diff --git a/sdk/security/azure-mgmt-security/CHANGELOG.md b/sdk/security/azure-mgmt-security/CHANGELOG.md index a57fcd2f2892..a04a69540747 100644 --- a/sdk/security/azure-mgmt-security/CHANGELOG.md +++ b/sdk/security/azure-mgmt-security/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 8.0.0b1 (2025-08-25) + +### Breaking Changes + +- This package now only targets the latest Api-Version available on Azure and removes APIs of other Api-Version. After this change, the package can have much smaller size. If your application requires a specific and non-latest Api-Version, it's recommended to pin this package to the previous released version; If your application always only use latest Api-Version, please ignore this change. + ## 7.0.0 (2024-05-20) ### Features Added diff --git a/sdk/security/azure-mgmt-security/MANIFEST.in b/sdk/security/azure-mgmt-security/MANIFEST.in index b0a417832daf..d8c3eb1171ee 100644 --- a/sdk/security/azure-mgmt-security/MANIFEST.in +++ b/sdk/security/azure-mgmt-security/MANIFEST.in @@ -1,4 +1,3 @@ -include _meta.json recursive-include tests *.py *.json recursive-include samples *.py *.md include *.md diff --git a/sdk/security/azure-mgmt-security/README.md b/sdk/security/azure-mgmt-security/README.md index 86e59f6919eb..c2e7c7023c79 100644 --- a/sdk/security/azure-mgmt-security/README.md +++ b/sdk/security/azure-mgmt-security/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Security Center Management Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.9+. 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.8+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/security/azure-mgmt-security/_meta.json b/sdk/security/azure-mgmt-security/_meta.json deleted file mode 100644 index 11ee7f358492..000000000000 --- a/sdk/security/azure-mgmt-security/_meta.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "commit": "5485fc4eb11debd9cc8d92ec156b573998aae977", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.13.16", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/security/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.13.16 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/security/resource-manager/readme.md", - "package-2023-11-15": "2023-09-12 12:04:57 -0700 32c178f2467f792a322f56174be244135d2c907f Microsoft.Security/stable/2023-11-15/apiCollections.json", - "package-preview-2023-03-only": "2023-03-23 11:34:42 +0200 2db2beee2fed67b08d273fdac7a51aba02ac2f80 Microsoft.Security/preview/2023-03-01-preview/securityConnectors.json", - "package-preview-2023-02-only": "2023-03-10 09:31:28 +0200 a2e2617050e68ae1c445db565076c5a7f42ebad4 Microsoft.Security/preview/2023-02-01-preview/healthReports.json", - "package-preview-2023-01-only": "2023-03-28 11:35:29 +0300 0e2c3d175e126284c5db1d3099b61e46e462fb74 Microsoft.Security/preview/2023-01-01-preview/securityOperators.json", - "package-2023-01": "2023-03-27 17:16:35 +0300 efd2b52bcf2b06e174f7008b2728f70ee7f972bd Microsoft.Security/stable/2023-01-01/pricings.json", - "package-preview-2022-12": "2023-09-12 22:01:54 +0300 b09b155f738b4178bcfe820f54f8702a94eb9d90 Microsoft.Security/preview/2022-12-01-preview/defenderForStorageSettings.json", - "package-preview-2022-08": "2022-09-20 03:45:43 +0300 9000eea3aa90071c2814f663dd763d7fc1668bed Microsoft.Security/preview/2022-08-01-preview/securityConnectors.json", - "package-preview-2022-07": "2022-11-01 04:47:16 +0200 312544c27464f61bf9639924099d4238bdfa1d71 Microsoft.Security/preview/2022-07-01-preview/applications.json", - "package-2022-05": "2022-06-09 12:47:24 +0300 d006e1d15d8fe19a6c558861dd5bba6b7baa8dd8 Microsoft.Security/stable/2022-05-01/settings.json", - "package-preview-2022-11": "2022-11-14 21:43:58 -0800 38995aeb1e63c781ae7c2cd176ea444480638093 Microsoft.Security/preview/2022-11-20-preview/apiCollections.json", - "package-preview-2022-05": "2022-06-24 06:02:22 +0300 0f8b747471c2bcae823c874e24e1b54726673a3a Microsoft.Security/preview/2022-05-01-preview/securityConnectors.json", - "package-2022-03": "2022-08-08 05:50:55 +0300 63312d0231ed57559b7f85548137cde356b98e57 Microsoft.Security/stable/2022-03-01/pricings.json", - "package-2022-01-only": "2023-03-02 10:05:39 +0800 c287c0fb1c00df4bb1812acec050d178fa969cb6 Microsoft.Security/stable/2022-01-01/alerts.json", - "package-2022-01-preview-only": "2023-01-24 09:46:27 +0200 9eb9c45842ba2932eee57326189019adc3018397 Microsoft.Security/preview/2022-01-01-preview/governanceRules.json", - "package-2021-10-preview-only": "2021-10-22 08:18:20 +0300 32652d34b63d39b2c9ca52cf97e2f805b881dd4a Microsoft.Security/preview/2021-10-01-preview/mdeOnboardings.json", - "package-2021-07-preview-only": "2022-02-16 05:25:20 +0200 72808f0e1bef87104ed97735158547422acb3d17 Microsoft.Security/preview/2021-07-01-preview/customAssessmentAutomation.json", - "package-2021-07-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/stable/2021-07-01/settings.json", - "package-2021-06-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/stable/2021-06-01/settings.json", - "package-2021-05-preview-only": "2021-05-20 10:54:13 +0300 5fcc6854765009e891052653b304cfe80353430a Microsoft.Security/preview/2021-05-01-preview/softwareInventories.json", - "package-2021-01-only": "2021-02-23 03:48:25 +0200 605f17bf33f419ee5cd3899f3ff799318a7caeb1 Microsoft.Security/stable/2021-01-01/alerts.json", - "package-2020-07-preview-only": "2020-10-28 04:54:24 +0200 f8440e900cea52b8347f63f9a755d1feeae6f161 Microsoft.Security/preview/2020-07-01-preview/sqlVulnerabilityAssessmentsScanResultsOperations.json", - "package-2020-01-python-only": "2022-05-17 18:32:46 +0300 9896393247d4098e6ff91944d2471385efaac804 Microsoft.Security/stable/2020-01-01/topologies.json", - "package-2020-01-preview-python-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/preview/2020-01-01-preview/securityContacts.json", - "package-2019-08-python-only": "2021-01-04 04:26:12 +0200 e5c779c267ed9d5ae7115ca71e16f3a6e6152bdd Microsoft.Security/stable/2019-08-01/iotSecuritySolutions.json", - "package-2019-01-python-only": "2022-02-23 11:14:18 +0800 8aa184e00b5314f9e293db0401e002cb99c85a91 Microsoft.Security/stable/2019-01-01/advancedThreatProtectionSettings.json", - "package-2019-01-preview-python-only": "2023-11-16 21:07:47 +0200 21d0c31470784c5765166f508c2892bdc6299444 Microsoft.Security/preview/2019-01-01-preview/alertsSuppressionRules.json", - "package-2018-06-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/stable/2018-06-01/pricings.json", - "package-2017-08-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/stable/2017-08-01/complianceResults.json", - "package-2017-08-preview-python-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/preview/2017-08-01-preview/securityContacts.json", - "package-2015-06-preview-python-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/preview/2015-06-01-preview/tasks.json", - "package-2024-04": "fatal: invalid object name 'from'. from: securityConnectorsDevOps.json", - "package-2024-01": "2023-12-13 05:43:47 +0200 b52464f520b77222ac8b0bdeb80a030c0fdf5b1b Microsoft.Security/stable/2024-01-01/pricings.json", - "package-preview-2023-10": "2023-10-27 04:43:14 +0300 2eb036ae2fcf0dab9bbc49f3aeadb7847c953f9a Microsoft.Security/preview/2023-10-01-preview/securityConnectors.json", - "package-preview-2023-09": "fatal: invalid object name 'from'. from: securityConnectorsDevOps.json", - "package-2023-05": "2023-06-07 22:07:01 -0700 483cdd30332340a14e3d09eafdc1a18f3ba4324c Microsoft.Security/stable/2023-05-01/ServerVulnerabilityAssessmentsSettings.json", - "package-preview-2023-05": "2023-05-29 05:03:56 +0300 be02493774ad6450166fa3383c109027658567b4 Microsoft.Security/preview/2023-05-01-preview/healthReports.json", - "package-preview-2023-02-15-only": "2024-03-29 06:00:35 +0300 7fa04c618c9a280dba63303b0034fa9f0aabab1f Microsoft.Security/preview/2023-02-15-preview/sensitivitySettings.json" -} \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/_metadata.json b/sdk/security/azure-mgmt-security/_metadata.json new file mode 100644 index 000000000000..6df441854665 --- /dev/null +++ b/sdk/security/azure-mgmt-security/_metadata.json @@ -0,0 +1,11 @@ +{ + "commit": "b64fe48e383ae6d6841fad0538f05dc82130ebb0", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.10.2", + "use": [ + "@autorest/python@6.38.2", + "@autorest/modelerfour@4.27.0" + ], + "autorest_command": "autorest specification/security/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --keep-setup-py=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-composite-v3 --use=@autorest/python@6.38.2 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/security/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/apiview-properties.json b/sdk/security/azure-mgmt-security/apiview-properties.json new file mode 100644 index 000000000000..33e867a0f086 --- /dev/null +++ b/sdk/security/azure-mgmt-security/apiview-properties.json @@ -0,0 +1,1119 @@ +{ + "CrossLanguagePackageId": null, + "CrossLanguageDefinitionId": { + "azure.mgmt.security.models.AadConnectivityState": null, + "azure.mgmt.security.models.Location": null, + "azure.mgmt.security.models.ExternalSecuritySolutionKind": null, + "azure.mgmt.security.models.Resource": null, + "azure.mgmt.security.models.ExternalSecuritySolution": null, + "azure.mgmt.security.models.AadExternalSecuritySolution": null, + "azure.mgmt.security.models.ExternalSecuritySolutionProperties": null, + "azure.mgmt.security.models.AadSolutionProperties": null, + "azure.mgmt.security.models.Authentication": null, + "azure.mgmt.security.models.AccessTokenAuthentication": null, + "azure.mgmt.security.models.ActionableRemediation": null, + "azure.mgmt.security.models.CustomAlertRule": null, + "azure.mgmt.security.models.ThresholdCustomAlertRule": null, + "azure.mgmt.security.models.TimeWindowCustomAlertRule": null, + "azure.mgmt.security.models.ActiveConnectionsNotInAllowedRange": null, + "azure.mgmt.security.models.AdditionalData": null, + "azure.mgmt.security.models.AdditionalWorkspacesProperties": null, + "azure.mgmt.security.models.AdvancedThreatProtectionSetting": null, + "azure.mgmt.security.models.AgentlessConfiguration": null, + "azure.mgmt.security.models.Alert": null, + "azure.mgmt.security.models.AlertEntity": null, + "azure.mgmt.security.models.AlertList": null, + "azure.mgmt.security.models.AlertPropertiesSupportingEvidence": null, + "azure.mgmt.security.models.AlertSimulatorRequestProperties": null, + "azure.mgmt.security.models.AlertSimulatorBundlesRequestProperties": null, + "azure.mgmt.security.models.AlertSimulatorRequestBody": null, + "azure.mgmt.security.models.AlertsSuppressionRule": null, + "azure.mgmt.security.models.AlertsSuppressionRulesList": null, + "azure.mgmt.security.models.Setting": null, + "azure.mgmt.security.models.AlertSyncSettings": null, + "azure.mgmt.security.models.AllowedConnectionsList": null, + "azure.mgmt.security.models.AllowedConnectionsResource": null, + "azure.mgmt.security.models.ListCustomAlertRule": null, + "azure.mgmt.security.models.AllowlistCustomAlertRule": null, + "azure.mgmt.security.models.AmqpC2DMessagesNotInAllowedRange": null, + "azure.mgmt.security.models.AmqpC2DRejectedMessagesNotInAllowedRange": null, + "azure.mgmt.security.models.AmqpD2CMessagesNotInAllowedRange": null, + "azure.mgmt.security.models.ApiCollection": null, + "azure.mgmt.security.models.ApiCollectionList": null, + "azure.mgmt.security.models.Application": null, + "azure.mgmt.security.models.ApplicationCondition": null, + "azure.mgmt.security.models.ApplicationsList": null, + "azure.mgmt.security.models.ArcAutoProvisioning": null, + "azure.mgmt.security.models.ArcAutoProvisioningAws": null, + "azure.mgmt.security.models.ArcAutoProvisioningConfiguration": null, + "azure.mgmt.security.models.ArcAutoProvisioningGcp": null, + "azure.mgmt.security.models.AscLocation": null, + "azure.mgmt.security.models.AscLocationList": null, + "azure.mgmt.security.models.AssessmentLinks": null, + "azure.mgmt.security.models.AssessmentStatus": null, + "azure.mgmt.security.models.AssessmentStatusResponse": null, + "azure.mgmt.security.models.AssignedAssessmentItem": null, + "azure.mgmt.security.models.AssignedStandardItem": null, + "azure.mgmt.security.models.AtaExternalSecuritySolution": null, + "azure.mgmt.security.models.AtaSolutionProperties": null, + "azure.mgmt.security.models.AttestationEvidence": null, + "azure.mgmt.security.models.AuthenticationDetailsProperties": null, + "azure.mgmt.security.models.Authorization": null, + "azure.mgmt.security.models.Tags": null, + "azure.mgmt.security.models.ETag": null, + "azure.mgmt.security.models.Kind": null, + "azure.mgmt.security.models.AzureTrackedResourceLocation": null, + "azure.mgmt.security.models.TrackedResource": null, + "azure.mgmt.security.models.Automation": null, + "azure.mgmt.security.models.AutomationAction": null, + "azure.mgmt.security.models.AutomationActionEventHub": null, + "azure.mgmt.security.models.AutomationActionLogicApp": null, + "azure.mgmt.security.models.AutomationActionWorkspace": null, + "azure.mgmt.security.models.AutomationList": null, + "azure.mgmt.security.models.AutomationRuleSet": null, + "azure.mgmt.security.models.AutomationScope": null, + "azure.mgmt.security.models.AutomationSource": null, + "azure.mgmt.security.models.AutomationTriggeringRule": null, + "azure.mgmt.security.models.AutomationUpdateModel": null, + "azure.mgmt.security.models.AutomationValidationStatus": null, + "azure.mgmt.security.models.AutoProvisioningSetting": null, + "azure.mgmt.security.models.AutoProvisioningSettingList": null, + "azure.mgmt.security.models.AwAssumeRoleAuthenticationDetailsProperties": null, + "azure.mgmt.security.models.AwsCredsAuthenticationDetailsProperties": null, + "azure.mgmt.security.models.EnvironmentData": null, + "azure.mgmt.security.models.AwsEnvironmentData": null, + "azure.mgmt.security.models.AwsOrganizationalData": null, + "azure.mgmt.security.models.AwsOrganizationalDataMaster": null, + "azure.mgmt.security.models.AwsOrganizationalDataMember": null, + "azure.mgmt.security.models.ResourceAutoGenerated3": null, + "azure.mgmt.security.models.ProxyResource": null, + "azure.mgmt.security.models.AzureDevOpsOrg": null, + "azure.mgmt.security.models.AzureDevOpsOrganizationConfiguration": null, + "azure.mgmt.security.models.AzureDevOpsOrgListResponse": null, + "azure.mgmt.security.models.AzureDevOpsOrgProperties": null, + "azure.mgmt.security.models.AzureDevOpsProject": null, + "azure.mgmt.security.models.AzureDevOpsProjectConfiguration": null, + "azure.mgmt.security.models.AzureDevOpsProjectListResponse": null, + "azure.mgmt.security.models.AzureDevOpsProjectProperties": null, + "azure.mgmt.security.models.AzureDevOpsRepository": null, + "azure.mgmt.security.models.AzureDevOpsRepositoryListResponse": null, + "azure.mgmt.security.models.AzureDevOpsRepositoryProperties": null, + "azure.mgmt.security.models.AzureDevOpsScopeEnvironmentData": null, + "azure.mgmt.security.models.ResourceDetails": null, + "azure.mgmt.security.models.AzureResourceDetails": null, + "azure.mgmt.security.models.ResourceIdentifier": null, + "azure.mgmt.security.models.AzureResourceIdentifier": null, + "azure.mgmt.security.models.AzureResourceLink": null, + "azure.mgmt.security.models.ResourceAutoGenerated": null, + "azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting": null, + "azure.mgmt.security.models.AzureServersSetting": null, + "azure.mgmt.security.models.Baseline": null, + "azure.mgmt.security.models.BaselineAdjustedResult": null, + "azure.mgmt.security.models.BaseResourceConfiguration": null, + "azure.mgmt.security.models.BenchmarkReference": null, + "azure.mgmt.security.models.BlobsScanSummary": null, + "azure.mgmt.security.models.BuiltInInfoType": null, + "azure.mgmt.security.models.CategoryConfiguration": null, + "azure.mgmt.security.models.CefExternalSecuritySolution": null, + "azure.mgmt.security.models.CefSolutionProperties": null, + "azure.mgmt.security.models.CloudErrorBody": null, + "azure.mgmt.security.models.CloudOffering": null, + "azure.mgmt.security.models.Compliance": null, + "azure.mgmt.security.models.ComplianceList": null, + "azure.mgmt.security.models.ComplianceResult": null, + "azure.mgmt.security.models.ComplianceResultList": null, + "azure.mgmt.security.models.ComplianceSegment": null, + "azure.mgmt.security.models.Components1Uu4J47SchemasSecurityassessmentpropertiesbasePropertiesRiskPropertiesPathsItemsPropertiesEdgesItems": null, + "azure.mgmt.security.models.Condition": null, + "azure.mgmt.security.models.ConnectableResource": null, + "azure.mgmt.security.models.ConnectedResource": null, + "azure.mgmt.security.models.ConnectedWorkspace": null, + "azure.mgmt.security.models.ConnectionFromIpNotAllowed": null, + "azure.mgmt.security.models.ConnectionToIpNotAllowed": null, + "azure.mgmt.security.models.ConnectorSetting": null, + "azure.mgmt.security.models.ConnectorSettingList": null, + "azure.mgmt.security.models.ContainerRegistryVulnerabilityProperties": null, + "azure.mgmt.security.models.CspmMonitorAwsOffering": null, + "azure.mgmt.security.models.CspmMonitorAwsOfferingNativeCloudConnection": null, + "azure.mgmt.security.models.CspmMonitorAzureDevOpsOffering": null, + "azure.mgmt.security.models.CspmMonitorDockerHubOffering": null, + "azure.mgmt.security.models.CspmMonitorGcpOffering": null, + "azure.mgmt.security.models.CspmMonitorGcpOfferingNativeCloudConnection": null, + "azure.mgmt.security.models.CspmMonitorGithubOffering": null, + "azure.mgmt.security.models.CspmMonitorGitLabOffering": null, + "azure.mgmt.security.models.CspmMonitorJFrogOffering": null, + "azure.mgmt.security.models.CustomAssessmentAutomation": null, + "azure.mgmt.security.models.CustomAssessmentAutomationRequest": null, + "azure.mgmt.security.models.CustomAssessmentAutomationsListResult": null, + "azure.mgmt.security.models.CustomEntityStoreAssignment": null, + "azure.mgmt.security.models.CustomEntityStoreAssignmentRequest": null, + "azure.mgmt.security.models.CustomEntityStoreAssignmentsListResult": null, + "azure.mgmt.security.models.CustomRecommendation": null, + "azure.mgmt.security.models.CustomRecommendationsList": null, + "azure.mgmt.security.models.CVE": null, + "azure.mgmt.security.models.CVSS": null, + "azure.mgmt.security.models.DataExportSettings": null, + "azure.mgmt.security.models.DefenderCspmAwsOffering": null, + "azure.mgmt.security.models.DefenderCspmAwsOfferingCiem": null, + "azure.mgmt.security.models.DefenderCspmAwsOfferingCiemDiscovery": null, + "azure.mgmt.security.models.DefenderCspmAwsOfferingCiemOidc": null, + "azure.mgmt.security.models.DefenderCspmAwsOfferingDatabasesDspm": null, + "azure.mgmt.security.models.DefenderCspmAwsOfferingDataSensitivityDiscovery": null, + "azure.mgmt.security.models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S": null, + "azure.mgmt.security.models.DefenderCspmAwsOfferingMdcContainersImageAssessment": null, + "azure.mgmt.security.models.VmScannersBase": null, + "azure.mgmt.security.models.VmScannersAws": null, + "azure.mgmt.security.models.DefenderCspmAwsOfferingVmScanners": null, + "azure.mgmt.security.models.DefenderCspmDockerHubOffering": null, + "azure.mgmt.security.models.DefenderCspmGcpOffering": null, + "azure.mgmt.security.models.DefenderCspmGcpOfferingCiemDiscovery": null, + "azure.mgmt.security.models.DefenderCspmGcpOfferingDataSensitivityDiscovery": null, + "azure.mgmt.security.models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S": null, + "azure.mgmt.security.models.DefenderCspmGcpOfferingMdcContainersImageAssessment": null, + "azure.mgmt.security.models.VmScannersGcp": null, + "azure.mgmt.security.models.DefenderCspmGcpOfferingVmScanners": null, + "azure.mgmt.security.models.DefenderCspmJFrogOffering": null, + "azure.mgmt.security.models.DefenderCspmJFrogOfferingMdcContainersImageAssessment": null, + "azure.mgmt.security.models.DefenderFoDatabasesAwsOffering": null, + "azure.mgmt.security.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning": null, + "azure.mgmt.security.models.DefenderFoDatabasesAwsOfferingDatabasesDspm": null, + "azure.mgmt.security.models.DefenderFoDatabasesAwsOfferingRds": null, + "azure.mgmt.security.models.DefenderForContainersAwsOffering": null, + "azure.mgmt.security.models.DefenderForContainersAwsOfferingCloudWatchToKinesis": null, + "azure.mgmt.security.models.DefenderForContainersAwsOfferingKinesisToS3": null, + "azure.mgmt.security.models.DefenderForContainersAwsOfferingKubernetesDataCollection": null, + "azure.mgmt.security.models.DefenderForContainersAwsOfferingKubernetesService": null, + "azure.mgmt.security.models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S": null, + "azure.mgmt.security.models.DefenderForContainersAwsOfferingMdcContainersImageAssessment": null, + "azure.mgmt.security.models.DefenderForContainersAwsOfferingVmScanners": null, + "azure.mgmt.security.models.DefenderForContainersDockerHubOffering": null, + "azure.mgmt.security.models.DefenderForContainersGcpOffering": null, + "azure.mgmt.security.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection": null, + "azure.mgmt.security.models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S": null, + "azure.mgmt.security.models.DefenderForContainersGcpOfferingMdcContainersImageAssessment": null, + "azure.mgmt.security.models.DefenderForContainersGcpOfferingNativeCloudConnection": null, + "azure.mgmt.security.models.DefenderForContainersGcpOfferingVmScanners": null, + "azure.mgmt.security.models.DefenderForContainersJFrogOffering": null, + "azure.mgmt.security.models.DefenderForDatabasesGcpOffering": null, + "azure.mgmt.security.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning": null, + "azure.mgmt.security.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning": null, + "azure.mgmt.security.models.DefenderForServersAwsOffering": null, + "azure.mgmt.security.models.DefenderForServersAwsOfferingArcAutoProvisioning": null, + "azure.mgmt.security.models.DefenderForServersAwsOfferingDefenderForServers": null, + "azure.mgmt.security.models.DefenderForServersAwsOfferingMdeAutoProvisioning": null, + "azure.mgmt.security.models.DefenderForServersAwsOfferingSubPlan": null, + "azure.mgmt.security.models.DefenderForServersAwsOfferingVaAutoProvisioning": null, + "azure.mgmt.security.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration": null, + "azure.mgmt.security.models.DefenderForServersAwsOfferingVmScanners": null, + "azure.mgmt.security.models.DefenderForServersGcpOffering": null, + "azure.mgmt.security.models.DefenderForServersGcpOfferingArcAutoProvisioning": null, + "azure.mgmt.security.models.DefenderForServersGcpOfferingDefenderForServers": null, + "azure.mgmt.security.models.DefenderForServersGcpOfferingMdeAutoProvisioning": null, + "azure.mgmt.security.models.DefenderForServersGcpOfferingSubPlan": null, + "azure.mgmt.security.models.DefenderForServersGcpOfferingVaAutoProvisioning": null, + "azure.mgmt.security.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration": null, + "azure.mgmt.security.models.DefenderForServersGcpOfferingVmScanners": null, + "azure.mgmt.security.models.DefenderForStorageSetting": null, + "azure.mgmt.security.models.DefenderForStorageSettingProperties": null, + "azure.mgmt.security.models.DenylistCustomAlertRule": null, + "azure.mgmt.security.models.DeviceSecurityGroup": null, + "azure.mgmt.security.models.DeviceSecurityGroupList": null, + "azure.mgmt.security.models.DevOpsCapability": null, + "azure.mgmt.security.models.DevOpsConfiguration": null, + "azure.mgmt.security.models.DevOpsConfigurationListResponse": null, + "azure.mgmt.security.models.DevOpsConfigurationProperties": null, + "azure.mgmt.security.models.DirectMethodInvokesNotInAllowedRange": null, + "azure.mgmt.security.models.DiscoveredSecuritySolution": null, + "azure.mgmt.security.models.DiscoveredSecuritySolutionList": null, + "azure.mgmt.security.models.DockerHubEnvironmentData": null, + "azure.mgmt.security.models.EdgeIdentifiers": null, + "azure.mgmt.security.models.EnvironmentDetails": null, + "azure.mgmt.security.models.ErrorAdditionalInfo": null, + "azure.mgmt.security.models.ErrorDetail": null, + "azure.mgmt.security.models.ErrorDetailAutoGenerated": null, + "azure.mgmt.security.models.ErrorDetailAutoGenerated2": null, + "azure.mgmt.security.models.ErrorResponse": null, + "azure.mgmt.security.models.ErrorResponseAutoGenerated": null, + "azure.mgmt.security.models.ErrorResponseAutoGenerated2": null, + "azure.mgmt.security.models.ExecuteGovernanceRuleParams": null, + "azure.mgmt.security.models.Extension": null, + "azure.mgmt.security.models.ExternalSecuritySolutionList": null, + "azure.mgmt.security.models.FailedLocalLoginsNotInAllowedRange": null, + "azure.mgmt.security.models.FileUploadsNotInAllowedRange": null, + "azure.mgmt.security.models.GcpCredentialsDetailsProperties": null, + "azure.mgmt.security.models.GcpOrganizationalData": null, + "azure.mgmt.security.models.GcpOrganizationalDataMember": null, + "azure.mgmt.security.models.GcpOrganizationalDataOrganization": null, + "azure.mgmt.security.models.GcpProjectDetails": null, + "azure.mgmt.security.models.GcpProjectEnvironmentData": null, + "azure.mgmt.security.models.GetSensitivitySettingsListResponse": null, + "azure.mgmt.security.models.GetSensitivitySettingsResponse": null, + "azure.mgmt.security.models.GetSensitivitySettingsResponseProperties": null, + "azure.mgmt.security.models.GetSensitivitySettingsResponsePropertiesMipInformation": null, + "azure.mgmt.security.models.GitHubOwner": null, + "azure.mgmt.security.models.GitHubOwnerConfiguration": null, + "azure.mgmt.security.models.GitHubOwnerListResponse": null, + "azure.mgmt.security.models.GitHubOwnerProperties": null, + "azure.mgmt.security.models.GitHubRepository": null, + "azure.mgmt.security.models.GitHubRepositoryListResponse": null, + "azure.mgmt.security.models.GitHubRepositoryProperties": null, + "azure.mgmt.security.models.GithubScopeEnvironmentData": null, + "azure.mgmt.security.models.GitLabGroup": null, + "azure.mgmt.security.models.GitLabGroupConfiguration": null, + "azure.mgmt.security.models.GitLabGroupListResponse": null, + "azure.mgmt.security.models.GitLabGroupProperties": null, + "azure.mgmt.security.models.GitLabProject": null, + "azure.mgmt.security.models.GitLabProjectListResponse": null, + "azure.mgmt.security.models.GitLabProjectProperties": null, + "azure.mgmt.security.models.GitlabScopeEnvironmentData": null, + "azure.mgmt.security.models.GovernanceAssignment": null, + "azure.mgmt.security.models.GovernanceAssignmentAdditionalData": null, + "azure.mgmt.security.models.GovernanceAssignmentsList": null, + "azure.mgmt.security.models.GovernanceEmailNotification": null, + "azure.mgmt.security.models.GovernanceRule": null, + "azure.mgmt.security.models.GovernanceRuleEmailNotification": null, + "azure.mgmt.security.models.GovernanceRuleList": null, + "azure.mgmt.security.models.GovernanceRuleMetadata": null, + "azure.mgmt.security.models.GovernanceRuleOwnerSource": null, + "azure.mgmt.security.models.HealthDataClassification": null, + "azure.mgmt.security.models.HealthReport": null, + "azure.mgmt.security.models.HealthReportsList": null, + "azure.mgmt.security.models.HttpC2DMessagesNotInAllowedRange": null, + "azure.mgmt.security.models.HttpC2DRejectedMessagesNotInAllowedRange": null, + "azure.mgmt.security.models.HttpD2CMessagesNotInAllowedRange": null, + "azure.mgmt.security.models.HybridComputeSettingsProperties": null, + "azure.mgmt.security.models.Identity": null, + "azure.mgmt.security.models.InformationProtectionKeyword": null, + "azure.mgmt.security.models.InformationProtectionPolicy": null, + "azure.mgmt.security.models.InformationProtectionPolicyList": null, + "azure.mgmt.security.models.InformationType": null, + "azure.mgmt.security.models.InfoType": null, + "azure.mgmt.security.models.InventoryList": null, + "azure.mgmt.security.models.TagsResource": null, + "azure.mgmt.security.models.IoTSecurityAggregatedAlert": null, + "azure.mgmt.security.models.IoTSecurityAggregatedAlertList": null, + "azure.mgmt.security.models.IoTSecurityAggregatedAlertPropertiesTopDevicesListItem": null, + "azure.mgmt.security.models.IoTSecurityAggregatedRecommendation": null, + "azure.mgmt.security.models.IoTSecurityAggregatedRecommendationList": null, + "azure.mgmt.security.models.IoTSecurityAlertedDevice": null, + "azure.mgmt.security.models.IoTSecurityDeviceAlert": null, + "azure.mgmt.security.models.IoTSecurityDeviceRecommendation": null, + "azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModel": null, + "azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModelList": null, + "azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem": null, + "azure.mgmt.security.models.IoTSecuritySolutionModel": null, + "azure.mgmt.security.models.IoTSecuritySolutionsList": null, + "azure.mgmt.security.models.IoTSeverityMetrics": null, + "azure.mgmt.security.models.Issue": null, + "azure.mgmt.security.models.JFrogEnvironmentData": null, + "azure.mgmt.security.models.JitNetworkAccessPoliciesList": null, + "azure.mgmt.security.models.JitNetworkAccessPolicy": null, + "azure.mgmt.security.models.JitNetworkAccessPolicyInitiatePort": null, + "azure.mgmt.security.models.JitNetworkAccessPolicyInitiateRequest": null, + "azure.mgmt.security.models.JitNetworkAccessPolicyInitiateVirtualMachine": null, + "azure.mgmt.security.models.JitNetworkAccessPolicyVirtualMachine": null, + "azure.mgmt.security.models.JitNetworkAccessPortRule": null, + "azure.mgmt.security.models.JitNetworkAccessRequest": null, + "azure.mgmt.security.models.JitNetworkAccessRequestPort": null, + "azure.mgmt.security.models.JitNetworkAccessRequestVirtualMachine": null, + "azure.mgmt.security.models.Label": null, + "azure.mgmt.security.models.LocalUserNotAllowed": null, + "azure.mgmt.security.models.LogAnalyticsIdentifier": null, + "azure.mgmt.security.models.MalwareScan": null, + "azure.mgmt.security.models.MalwareScanningProperties": null, + "azure.mgmt.security.models.MalwareScanProperties": null, + "azure.mgmt.security.models.MdeOnboardingData": null, + "azure.mgmt.security.models.MdeOnboardingDataList": null, + "azure.mgmt.security.models.MqttC2DMessagesNotInAllowedRange": null, + "azure.mgmt.security.models.MqttC2DRejectedMessagesNotInAllowedRange": null, + "azure.mgmt.security.models.MqttD2CMessagesNotInAllowedRange": null, + "azure.mgmt.security.models.NodeIdentifier": null, + "azure.mgmt.security.models.NotificationsSource": null, + "azure.mgmt.security.models.NotificationsSourceAlert": null, + "azure.mgmt.security.models.NotificationsSourceAttackPath": null, + "azure.mgmt.security.models.OnPremiseResourceDetails": null, + "azure.mgmt.security.models.OnPremiseSqlResourceDetails": null, + "azure.mgmt.security.models.OnUploadFilters": null, + "azure.mgmt.security.models.OnUploadProperties": null, + "azure.mgmt.security.models.Operation": null, + "azure.mgmt.security.models.OperationDisplay": null, + "azure.mgmt.security.models.OperationListResult": null, + "azure.mgmt.security.models.OperationResultAutoGenerated": null, + "azure.mgmt.security.models.OperationStatus": null, + "azure.mgmt.security.models.OperationStatusAutoGenerated": null, + "azure.mgmt.security.models.OperationStatusResult": null, + "azure.mgmt.security.models.PartialAssessmentProperties": null, + "azure.mgmt.security.models.Path": null, + "azure.mgmt.security.models.Pricing": null, + "azure.mgmt.security.models.PricingList": null, + "azure.mgmt.security.models.PrivateEndpoint": null, + "azure.mgmt.security.models.PrivateEndpointConnection": null, + "azure.mgmt.security.models.PrivateEndpointConnectionListResult": null, + "azure.mgmt.security.models.PrivateLinkParameters": null, + "azure.mgmt.security.models.ResourceAutoGenerated2": null, + "azure.mgmt.security.models.TrackedResourceAutoGenerated": null, + "azure.mgmt.security.models.PrivateLinkResource": null, + "azure.mgmt.security.models.PrivateLinkResourceAutoGenerated": null, + "azure.mgmt.security.models.PrivateLinkResourceListResult": null, + "azure.mgmt.security.models.PrivateLinkServiceConnectionState": null, + "azure.mgmt.security.models.PrivateLinksList": null, + "azure.mgmt.security.models.PrivateLinkUpdate": null, + "azure.mgmt.security.models.ProcessNotAllowed": null, + "azure.mgmt.security.models.ProxyServerProperties": null, + "azure.mgmt.security.models.QueryCheck": null, + "azure.mgmt.security.models.QueuePurgesNotInAllowedRange": null, + "azure.mgmt.security.models.RecommendationConfigurationProperties": null, + "azure.mgmt.security.models.RegulatoryComplianceAssessment": null, + "azure.mgmt.security.models.RegulatoryComplianceAssessmentList": null, + "azure.mgmt.security.models.RegulatoryComplianceControl": null, + "azure.mgmt.security.models.RegulatoryComplianceControlList": null, + "azure.mgmt.security.models.RegulatoryComplianceStandard": null, + "azure.mgmt.security.models.RegulatoryComplianceStandardList": null, + "azure.mgmt.security.models.Remediation": null, + "azure.mgmt.security.models.RemediationEta": null, + "azure.mgmt.security.models.ResourceDetailsAutoGenerated": null, + "azure.mgmt.security.models.RuleResults": null, + "azure.mgmt.security.models.RuleResultsInput": null, + "azure.mgmt.security.models.RuleResultsProperties": null, + "azure.mgmt.security.models.RulesResults": null, + "azure.mgmt.security.models.RulesResultsInput": null, + "azure.mgmt.security.models.Scan": null, + "azure.mgmt.security.models.ScanProperties": null, + "azure.mgmt.security.models.ScanResult": null, + "azure.mgmt.security.models.ScanResultProperties": null, + "azure.mgmt.security.models.ScanResults": null, + "azure.mgmt.security.models.Scans": null, + "azure.mgmt.security.models.ScanSummary": null, + "azure.mgmt.security.models.ScopeElement": null, + "azure.mgmt.security.models.SecureScoreControlDefinitionItem": null, + "azure.mgmt.security.models.SecureScoreControlDefinitionList": null, + "azure.mgmt.security.models.SecureScoreControlDefinitionSource": null, + "azure.mgmt.security.models.SecureScoreControlDetails": null, + "azure.mgmt.security.models.SecureScoreControlList": null, + "azure.mgmt.security.models.SecureScoreControlScore": null, + "azure.mgmt.security.models.SecureScoreItem": null, + "azure.mgmt.security.models.SecureScoresList": null, + "azure.mgmt.security.models.SecurityAssessment": null, + "azure.mgmt.security.models.SecurityAssessmentList": null, + "azure.mgmt.security.models.SecurityAssessmentMetadata": null, + "azure.mgmt.security.models.SecurityAssessmentMetadataPartnerData": null, + "azure.mgmt.security.models.SecurityAssessmentMetadataProperties": null, + "azure.mgmt.security.models.SecurityAssessmentMetadataPropertiesResponse": null, + "azure.mgmt.security.models.SecurityAssessmentMetadataPropertiesResponsePublishDates": null, + "azure.mgmt.security.models.SecurityAssessmentMetadataResponse": null, + "azure.mgmt.security.models.SecurityAssessmentMetadataResponseList": null, + "azure.mgmt.security.models.SecurityAssessmentPartnerData": null, + "azure.mgmt.security.models.SecurityAssessmentPropertiesBase": null, + "azure.mgmt.security.models.SecurityAssessmentProperties": null, + "azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk": null, + "azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRiskPathsItem": null, + "azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRiskPathsPropertiesItemsItem": null, + "azure.mgmt.security.models.SecurityAssessmentPropertiesResponse": null, + "azure.mgmt.security.models.SecurityAssessmentResponse": null, + "azure.mgmt.security.models.SecurityConnector": null, + "azure.mgmt.security.models.SecurityConnectorsList": null, + "azure.mgmt.security.models.SecurityContact": null, + "azure.mgmt.security.models.SecurityContactList": null, + "azure.mgmt.security.models.SecurityContactPropertiesNotificationsByRole": null, + "azure.mgmt.security.models.SecurityOperator": null, + "azure.mgmt.security.models.SecurityOperatorList": null, + "azure.mgmt.security.models.SecuritySolution": null, + "azure.mgmt.security.models.SecuritySolutionList": null, + "azure.mgmt.security.models.SecuritySolutionsReferenceData": null, + "azure.mgmt.security.models.SecuritySolutionsReferenceDataList": null, + "azure.mgmt.security.models.SecurityStandard": null, + "azure.mgmt.security.models.SecurityStandardList": null, + "azure.mgmt.security.models.SecuritySubAssessment": null, + "azure.mgmt.security.models.SecuritySubAssessmentList": null, + "azure.mgmt.security.models.SecurityTask": null, + "azure.mgmt.security.models.SecurityTaskList": null, + "azure.mgmt.security.models.SecurityTaskParameters": null, + "azure.mgmt.security.models.SensitiveDataDiscoveryProperties": null, + "azure.mgmt.security.models.SensitivityLabel": null, + "azure.mgmt.security.models.ServerVulnerabilityAssessment": null, + "azure.mgmt.security.models.ServerVulnerabilityAssessmentsList": null, + "azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingsList": null, + "azure.mgmt.security.models.ServerVulnerabilityProperties": null, + "azure.mgmt.security.models.ServicePrincipalProperties": null, + "azure.mgmt.security.models.SettingsList": null, + "azure.mgmt.security.models.Software": null, + "azure.mgmt.security.models.SoftwaresList": null, + "azure.mgmt.security.models.SqlServerVulnerabilityProperties": null, + "azure.mgmt.security.models.StandardAssignment": null, + "azure.mgmt.security.models.StandardAssignmentMetadata": null, + "azure.mgmt.security.models.StandardAssignmentPropertiesAttestationData": null, + "azure.mgmt.security.models.StandardAssignmentPropertiesExemptionData": null, + "azure.mgmt.security.models.StandardAssignmentsList": null, + "azure.mgmt.security.models.StandardMetadata": null, + "azure.mgmt.security.models.StatusAutoGenerated": null, + "azure.mgmt.security.models.SubAssessmentStatus": null, + "azure.mgmt.security.models.SuppressionAlertsScope": null, + "azure.mgmt.security.models.SystemData": null, + "azure.mgmt.security.models.TargetBranchConfiguration": null, + "azure.mgmt.security.models.TopologyList": null, + "azure.mgmt.security.models.TopologyResource": null, + "azure.mgmt.security.models.TopologySingleResource": null, + "azure.mgmt.security.models.TopologySingleResourceChild": null, + "azure.mgmt.security.models.TopologySingleResourceParent": null, + "azure.mgmt.security.models.TwinUpdatesNotInAllowedRange": null, + "azure.mgmt.security.models.UnauthorizedOperationsNotInAllowedRange": null, + "azure.mgmt.security.models.UpdateIotSecuritySolutionData": null, + "azure.mgmt.security.models.UpdateSensitivitySettingsRequest": null, + "azure.mgmt.security.models.UserDefinedResourcesProperties": null, + "azure.mgmt.security.models.VaRule": null, + "azure.mgmt.security.models.VendorReference": null, + "azure.mgmt.security.models.VmScannersBaseConfiguration": null, + "azure.mgmt.security.models.WorkspaceSetting": null, + "azure.mgmt.security.models.WorkspaceSettingList": null, + "azure.mgmt.security.models.AutoProvision": null, + "azure.mgmt.security.models.Rank": null, + "azure.mgmt.security.models.RuleState": null, + "azure.mgmt.security.models.State": null, + "azure.mgmt.security.models.SubAssessmentStatusCode": null, + "azure.mgmt.security.models.Severity": null, + "azure.mgmt.security.models.Source": null, + "azure.mgmt.security.models.AssessedResourceType": null, + "azure.mgmt.security.models.PermissionProperty": null, + "azure.mgmt.security.models.HybridComputeProvisioningState": null, + "azure.mgmt.security.models.AuthenticationProvisioningState": null, + "azure.mgmt.security.models.AuthenticationType": null, + "azure.mgmt.security.models.EndOfSupportStatus": null, + "azure.mgmt.security.models.CreatedByType": null, + "azure.mgmt.security.models.SupportedCloudEnum": null, + "azure.mgmt.security.models.SeverityEnum": null, + "azure.mgmt.security.models.GovernanceRuleType": null, + "azure.mgmt.security.models.GovernanceRuleSourceResourceType": null, + "azure.mgmt.security.models.GovernanceRuleOwnerSourceType": null, + "azure.mgmt.security.models.ApplicationSourceResourceType": null, + "azure.mgmt.security.models.ScanTriggerType": null, + "azure.mgmt.security.models.ScanState": null, + "azure.mgmt.security.models.RuleStatus": null, + "azure.mgmt.security.models.RuleSeverity": null, + "azure.mgmt.security.models.RuleType": null, + "azure.mgmt.security.models.MipIntegrationStatus": null, + "azure.mgmt.security.models.StatusName": null, + "azure.mgmt.security.models.PropertyType": null, + "azure.mgmt.security.models.Operator": null, + "azure.mgmt.security.models.EventSource": null, + "azure.mgmt.security.models.ActionType": null, + "azure.mgmt.security.models.SourceType": null, + "azure.mgmt.security.models.MinimalSeverity": null, + "azure.mgmt.security.models.MinimalRiskLevel": null, + "azure.mgmt.security.models.SecurityContactRole": null, + "azure.mgmt.security.models.OfferingType": null, + "azure.mgmt.security.models.ScanningMode": null, + "azure.mgmt.security.models.Type": null, + "azure.mgmt.security.models.SubPlan": null, + "azure.mgmt.security.models.CloudName": null, + "azure.mgmt.security.models.EnvironmentType": null, + "azure.mgmt.security.models.OrganizationMembershipType": null, + "azure.mgmt.security.models.Origin": null, + "azure.mgmt.security.models.Tactics": null, + "azure.mgmt.security.models.Techniques": null, + "azure.mgmt.security.models.Categories": null, + "azure.mgmt.security.models.Threats": null, + "azure.mgmt.security.models.UserImpact": null, + "azure.mgmt.security.models.ImplementationEffort": null, + "azure.mgmt.security.models.AssessmentType": null, + "azure.mgmt.security.models.RiskLevel": null, + "azure.mgmt.security.models.AssessmentStatusCode": null, + "azure.mgmt.security.models.PrivateEndpointServiceConnectionStatus": null, + "azure.mgmt.security.models.PrivateEndpointConnectionProvisioningState": null, + "azure.mgmt.security.models.ProvisioningState": null, + "azure.mgmt.security.models.ResourceStatus": null, + "azure.mgmt.security.models.ValueType": null, + "azure.mgmt.security.models.ReportedSeverity": null, + "azure.mgmt.security.models.ExportData": null, + "azure.mgmt.security.models.DataSource": null, + "azure.mgmt.security.models.RecommendationType": null, + "azure.mgmt.security.models.RecommendationConfigStatus": null, + "azure.mgmt.security.models.AdditionalWorkspaceDataType": null, + "azure.mgmt.security.models.AdditionalWorkspaceType": null, + "azure.mgmt.security.models.SecuritySolutionStatus": null, + "azure.mgmt.security.models.UnmaskedIpLoggingStatus": null, + "azure.mgmt.security.models.SecurityFamily": null, + "azure.mgmt.security.models.ExternalSecuritySolutionKindEnum": null, + "azure.mgmt.security.models.ProtocolEnum": null, + "azure.mgmt.security.models.Status": null, + "azure.mgmt.security.models.StatusReason": null, + "azure.mgmt.security.models.ControlType": null, + "azure.mgmt.security.models.ServerVulnerabilityAssessmentPropertiesProvisioningState": null, + "azure.mgmt.security.models.ResourceIdentifierType": null, + "azure.mgmt.security.models.AlertSeverity": null, + "azure.mgmt.security.models.Intent": null, + "azure.mgmt.security.models.AlertStatus": null, + "azure.mgmt.security.models.SettingKind": null, + "azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKind": null, + "azure.mgmt.security.models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider": null, + "azure.mgmt.security.models.IsEnabled": null, + "azure.mgmt.security.models.Code": null, + "azure.mgmt.security.models.PricingTier": null, + "azure.mgmt.security.models.Enforce": null, + "azure.mgmt.security.models.Inherited": null, + "azure.mgmt.security.models.ResourcesCoverageStatus": null, + "azure.mgmt.security.models.StandardSupportedCloud": null, + "azure.mgmt.security.models.StandardType": null, + "azure.mgmt.security.models.Effect": null, + "azure.mgmt.security.models.ExemptionCategory": null, + "azure.mgmt.security.models.AttestationComplianceState": null, + "azure.mgmt.security.models.RecommendationSupportedClouds": null, + "azure.mgmt.security.models.SecurityIssue": null, + "azure.mgmt.security.models.RuleCategory": null, + "azure.mgmt.security.models.DevOpsProvisioningState": null, + "azure.mgmt.security.models.OnboardingState": null, + "azure.mgmt.security.models.ActionableRemediationState": null, + "azure.mgmt.security.models.AnnotateDefaultBranchState": null, + "azure.mgmt.security.models.InheritFromParentState": null, + "azure.mgmt.security.models.InventoryKind": null, + "azure.mgmt.security.models.AutoDiscovery": null, + "azure.mgmt.security.models.AgentlessEnablement": null, + "azure.mgmt.security.models.InventoryListKind": null, + "azure.mgmt.security.models.GovernanceRuleConditionOperator": null, + "azure.mgmt.security.models.ApplicationConditionOperator": null, + "azure.mgmt.security.models.BundleType": null, + "azure.mgmt.security.models.TaskUpdateActionType": null, + "azure.mgmt.security.models.InformationProtectionPolicyName": null, + "azure.mgmt.security.models.OperationResult": null, + "azure.mgmt.security.models.SecurityContactName": null, + "azure.mgmt.security.models.SettingName": null, + "azure.mgmt.security.models.BlobScanResultsOptions": null, + "azure.mgmt.security.models.ExpandEnum": null, + "azure.mgmt.security.models.ConnectionType": null, + "azure.mgmt.security.models.ExpandControlsEnum": null, + "azure.mgmt.security.models.KindEnum": null, + "azure.mgmt.security.models.SettingNameAutoGenerated": null, + "azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName": null, + "azure.mgmt.security.models.AadConnectivityStateEnum": null, + "azure.mgmt.security.models.DesiredOnboardingState": null, + "azure.mgmt.security.operations.LocationsOperations.list": null, + "azure.mgmt.security.aio.operations.LocationsOperations.list": null, + "azure.mgmt.security.operations.LocationsOperations.get": null, + "azure.mgmt.security.aio.operations.LocationsOperations.get": null, + "azure.mgmt.security.operations.TasksOperations.list": null, + "azure.mgmt.security.aio.operations.TasksOperations.list": null, + "azure.mgmt.security.operations.TasksOperations.list_by_home_region": null, + "azure.mgmt.security.aio.operations.TasksOperations.list_by_home_region": null, + "azure.mgmt.security.operations.TasksOperations.get_subscription_level_task": null, + "azure.mgmt.security.aio.operations.TasksOperations.get_subscription_level_task": null, + "azure.mgmt.security.operations.TasksOperations.update_subscription_level_task_state": null, + "azure.mgmt.security.aio.operations.TasksOperations.update_subscription_level_task_state": null, + "azure.mgmt.security.operations.TasksOperations.list_by_resource_group": null, + "azure.mgmt.security.aio.operations.TasksOperations.list_by_resource_group": null, + "azure.mgmt.security.operations.TasksOperations.get_resource_group_level_task": null, + "azure.mgmt.security.aio.operations.TasksOperations.get_resource_group_level_task": null, + "azure.mgmt.security.operations.TasksOperations.update_resource_group_level_task_state": null, + "azure.mgmt.security.aio.operations.TasksOperations.update_resource_group_level_task_state": null, + "azure.mgmt.security.operations.AutoProvisioningSettingsOperations.list": null, + "azure.mgmt.security.aio.operations.AutoProvisioningSettingsOperations.list": null, + "azure.mgmt.security.operations.AutoProvisioningSettingsOperations.get": null, + "azure.mgmt.security.aio.operations.AutoProvisioningSettingsOperations.get": null, + "azure.mgmt.security.operations.AutoProvisioningSettingsOperations.create": null, + "azure.mgmt.security.aio.operations.AutoProvisioningSettingsOperations.create": null, + "azure.mgmt.security.operations.CompliancesOperations.list": null, + "azure.mgmt.security.aio.operations.CompliancesOperations.list": null, + "azure.mgmt.security.operations.CompliancesOperations.get": null, + "azure.mgmt.security.aio.operations.CompliancesOperations.get": null, + "azure.mgmt.security.operations.InformationProtectionPoliciesOperations.get": null, + "azure.mgmt.security.aio.operations.InformationProtectionPoliciesOperations.get": null, + "azure.mgmt.security.operations.InformationProtectionPoliciesOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.InformationProtectionPoliciesOperations.create_or_update": null, + "azure.mgmt.security.operations.InformationProtectionPoliciesOperations.list": null, + "azure.mgmt.security.aio.operations.InformationProtectionPoliciesOperations.list": null, + "azure.mgmt.security.operations.WorkspaceSettingsOperations.list": null, + "azure.mgmt.security.aio.operations.WorkspaceSettingsOperations.list": null, + "azure.mgmt.security.operations.WorkspaceSettingsOperations.get": null, + "azure.mgmt.security.aio.operations.WorkspaceSettingsOperations.get": null, + "azure.mgmt.security.operations.WorkspaceSettingsOperations.create": null, + "azure.mgmt.security.aio.operations.WorkspaceSettingsOperations.create": null, + "azure.mgmt.security.operations.WorkspaceSettingsOperations.update": null, + "azure.mgmt.security.aio.operations.WorkspaceSettingsOperations.update": null, + "azure.mgmt.security.operations.WorkspaceSettingsOperations.delete": null, + "azure.mgmt.security.aio.operations.WorkspaceSettingsOperations.delete": null, + "azure.mgmt.security.operations.AlertsSuppressionRulesOperations.list": null, + "azure.mgmt.security.aio.operations.AlertsSuppressionRulesOperations.list": null, + "azure.mgmt.security.operations.AlertsSuppressionRulesOperations.get": null, + "azure.mgmt.security.aio.operations.AlertsSuppressionRulesOperations.get": null, + "azure.mgmt.security.operations.AlertsSuppressionRulesOperations.update": null, + "azure.mgmt.security.aio.operations.AlertsSuppressionRulesOperations.update": null, + "azure.mgmt.security.operations.AlertsSuppressionRulesOperations.delete": null, + "azure.mgmt.security.aio.operations.AlertsSuppressionRulesOperations.delete": null, + "azure.mgmt.security.operations.RegulatoryComplianceStandardsOperations.list": null, + "azure.mgmt.security.aio.operations.RegulatoryComplianceStandardsOperations.list": null, + "azure.mgmt.security.operations.RegulatoryComplianceStandardsOperations.get": null, + "azure.mgmt.security.aio.operations.RegulatoryComplianceStandardsOperations.get": null, + "azure.mgmt.security.operations.RegulatoryComplianceControlsOperations.list": null, + "azure.mgmt.security.aio.operations.RegulatoryComplianceControlsOperations.list": null, + "azure.mgmt.security.operations.RegulatoryComplianceControlsOperations.get": null, + "azure.mgmt.security.aio.operations.RegulatoryComplianceControlsOperations.get": null, + "azure.mgmt.security.operations.RegulatoryComplianceAssessmentsOperations.list": null, + "azure.mgmt.security.aio.operations.RegulatoryComplianceAssessmentsOperations.list": null, + "azure.mgmt.security.operations.RegulatoryComplianceAssessmentsOperations.get": null, + "azure.mgmt.security.aio.operations.RegulatoryComplianceAssessmentsOperations.get": null, + "azure.mgmt.security.operations.SubAssessmentsOperations.list_all": null, + "azure.mgmt.security.aio.operations.SubAssessmentsOperations.list_all": null, + "azure.mgmt.security.operations.SubAssessmentsOperations.list": null, + "azure.mgmt.security.aio.operations.SubAssessmentsOperations.list": null, + "azure.mgmt.security.operations.SubAssessmentsOperations.get": null, + "azure.mgmt.security.aio.operations.SubAssessmentsOperations.get": null, + "azure.mgmt.security.operations.ConnectorsOperations.list": null, + "azure.mgmt.security.aio.operations.ConnectorsOperations.list": null, + "azure.mgmt.security.operations.ConnectorsOperations.get": null, + "azure.mgmt.security.aio.operations.ConnectorsOperations.get": null, + "azure.mgmt.security.operations.ConnectorsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.ConnectorsOperations.create_or_update": null, + "azure.mgmt.security.operations.ConnectorsOperations.delete": null, + "azure.mgmt.security.aio.operations.ConnectorsOperations.delete": null, + "azure.mgmt.security.operations.SoftwareInventoriesOperations.list_by_extended_resource": null, + "azure.mgmt.security.aio.operations.SoftwareInventoriesOperations.list_by_extended_resource": null, + "azure.mgmt.security.operations.SoftwareInventoriesOperations.list_by_subscription": null, + "azure.mgmt.security.aio.operations.SoftwareInventoriesOperations.list_by_subscription": null, + "azure.mgmt.security.operations.SoftwareInventoriesOperations.get": null, + "azure.mgmt.security.aio.operations.SoftwareInventoriesOperations.get": null, + "azure.mgmt.security.operations.CustomAssessmentAutomationsOperations.get": null, + "azure.mgmt.security.aio.operations.CustomAssessmentAutomationsOperations.get": null, + "azure.mgmt.security.operations.CustomAssessmentAutomationsOperations.create": null, + "azure.mgmt.security.aio.operations.CustomAssessmentAutomationsOperations.create": null, + "azure.mgmt.security.operations.CustomAssessmentAutomationsOperations.delete": null, + "azure.mgmt.security.aio.operations.CustomAssessmentAutomationsOperations.delete": null, + "azure.mgmt.security.operations.CustomAssessmentAutomationsOperations.list_by_resource_group": null, + "azure.mgmt.security.aio.operations.CustomAssessmentAutomationsOperations.list_by_resource_group": null, + "azure.mgmt.security.operations.CustomAssessmentAutomationsOperations.list_by_subscription": null, + "azure.mgmt.security.aio.operations.CustomAssessmentAutomationsOperations.list_by_subscription": null, + "azure.mgmt.security.operations.CustomEntityStoreAssignmentsOperations.get": null, + "azure.mgmt.security.aio.operations.CustomEntityStoreAssignmentsOperations.get": null, + "azure.mgmt.security.operations.CustomEntityStoreAssignmentsOperations.create": null, + "azure.mgmt.security.aio.operations.CustomEntityStoreAssignmentsOperations.create": null, + "azure.mgmt.security.operations.CustomEntityStoreAssignmentsOperations.delete": null, + "azure.mgmt.security.aio.operations.CustomEntityStoreAssignmentsOperations.delete": null, + "azure.mgmt.security.operations.CustomEntityStoreAssignmentsOperations.list_by_resource_group": null, + "azure.mgmt.security.aio.operations.CustomEntityStoreAssignmentsOperations.list_by_resource_group": null, + "azure.mgmt.security.operations.CustomEntityStoreAssignmentsOperations.list_by_subscription": null, + "azure.mgmt.security.aio.operations.CustomEntityStoreAssignmentsOperations.list_by_subscription": null, + "azure.mgmt.security.operations.MdeOnboardingsOperations.list": null, + "azure.mgmt.security.aio.operations.MdeOnboardingsOperations.list": null, + "azure.mgmt.security.operations.MdeOnboardingsOperations.get": null, + "azure.mgmt.security.aio.operations.MdeOnboardingsOperations.get": null, + "azure.mgmt.security.operations.GovernanceAssignmentsOperations.list": null, + "azure.mgmt.security.aio.operations.GovernanceAssignmentsOperations.list": null, + "azure.mgmt.security.operations.GovernanceAssignmentsOperations.get": null, + "azure.mgmt.security.aio.operations.GovernanceAssignmentsOperations.get": null, + "azure.mgmt.security.operations.GovernanceAssignmentsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.GovernanceAssignmentsOperations.create_or_update": null, + "azure.mgmt.security.operations.GovernanceAssignmentsOperations.delete": null, + "azure.mgmt.security.aio.operations.GovernanceAssignmentsOperations.delete": null, + "azure.mgmt.security.operations.GovernanceRulesOperations.list": null, + "azure.mgmt.security.aio.operations.GovernanceRulesOperations.list": null, + "azure.mgmt.security.operations.GovernanceRulesOperations.get": null, + "azure.mgmt.security.aio.operations.GovernanceRulesOperations.get": null, + "azure.mgmt.security.operations.GovernanceRulesOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.GovernanceRulesOperations.create_or_update": null, + "azure.mgmt.security.operations.GovernanceRulesOperations.begin_delete": null, + "azure.mgmt.security.aio.operations.GovernanceRulesOperations.begin_delete": null, + "azure.mgmt.security.operations.GovernanceRulesOperations.begin_execute": null, + "azure.mgmt.security.aio.operations.GovernanceRulesOperations.begin_execute": null, + "azure.mgmt.security.operations.GovernanceRulesOperations.operation_results": null, + "azure.mgmt.security.aio.operations.GovernanceRulesOperations.operation_results": null, + "azure.mgmt.security.operations.ApplicationsOperations.list": null, + "azure.mgmt.security.aio.operations.ApplicationsOperations.list": null, + "azure.mgmt.security.operations.ApplicationOperations.get": null, + "azure.mgmt.security.aio.operations.ApplicationOperations.get": null, + "azure.mgmt.security.operations.ApplicationOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.ApplicationOperations.create_or_update": null, + "azure.mgmt.security.operations.ApplicationOperations.delete": null, + "azure.mgmt.security.aio.operations.ApplicationOperations.delete": null, + "azure.mgmt.security.operations.SecurityConnectorApplicationsOperations.list": null, + "azure.mgmt.security.aio.operations.SecurityConnectorApplicationsOperations.list": null, + "azure.mgmt.security.operations.SecurityConnectorApplicationOperations.get": null, + "azure.mgmt.security.aio.operations.SecurityConnectorApplicationOperations.get": null, + "azure.mgmt.security.operations.SecurityConnectorApplicationOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.SecurityConnectorApplicationOperations.create_or_update": null, + "azure.mgmt.security.operations.SecurityConnectorApplicationOperations.delete": null, + "azure.mgmt.security.aio.operations.SecurityConnectorApplicationOperations.delete": null, + "azure.mgmt.security.operations.SecurityOperatorsOperations.list": null, + "azure.mgmt.security.aio.operations.SecurityOperatorsOperations.list": null, + "azure.mgmt.security.operations.SecurityOperatorsOperations.get": null, + "azure.mgmt.security.aio.operations.SecurityOperatorsOperations.get": null, + "azure.mgmt.security.operations.SecurityOperatorsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.SecurityOperatorsOperations.create_or_update": null, + "azure.mgmt.security.operations.SecurityOperatorsOperations.delete": null, + "azure.mgmt.security.aio.operations.SecurityOperatorsOperations.delete": null, + "azure.mgmt.security.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.create_or_update": null, + "azure.mgmt.security.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.get": null, + "azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.get": null, + "azure.mgmt.security.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.delete": null, + "azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.delete": null, + "azure.mgmt.security.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.list": null, + "azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.list": null, + "azure.mgmt.security.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.add": null, + "azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations.add": null, + "azure.mgmt.security.operations.SqlVulnerabilityAssessmentScansOperations.get": null, + "azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentScansOperations.get": null, + "azure.mgmt.security.operations.SqlVulnerabilityAssessmentScansOperations.list": null, + "azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentScansOperations.list": null, + "azure.mgmt.security.operations.SqlVulnerabilityAssessmentScanResultsOperations.get": null, + "azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentScanResultsOperations.get": null, + "azure.mgmt.security.operations.SqlVulnerabilityAssessmentScanResultsOperations.list": null, + "azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentScanResultsOperations.list": null, + "azure.mgmt.security.operations.SensitivitySettingsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.SensitivitySettingsOperations.create_or_update": null, + "azure.mgmt.security.operations.SensitivitySettingsOperations.get": null, + "azure.mgmt.security.aio.operations.SensitivitySettingsOperations.get": null, + "azure.mgmt.security.operations.SensitivitySettingsOperations.list": null, + "azure.mgmt.security.aio.operations.SensitivitySettingsOperations.list": null, + "azure.mgmt.security.operations.HealthReportsOperations.list": null, + "azure.mgmt.security.aio.operations.HealthReportsOperations.list": null, + "azure.mgmt.security.operations.HealthReportsOperations.get": null, + "azure.mgmt.security.aio.operations.HealthReportsOperations.get": null, + "azure.mgmt.security.operations.AutomationsOperations.list": null, + "azure.mgmt.security.aio.operations.AutomationsOperations.list": null, + "azure.mgmt.security.operations.AutomationsOperations.list_by_resource_group": null, + "azure.mgmt.security.aio.operations.AutomationsOperations.list_by_resource_group": null, + "azure.mgmt.security.operations.AutomationsOperations.get": null, + "azure.mgmt.security.aio.operations.AutomationsOperations.get": null, + "azure.mgmt.security.operations.AutomationsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.AutomationsOperations.create_or_update": null, + "azure.mgmt.security.operations.AutomationsOperations.update": null, + "azure.mgmt.security.aio.operations.AutomationsOperations.update": null, + "azure.mgmt.security.operations.AutomationsOperations.delete": null, + "azure.mgmt.security.aio.operations.AutomationsOperations.delete": null, + "azure.mgmt.security.operations.AutomationsOperations.validate": null, + "azure.mgmt.security.aio.operations.AutomationsOperations.validate": null, + "azure.mgmt.security.operations.SecurityContactsOperations.list": null, + "azure.mgmt.security.aio.operations.SecurityContactsOperations.list": null, + "azure.mgmt.security.operations.SecurityContactsOperations.get": null, + "azure.mgmt.security.aio.operations.SecurityContactsOperations.get": null, + "azure.mgmt.security.operations.SecurityContactsOperations.create": null, + "azure.mgmt.security.aio.operations.SecurityContactsOperations.create": null, + "azure.mgmt.security.operations.SecurityContactsOperations.delete": null, + "azure.mgmt.security.aio.operations.SecurityContactsOperations.delete": null, + "azure.mgmt.security.operations.SecurityConnectorsOperations.list": null, + "azure.mgmt.security.aio.operations.SecurityConnectorsOperations.list": null, + "azure.mgmt.security.operations.SecurityConnectorsOperations.list_by_resource_group": null, + "azure.mgmt.security.aio.operations.SecurityConnectorsOperations.list_by_resource_group": null, + "azure.mgmt.security.operations.SecurityConnectorsOperations.get": null, + "azure.mgmt.security.aio.operations.SecurityConnectorsOperations.get": null, + "azure.mgmt.security.operations.SecurityConnectorsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.SecurityConnectorsOperations.create_or_update": null, + "azure.mgmt.security.operations.SecurityConnectorsOperations.update": null, + "azure.mgmt.security.aio.operations.SecurityConnectorsOperations.update": null, + "azure.mgmt.security.operations.SecurityConnectorsOperations.delete": null, + "azure.mgmt.security.aio.operations.SecurityConnectorsOperations.delete": null, + "azure.mgmt.security.operations.DefenderForStorageOperations.get": null, + "azure.mgmt.security.aio.operations.DefenderForStorageOperations.get": null, + "azure.mgmt.security.operations.DefenderForStorageOperations.create": null, + "azure.mgmt.security.aio.operations.DefenderForStorageOperations.create": null, + "azure.mgmt.security.operations.DefenderForStorageOperations.start_malware_scan": null, + "azure.mgmt.security.aio.operations.DefenderForStorageOperations.start_malware_scan": null, + "azure.mgmt.security.operations.DefenderForStorageOperations.cancel_malware_scan": null, + "azure.mgmt.security.aio.operations.DefenderForStorageOperations.cancel_malware_scan": null, + "azure.mgmt.security.operations.DefenderForStorageOperations.get_malware_scan": null, + "azure.mgmt.security.aio.operations.DefenderForStorageOperations.get_malware_scan": null, + "azure.mgmt.security.operations.Operations.list": null, + "azure.mgmt.security.aio.operations.Operations.list": null, + "azure.mgmt.security.operations.AssessmentsMetadataOperations.list": null, + "azure.mgmt.security.aio.operations.AssessmentsMetadataOperations.list": null, + "azure.mgmt.security.operations.AssessmentsMetadataOperations.get": null, + "azure.mgmt.security.aio.operations.AssessmentsMetadataOperations.get": null, + "azure.mgmt.security.operations.AssessmentsMetadataOperations.list_by_subscription": null, + "azure.mgmt.security.aio.operations.AssessmentsMetadataOperations.list_by_subscription": null, + "azure.mgmt.security.operations.AssessmentsMetadataOperations.get_in_subscription": null, + "azure.mgmt.security.aio.operations.AssessmentsMetadataOperations.get_in_subscription": null, + "azure.mgmt.security.operations.AssessmentsMetadataOperations.create_in_subscription": null, + "azure.mgmt.security.aio.operations.AssessmentsMetadataOperations.create_in_subscription": null, + "azure.mgmt.security.operations.AssessmentsMetadataOperations.delete_in_subscription": null, + "azure.mgmt.security.aio.operations.AssessmentsMetadataOperations.delete_in_subscription": null, + "azure.mgmt.security.operations.AssessmentsOperations.list": null, + "azure.mgmt.security.aio.operations.AssessmentsOperations.list": null, + "azure.mgmt.security.operations.AssessmentsOperations.get": null, + "azure.mgmt.security.aio.operations.AssessmentsOperations.get": null, + "azure.mgmt.security.operations.AssessmentsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.AssessmentsOperations.create_or_update": null, + "azure.mgmt.security.operations.AssessmentsOperations.delete": null, + "azure.mgmt.security.aio.operations.AssessmentsOperations.delete": null, + "azure.mgmt.security.operations.PrivateLinksOperations.list_by_subscription": null, + "azure.mgmt.security.aio.operations.PrivateLinksOperations.list_by_subscription": null, + "azure.mgmt.security.operations.PrivateLinksOperations.list": null, + "azure.mgmt.security.aio.operations.PrivateLinksOperations.list": null, + "azure.mgmt.security.operations.PrivateLinksOperations.get": null, + "azure.mgmt.security.aio.operations.PrivateLinksOperations.get": null, + "azure.mgmt.security.operations.PrivateLinksOperations.head": null, + "azure.mgmt.security.aio.operations.PrivateLinksOperations.head": null, + "azure.mgmt.security.operations.PrivateLinksOperations.begin_create": null, + "azure.mgmt.security.aio.operations.PrivateLinksOperations.begin_create": null, + "azure.mgmt.security.operations.PrivateLinksOperations.update": null, + "azure.mgmt.security.aio.operations.PrivateLinksOperations.update": null, + "azure.mgmt.security.operations.PrivateLinksOperations.begin_delete": null, + "azure.mgmt.security.aio.operations.PrivateLinksOperations.begin_delete": null, + "azure.mgmt.security.operations.PrivateLinkResourcesOperations.list": null, + "azure.mgmt.security.aio.operations.PrivateLinkResourcesOperations.list": null, + "azure.mgmt.security.operations.PrivateLinkResourcesOperations.get": null, + "azure.mgmt.security.aio.operations.PrivateLinkResourcesOperations.get": null, + "azure.mgmt.security.operations.PrivateEndpointConnectionsOperations.list": null, + "azure.mgmt.security.aio.operations.PrivateEndpointConnectionsOperations.list": null, + "azure.mgmt.security.operations.PrivateEndpointConnectionsOperations.get": null, + "azure.mgmt.security.aio.operations.PrivateEndpointConnectionsOperations.get": null, + "azure.mgmt.security.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, + "azure.mgmt.security.aio.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, + "azure.mgmt.security.operations.PrivateEndpointConnectionsOperations.begin_delete": null, + "azure.mgmt.security.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": null, + "azure.mgmt.security.operations.ComplianceResultsOperations.list": null, + "azure.mgmt.security.aio.operations.ComplianceResultsOperations.list": null, + "azure.mgmt.security.operations.ComplianceResultsOperations.get": null, + "azure.mgmt.security.aio.operations.ComplianceResultsOperations.get": null, + "azure.mgmt.security.operations.AdvancedThreatProtectionOperations.get": null, + "azure.mgmt.security.aio.operations.AdvancedThreatProtectionOperations.get": null, + "azure.mgmt.security.operations.AdvancedThreatProtectionOperations.create": null, + "azure.mgmt.security.aio.operations.AdvancedThreatProtectionOperations.create": null, + "azure.mgmt.security.operations.DeviceSecurityGroupsOperations.list": null, + "azure.mgmt.security.aio.operations.DeviceSecurityGroupsOperations.list": null, + "azure.mgmt.security.operations.DeviceSecurityGroupsOperations.get": null, + "azure.mgmt.security.aio.operations.DeviceSecurityGroupsOperations.get": null, + "azure.mgmt.security.operations.DeviceSecurityGroupsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.DeviceSecurityGroupsOperations.create_or_update": null, + "azure.mgmt.security.operations.DeviceSecurityGroupsOperations.delete": null, + "azure.mgmt.security.aio.operations.DeviceSecurityGroupsOperations.delete": null, + "azure.mgmt.security.operations.IotSecuritySolutionAnalyticsOperations.list": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionAnalyticsOperations.list": null, + "azure.mgmt.security.operations.IotSecuritySolutionAnalyticsOperations.get": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionAnalyticsOperations.get": null, + "azure.mgmt.security.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations.list": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations.list": null, + "azure.mgmt.security.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations.get": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations.get": null, + "azure.mgmt.security.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations.dismiss": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations.dismiss": null, + "azure.mgmt.security.operations.IotSecuritySolutionsAnalyticsRecommendationOperations.get": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionsAnalyticsRecommendationOperations.get": null, + "azure.mgmt.security.operations.IotSecuritySolutionsAnalyticsRecommendationOperations.list": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionsAnalyticsRecommendationOperations.list": null, + "azure.mgmt.security.operations.IotSecuritySolutionOperations.list_by_subscription": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionOperations.list_by_subscription": null, + "azure.mgmt.security.operations.IotSecuritySolutionOperations.list_by_resource_group": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionOperations.list_by_resource_group": null, + "azure.mgmt.security.operations.IotSecuritySolutionOperations.get": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionOperations.get": null, + "azure.mgmt.security.operations.IotSecuritySolutionOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionOperations.create_or_update": null, + "azure.mgmt.security.operations.IotSecuritySolutionOperations.update": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionOperations.update": null, + "azure.mgmt.security.operations.IotSecuritySolutionOperations.delete": null, + "azure.mgmt.security.aio.operations.IotSecuritySolutionOperations.delete": null, + "azure.mgmt.security.operations.AllowedConnectionsOperations.list": null, + "azure.mgmt.security.aio.operations.AllowedConnectionsOperations.list": null, + "azure.mgmt.security.operations.AllowedConnectionsOperations.list_by_home_region": null, + "azure.mgmt.security.aio.operations.AllowedConnectionsOperations.list_by_home_region": null, + "azure.mgmt.security.operations.AllowedConnectionsOperations.get": null, + "azure.mgmt.security.aio.operations.AllowedConnectionsOperations.get": null, + "azure.mgmt.security.operations.DiscoveredSecuritySolutionsOperations.list": null, + "azure.mgmt.security.aio.operations.DiscoveredSecuritySolutionsOperations.list": null, + "azure.mgmt.security.operations.DiscoveredSecuritySolutionsOperations.list_by_home_region": null, + "azure.mgmt.security.aio.operations.DiscoveredSecuritySolutionsOperations.list_by_home_region": null, + "azure.mgmt.security.operations.DiscoveredSecuritySolutionsOperations.get": null, + "azure.mgmt.security.aio.operations.DiscoveredSecuritySolutionsOperations.get": null, + "azure.mgmt.security.operations.ExternalSecuritySolutionsOperations.list": null, + "azure.mgmt.security.aio.operations.ExternalSecuritySolutionsOperations.list": null, + "azure.mgmt.security.operations.ExternalSecuritySolutionsOperations.list_by_home_region": null, + "azure.mgmt.security.aio.operations.ExternalSecuritySolutionsOperations.list_by_home_region": null, + "azure.mgmt.security.operations.ExternalSecuritySolutionsOperations.get": null, + "azure.mgmt.security.aio.operations.ExternalSecuritySolutionsOperations.get": null, + "azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations.list": null, + "azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations.list": null, + "azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations.list_by_region": null, + "azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations.list_by_region": null, + "azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations.list_by_resource_group": null, + "azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations.list_by_resource_group": null, + "azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations.list_by_resource_group_and_region": null, + "azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations.list_by_resource_group_and_region": null, + "azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations.get": null, + "azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations.get": null, + "azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations.create_or_update": null, + "azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations.delete": null, + "azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations.delete": null, + "azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations.initiate": null, + "azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations.initiate": null, + "azure.mgmt.security.operations.SecureScoresOperations.list": null, + "azure.mgmt.security.aio.operations.SecureScoresOperations.list": null, + "azure.mgmt.security.operations.SecureScoresOperations.get": null, + "azure.mgmt.security.aio.operations.SecureScoresOperations.get": null, + "azure.mgmt.security.operations.SecureScoreControlsOperations.list_by_secure_score": null, + "azure.mgmt.security.aio.operations.SecureScoreControlsOperations.list_by_secure_score": null, + "azure.mgmt.security.operations.SecureScoreControlsOperations.list": null, + "azure.mgmt.security.aio.operations.SecureScoreControlsOperations.list": null, + "azure.mgmt.security.operations.SecureScoreControlDefinitionsOperations.list": null, + "azure.mgmt.security.aio.operations.SecureScoreControlDefinitionsOperations.list": null, + "azure.mgmt.security.operations.SecureScoreControlDefinitionsOperations.list_by_subscription": null, + "azure.mgmt.security.aio.operations.SecureScoreControlDefinitionsOperations.list_by_subscription": null, + "azure.mgmt.security.operations.SecuritySolutionsOperations.list": null, + "azure.mgmt.security.aio.operations.SecuritySolutionsOperations.list": null, + "azure.mgmt.security.operations.SecuritySolutionsOperations.get": null, + "azure.mgmt.security.aio.operations.SecuritySolutionsOperations.get": null, + "azure.mgmt.security.operations.SecuritySolutionsReferenceDataOperations.list": null, + "azure.mgmt.security.aio.operations.SecuritySolutionsReferenceDataOperations.list": null, + "azure.mgmt.security.operations.SecuritySolutionsReferenceDataOperations.list_by_home_region": null, + "azure.mgmt.security.aio.operations.SecuritySolutionsReferenceDataOperations.list_by_home_region": null, + "azure.mgmt.security.operations.ServerVulnerabilityAssessmentOperations.list_by_extended_resource": null, + "azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentOperations.list_by_extended_resource": null, + "azure.mgmt.security.operations.ServerVulnerabilityAssessmentOperations.get": null, + "azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentOperations.get": null, + "azure.mgmt.security.operations.ServerVulnerabilityAssessmentOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentOperations.create_or_update": null, + "azure.mgmt.security.operations.ServerVulnerabilityAssessmentOperations.begin_delete": null, + "azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentOperations.begin_delete": null, + "azure.mgmt.security.operations.TopologyOperations.list": null, + "azure.mgmt.security.aio.operations.TopologyOperations.list": null, + "azure.mgmt.security.operations.TopologyOperations.list_by_home_region": null, + "azure.mgmt.security.aio.operations.TopologyOperations.list_by_home_region": null, + "azure.mgmt.security.operations.TopologyOperations.get": null, + "azure.mgmt.security.aio.operations.TopologyOperations.get": null, + "azure.mgmt.security.operations.AlertsOperations.list": null, + "azure.mgmt.security.aio.operations.AlertsOperations.list": null, + "azure.mgmt.security.operations.AlertsOperations.list_by_resource_group": null, + "azure.mgmt.security.aio.operations.AlertsOperations.list_by_resource_group": null, + "azure.mgmt.security.operations.AlertsOperations.list_subscription_level_by_region": null, + "azure.mgmt.security.aio.operations.AlertsOperations.list_subscription_level_by_region": null, + "azure.mgmt.security.operations.AlertsOperations.list_resource_group_level_by_region": null, + "azure.mgmt.security.aio.operations.AlertsOperations.list_resource_group_level_by_region": null, + "azure.mgmt.security.operations.AlertsOperations.get_subscription_level": null, + "azure.mgmt.security.aio.operations.AlertsOperations.get_subscription_level": null, + "azure.mgmt.security.operations.AlertsOperations.get_resource_group_level": null, + "azure.mgmt.security.aio.operations.AlertsOperations.get_resource_group_level": null, + "azure.mgmt.security.operations.AlertsOperations.update_subscription_level_state_to_dismiss": null, + "azure.mgmt.security.aio.operations.AlertsOperations.update_subscription_level_state_to_dismiss": null, + "azure.mgmt.security.operations.AlertsOperations.update_subscription_level_state_to_resolve": null, + "azure.mgmt.security.aio.operations.AlertsOperations.update_subscription_level_state_to_resolve": null, + "azure.mgmt.security.operations.AlertsOperations.update_subscription_level_state_to_activate": null, + "azure.mgmt.security.aio.operations.AlertsOperations.update_subscription_level_state_to_activate": null, + "azure.mgmt.security.operations.AlertsOperations.update_subscription_level_state_to_in_progress": null, + "azure.mgmt.security.aio.operations.AlertsOperations.update_subscription_level_state_to_in_progress": null, + "azure.mgmt.security.operations.AlertsOperations.update_resource_group_level_state_to_resolve": null, + "azure.mgmt.security.aio.operations.AlertsOperations.update_resource_group_level_state_to_resolve": null, + "azure.mgmt.security.operations.AlertsOperations.update_resource_group_level_state_to_dismiss": null, + "azure.mgmt.security.aio.operations.AlertsOperations.update_resource_group_level_state_to_dismiss": null, + "azure.mgmt.security.operations.AlertsOperations.update_resource_group_level_state_to_activate": null, + "azure.mgmt.security.aio.operations.AlertsOperations.update_resource_group_level_state_to_activate": null, + "azure.mgmt.security.operations.AlertsOperations.update_resource_group_level_state_to_in_progress": null, + "azure.mgmt.security.aio.operations.AlertsOperations.update_resource_group_level_state_to_in_progress": null, + "azure.mgmt.security.operations.AlertsOperations.begin_simulate": null, + "azure.mgmt.security.aio.operations.AlertsOperations.begin_simulate": null, + "azure.mgmt.security.operations.SettingsOperations.list": null, + "azure.mgmt.security.aio.operations.SettingsOperations.list": null, + "azure.mgmt.security.operations.SettingsOperations.get": null, + "azure.mgmt.security.aio.operations.SettingsOperations.get": null, + "azure.mgmt.security.operations.SettingsOperations.update": null, + "azure.mgmt.security.aio.operations.SettingsOperations.update": null, + "azure.mgmt.security.operations.ServerVulnerabilityAssessmentsSettingsOperations.list_by_subscription": null, + "azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentsSettingsOperations.list_by_subscription": null, + "azure.mgmt.security.operations.ServerVulnerabilityAssessmentsSettingsOperations.get": null, + "azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentsSettingsOperations.get": null, + "azure.mgmt.security.operations.ServerVulnerabilityAssessmentsSettingsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentsSettingsOperations.create_or_update": null, + "azure.mgmt.security.operations.ServerVulnerabilityAssessmentsSettingsOperations.delete": null, + "azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentsSettingsOperations.delete": null, + "azure.mgmt.security.operations.APICollectionsOperations.list_by_subscription": null, + "azure.mgmt.security.aio.operations.APICollectionsOperations.list_by_subscription": null, + "azure.mgmt.security.operations.APICollectionsOperations.list_by_resource_group": null, + "azure.mgmt.security.aio.operations.APICollectionsOperations.list_by_resource_group": null, + "azure.mgmt.security.operations.APICollectionsOperations.list_by_azure_api_management_service": null, + "azure.mgmt.security.aio.operations.APICollectionsOperations.list_by_azure_api_management_service": null, + "azure.mgmt.security.operations.APICollectionsOperations.get_by_azure_api_management_service": null, + "azure.mgmt.security.aio.operations.APICollectionsOperations.get_by_azure_api_management_service": null, + "azure.mgmt.security.operations.APICollectionsOperations.begin_onboard_azure_api_management_api": null, + "azure.mgmt.security.aio.operations.APICollectionsOperations.begin_onboard_azure_api_management_api": null, + "azure.mgmt.security.operations.APICollectionsOperations.offboard_azure_api_management_api": null, + "azure.mgmt.security.aio.operations.APICollectionsOperations.offboard_azure_api_management_api": null, + "azure.mgmt.security.operations.PricingsOperations.get": null, + "azure.mgmt.security.aio.operations.PricingsOperations.get": null, + "azure.mgmt.security.operations.PricingsOperations.update": null, + "azure.mgmt.security.aio.operations.PricingsOperations.update": null, + "azure.mgmt.security.operations.PricingsOperations.delete": null, + "azure.mgmt.security.aio.operations.PricingsOperations.delete": null, + "azure.mgmt.security.operations.PricingsOperations.list": null, + "azure.mgmt.security.aio.operations.PricingsOperations.list": null, + "azure.mgmt.security.operations.SecurityStandardsOperations.list": null, + "azure.mgmt.security.aio.operations.SecurityStandardsOperations.list": null, + "azure.mgmt.security.operations.SecurityStandardsOperations.get": null, + "azure.mgmt.security.aio.operations.SecurityStandardsOperations.get": null, + "azure.mgmt.security.operations.SecurityStandardsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.SecurityStandardsOperations.create_or_update": null, + "azure.mgmt.security.operations.SecurityStandardsOperations.delete": null, + "azure.mgmt.security.aio.operations.SecurityStandardsOperations.delete": null, + "azure.mgmt.security.operations.StandardAssignmentsOperations.get": null, + "azure.mgmt.security.aio.operations.StandardAssignmentsOperations.get": null, + "azure.mgmt.security.operations.StandardAssignmentsOperations.create": null, + "azure.mgmt.security.aio.operations.StandardAssignmentsOperations.create": null, + "azure.mgmt.security.operations.StandardAssignmentsOperations.delete": null, + "azure.mgmt.security.aio.operations.StandardAssignmentsOperations.delete": null, + "azure.mgmt.security.operations.StandardAssignmentsOperations.list": null, + "azure.mgmt.security.aio.operations.StandardAssignmentsOperations.list": null, + "azure.mgmt.security.operations.CustomRecommendationsOperations.list": null, + "azure.mgmt.security.aio.operations.CustomRecommendationsOperations.list": null, + "azure.mgmt.security.operations.CustomRecommendationsOperations.get": null, + "azure.mgmt.security.aio.operations.CustomRecommendationsOperations.get": null, + "azure.mgmt.security.operations.CustomRecommendationsOperations.create_or_update": null, + "azure.mgmt.security.aio.operations.CustomRecommendationsOperations.create_or_update": null, + "azure.mgmt.security.operations.CustomRecommendationsOperations.delete": null, + "azure.mgmt.security.aio.operations.CustomRecommendationsOperations.delete": null, + "azure.mgmt.security.operations.AzureDevOpsOrgsOperations.list_available": null, + "azure.mgmt.security.aio.operations.AzureDevOpsOrgsOperations.list_available": null, + "azure.mgmt.security.operations.AzureDevOpsOrgsOperations.list": null, + "azure.mgmt.security.aio.operations.AzureDevOpsOrgsOperations.list": null, + "azure.mgmt.security.operations.AzureDevOpsOrgsOperations.get": null, + "azure.mgmt.security.aio.operations.AzureDevOpsOrgsOperations.get": null, + "azure.mgmt.security.operations.AzureDevOpsOrgsOperations.begin_create_or_update": null, + "azure.mgmt.security.aio.operations.AzureDevOpsOrgsOperations.begin_create_or_update": null, + "azure.mgmt.security.operations.AzureDevOpsOrgsOperations.begin_update": null, + "azure.mgmt.security.aio.operations.AzureDevOpsOrgsOperations.begin_update": null, + "azure.mgmt.security.operations.AzureDevOpsProjectsOperations.list": null, + "azure.mgmt.security.aio.operations.AzureDevOpsProjectsOperations.list": null, + "azure.mgmt.security.operations.AzureDevOpsProjectsOperations.get": null, + "azure.mgmt.security.aio.operations.AzureDevOpsProjectsOperations.get": null, + "azure.mgmt.security.operations.AzureDevOpsProjectsOperations.begin_create_or_update": null, + "azure.mgmt.security.aio.operations.AzureDevOpsProjectsOperations.begin_create_or_update": null, + "azure.mgmt.security.operations.AzureDevOpsProjectsOperations.begin_update": null, + "azure.mgmt.security.aio.operations.AzureDevOpsProjectsOperations.begin_update": null, + "azure.mgmt.security.operations.AzureDevOpsReposOperations.list": null, + "azure.mgmt.security.aio.operations.AzureDevOpsReposOperations.list": null, + "azure.mgmt.security.operations.AzureDevOpsReposOperations.get": null, + "azure.mgmt.security.aio.operations.AzureDevOpsReposOperations.get": null, + "azure.mgmt.security.operations.AzureDevOpsReposOperations.begin_create_or_update": null, + "azure.mgmt.security.aio.operations.AzureDevOpsReposOperations.begin_create_or_update": null, + "azure.mgmt.security.operations.AzureDevOpsReposOperations.begin_update": null, + "azure.mgmt.security.aio.operations.AzureDevOpsReposOperations.begin_update": null, + "azure.mgmt.security.operations.DevOpsConfigurationsOperations.list": null, + "azure.mgmt.security.aio.operations.DevOpsConfigurationsOperations.list": null, + "azure.mgmt.security.operations.DevOpsConfigurationsOperations.get": null, + "azure.mgmt.security.aio.operations.DevOpsConfigurationsOperations.get": null, + "azure.mgmt.security.operations.DevOpsConfigurationsOperations.begin_create_or_update": null, + "azure.mgmt.security.aio.operations.DevOpsConfigurationsOperations.begin_create_or_update": null, + "azure.mgmt.security.operations.DevOpsConfigurationsOperations.begin_update": null, + "azure.mgmt.security.aio.operations.DevOpsConfigurationsOperations.begin_update": null, + "azure.mgmt.security.operations.DevOpsConfigurationsOperations.begin_delete": null, + "azure.mgmt.security.aio.operations.DevOpsConfigurationsOperations.begin_delete": null, + "azure.mgmt.security.operations.GitHubOwnersOperations.list_available": null, + "azure.mgmt.security.aio.operations.GitHubOwnersOperations.list_available": null, + "azure.mgmt.security.operations.GitHubOwnersOperations.list": null, + "azure.mgmt.security.aio.operations.GitHubOwnersOperations.list": null, + "azure.mgmt.security.operations.GitHubOwnersOperations.get": null, + "azure.mgmt.security.aio.operations.GitHubOwnersOperations.get": null, + "azure.mgmt.security.operations.GitHubReposOperations.list": null, + "azure.mgmt.security.aio.operations.GitHubReposOperations.list": null, + "azure.mgmt.security.operations.GitHubReposOperations.get": null, + "azure.mgmt.security.aio.operations.GitHubReposOperations.get": null, + "azure.mgmt.security.operations.GitLabGroupsOperations.list_available": null, + "azure.mgmt.security.aio.operations.GitLabGroupsOperations.list_available": null, + "azure.mgmt.security.operations.GitLabGroupsOperations.list": null, + "azure.mgmt.security.aio.operations.GitLabGroupsOperations.list": null, + "azure.mgmt.security.operations.GitLabGroupsOperations.get": null, + "azure.mgmt.security.aio.operations.GitLabGroupsOperations.get": null, + "azure.mgmt.security.operations.GitLabSubgroupsOperations.list": null, + "azure.mgmt.security.aio.operations.GitLabSubgroupsOperations.list": null, + "azure.mgmt.security.operations.GitLabProjectsOperations.list": null, + "azure.mgmt.security.aio.operations.GitLabProjectsOperations.list": null, + "azure.mgmt.security.operations.GitLabProjectsOperations.get": null, + "azure.mgmt.security.aio.operations.GitLabProjectsOperations.get": null, + "azure.mgmt.security.operations.DevOpsOperationResultsOperations.get": null, + "azure.mgmt.security.aio.operations.DevOpsOperationResultsOperations.get": null + } +} \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/__init__.py index aaec1eb751b8..dc0afd3f67f6 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/__init__.py @@ -5,16 +5,28 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._security_center import SecurityCenter -__all__ = ['SecurityCenter'] +from typing import TYPE_CHECKING -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import +from ._security_center import SecurityCenter # type: ignore from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_configuration.py index e8564a3e71a7..a34ecf537a42 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_configuration.py @@ -1,13 +1,11 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,10 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SecurityCenterConfiguration: + +class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for SecurityCenter. Note that all parameters used to create this instance are saved as instance @@ -27,16 +25,11 @@ class SecurityCenterConfiguration: :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: Azure subscription ID. Required. :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ): + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -44,23 +37,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-security/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ): - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_patch.py @@ -0,0 +1,21 @@ +# 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 + + +def patch_sdk(): + """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/security/azure-mgmt-security/azure/mgmt/security/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_security_center.py index b02dcbe37e5e..94d2ca8ccc85 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_security_center.py @@ -1,145 +1,310 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING, cast +from typing_extensions import Self from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.tools import get_arm_endpoints +from . import models as _models from ._configuration import SecurityCenterConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer +from .operations import ( + APICollectionsOperations, + AdvancedThreatProtectionOperations, + AlertsOperations, + AlertsSuppressionRulesOperations, + AllowedConnectionsOperations, + ApplicationOperations, + ApplicationsOperations, + AssessmentsMetadataOperations, + AssessmentsOperations, + AutoProvisioningSettingsOperations, + AutomationsOperations, + AzureDevOpsOrgsOperations, + AzureDevOpsProjectsOperations, + AzureDevOpsReposOperations, + ComplianceResultsOperations, + CompliancesOperations, + ConnectorsOperations, + CustomAssessmentAutomationsOperations, + CustomEntityStoreAssignmentsOperations, + CustomRecommendationsOperations, + DefenderForStorageOperations, + DevOpsConfigurationsOperations, + DevOpsOperationResultsOperations, + DeviceSecurityGroupsOperations, + DiscoveredSecuritySolutionsOperations, + ExternalSecuritySolutionsOperations, + GitHubOwnersOperations, + GitHubReposOperations, + GitLabGroupsOperations, + GitLabProjectsOperations, + GitLabSubgroupsOperations, + GovernanceAssignmentsOperations, + GovernanceRulesOperations, + HealthReportsOperations, + InformationProtectionPoliciesOperations, + IotSecuritySolutionAnalyticsOperations, + IotSecuritySolutionOperations, + IotSecuritySolutionsAnalyticsAggregatedAlertOperations, + IotSecuritySolutionsAnalyticsRecommendationOperations, + JitNetworkAccessPoliciesOperations, + LocationsOperations, + MdeOnboardingsOperations, + Operations, + PricingsOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + PrivateLinksOperations, + RegulatoryComplianceAssessmentsOperations, + RegulatoryComplianceControlsOperations, + RegulatoryComplianceStandardsOperations, + SecureScoreControlDefinitionsOperations, + SecureScoreControlsOperations, + SecureScoresOperations, + SecurityConnectorApplicationOperations, + SecurityConnectorApplicationsOperations, + SecurityConnectorsOperations, + SecurityContactsOperations, + SecurityOperatorsOperations, + SecuritySolutionsOperations, + SecuritySolutionsReferenceDataOperations, + SecurityStandardsOperations, + SensitivitySettingsOperations, + ServerVulnerabilityAssessmentOperations, + ServerVulnerabilityAssessmentsSettingsOperations, + SettingsOperations, + SoftwareInventoriesOperations, + SqlVulnerabilityAssessmentBaselineRulesOperations, + SqlVulnerabilityAssessmentScanResultsOperations, + SqlVulnerabilityAssessmentScansOperations, + StandardAssignmentsOperations, + SubAssessmentsOperations, + TasksOperations, + TopologyOperations, + WorkspaceSettingsOperations, +) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class SecurityCenter(MultiApiClientMixin, _SDKClient): +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """API spec for Microsoft.Security (Azure Security Center) resource provider. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar locations: LocationsOperations operations + :vartype locations: azure.mgmt.security.operations.LocationsOperations + :ivar tasks: TasksOperations operations + :vartype tasks: azure.mgmt.security.operations.TasksOperations + :ivar auto_provisioning_settings: AutoProvisioningSettingsOperations operations + :vartype auto_provisioning_settings: + azure.mgmt.security.operations.AutoProvisioningSettingsOperations + :ivar compliances: CompliancesOperations operations + :vartype compliances: azure.mgmt.security.operations.CompliancesOperations + :ivar information_protection_policies: InformationProtectionPoliciesOperations operations + :vartype information_protection_policies: + azure.mgmt.security.operations.InformationProtectionPoliciesOperations + :ivar workspace_settings: WorkspaceSettingsOperations operations + :vartype workspace_settings: azure.mgmt.security.operations.WorkspaceSettingsOperations + :ivar alerts_suppression_rules: AlertsSuppressionRulesOperations operations + :vartype alerts_suppression_rules: + azure.mgmt.security.operations.AlertsSuppressionRulesOperations + :ivar regulatory_compliance_standards: RegulatoryComplianceStandardsOperations operations + :vartype regulatory_compliance_standards: + azure.mgmt.security.operations.RegulatoryComplianceStandardsOperations + :ivar regulatory_compliance_controls: RegulatoryComplianceControlsOperations operations + :vartype regulatory_compliance_controls: + azure.mgmt.security.operations.RegulatoryComplianceControlsOperations + :ivar regulatory_compliance_assessments: RegulatoryComplianceAssessmentsOperations operations + :vartype regulatory_compliance_assessments: + azure.mgmt.security.operations.RegulatoryComplianceAssessmentsOperations + :ivar sub_assessments: SubAssessmentsOperations operations + :vartype sub_assessments: azure.mgmt.security.operations.SubAssessmentsOperations + :ivar connectors: ConnectorsOperations operations + :vartype connectors: azure.mgmt.security.operations.ConnectorsOperations + :ivar software_inventories: SoftwareInventoriesOperations operations + :vartype software_inventories: azure.mgmt.security.operations.SoftwareInventoriesOperations + :ivar custom_assessment_automations: CustomAssessmentAutomationsOperations operations + :vartype custom_assessment_automations: + azure.mgmt.security.operations.CustomAssessmentAutomationsOperations + :ivar custom_entity_store_assignments: CustomEntityStoreAssignmentsOperations operations + :vartype custom_entity_store_assignments: + azure.mgmt.security.operations.CustomEntityStoreAssignmentsOperations + :ivar mde_onboardings: MdeOnboardingsOperations operations + :vartype mde_onboardings: azure.mgmt.security.operations.MdeOnboardingsOperations + :ivar governance_assignments: GovernanceAssignmentsOperations operations + :vartype governance_assignments: azure.mgmt.security.operations.GovernanceAssignmentsOperations + :ivar governance_rules: GovernanceRulesOperations operations + :vartype governance_rules: azure.mgmt.security.operations.GovernanceRulesOperations + :ivar applications: ApplicationsOperations operations + :vartype applications: azure.mgmt.security.operations.ApplicationsOperations + :ivar application: ApplicationOperations operations + :vartype application: azure.mgmt.security.operations.ApplicationOperations + :ivar security_connector_applications: SecurityConnectorApplicationsOperations operations + :vartype security_connector_applications: + azure.mgmt.security.operations.SecurityConnectorApplicationsOperations + :ivar security_connector_application: SecurityConnectorApplicationOperations operations + :vartype security_connector_application: + azure.mgmt.security.operations.SecurityConnectorApplicationOperations + :ivar security_operators: SecurityOperatorsOperations operations + :vartype security_operators: azure.mgmt.security.operations.SecurityOperatorsOperations + :ivar sql_vulnerability_assessment_baseline_rules: + SqlVulnerabilityAssessmentBaselineRulesOperations operations + :vartype sql_vulnerability_assessment_baseline_rules: + azure.mgmt.security.operations.SqlVulnerabilityAssessmentBaselineRulesOperations + :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations + :vartype sql_vulnerability_assessment_scans: + azure.mgmt.security.operations.SqlVulnerabilityAssessmentScansOperations + :ivar sql_vulnerability_assessment_scan_results: + SqlVulnerabilityAssessmentScanResultsOperations operations + :vartype sql_vulnerability_assessment_scan_results: + azure.mgmt.security.operations.SqlVulnerabilityAssessmentScanResultsOperations + :ivar sensitivity_settings: SensitivitySettingsOperations operations + :vartype sensitivity_settings: azure.mgmt.security.operations.SensitivitySettingsOperations + :ivar health_reports: HealthReportsOperations operations + :vartype health_reports: azure.mgmt.security.operations.HealthReportsOperations + :ivar automations: AutomationsOperations operations + :vartype automations: azure.mgmt.security.operations.AutomationsOperations + :ivar security_contacts: SecurityContactsOperations operations + :vartype security_contacts: azure.mgmt.security.operations.SecurityContactsOperations + :ivar security_connectors: SecurityConnectorsOperations operations + :vartype security_connectors: azure.mgmt.security.operations.SecurityConnectorsOperations + :ivar defender_for_storage: DefenderForStorageOperations operations + :vartype defender_for_storage: azure.mgmt.security.operations.DefenderForStorageOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.security.operations.Operations + :ivar assessments_metadata: AssessmentsMetadataOperations operations + :vartype assessments_metadata: azure.mgmt.security.operations.AssessmentsMetadataOperations + :ivar assessments: AssessmentsOperations operations + :vartype assessments: azure.mgmt.security.operations.AssessmentsOperations + :ivar private_links: PrivateLinksOperations operations + :vartype private_links: azure.mgmt.security.operations.PrivateLinksOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: azure.mgmt.security.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.security.operations.PrivateEndpointConnectionsOperations + :ivar compliance_results: ComplianceResultsOperations operations + :vartype compliance_results: azure.mgmt.security.operations.ComplianceResultsOperations + :ivar advanced_threat_protection: AdvancedThreatProtectionOperations operations + :vartype advanced_threat_protection: + azure.mgmt.security.operations.AdvancedThreatProtectionOperations + :ivar device_security_groups: DeviceSecurityGroupsOperations operations + :vartype device_security_groups: azure.mgmt.security.operations.DeviceSecurityGroupsOperations + :ivar iot_security_solution_analytics: IotSecuritySolutionAnalyticsOperations operations + :vartype iot_security_solution_analytics: + azure.mgmt.security.operations.IotSecuritySolutionAnalyticsOperations + :ivar iot_security_solutions_analytics_aggregated_alert: + IotSecuritySolutionsAnalyticsAggregatedAlertOperations operations + :vartype iot_security_solutions_analytics_aggregated_alert: + azure.mgmt.security.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations + :ivar iot_security_solutions_analytics_recommendation: + IotSecuritySolutionsAnalyticsRecommendationOperations operations + :vartype iot_security_solutions_analytics_recommendation: + azure.mgmt.security.operations.IotSecuritySolutionsAnalyticsRecommendationOperations + :ivar iot_security_solution: IotSecuritySolutionOperations operations + :vartype iot_security_solution: azure.mgmt.security.operations.IotSecuritySolutionOperations + :ivar allowed_connections: AllowedConnectionsOperations operations + :vartype allowed_connections: azure.mgmt.security.operations.AllowedConnectionsOperations + :ivar discovered_security_solutions: DiscoveredSecuritySolutionsOperations operations + :vartype discovered_security_solutions: + azure.mgmt.security.operations.DiscoveredSecuritySolutionsOperations + :ivar external_security_solutions: ExternalSecuritySolutionsOperations operations + :vartype external_security_solutions: + azure.mgmt.security.operations.ExternalSecuritySolutionsOperations + :ivar jit_network_access_policies: JitNetworkAccessPoliciesOperations operations + :vartype jit_network_access_policies: + azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations + :ivar secure_scores: SecureScoresOperations operations + :vartype secure_scores: azure.mgmt.security.operations.SecureScoresOperations + :ivar secure_score_controls: SecureScoreControlsOperations operations + :vartype secure_score_controls: azure.mgmt.security.operations.SecureScoreControlsOperations + :ivar secure_score_control_definitions: SecureScoreControlDefinitionsOperations operations + :vartype secure_score_control_definitions: + azure.mgmt.security.operations.SecureScoreControlDefinitionsOperations + :ivar security_solutions: SecuritySolutionsOperations operations + :vartype security_solutions: azure.mgmt.security.operations.SecuritySolutionsOperations + :ivar security_solutions_reference_data: SecuritySolutionsReferenceDataOperations operations + :vartype security_solutions_reference_data: + azure.mgmt.security.operations.SecuritySolutionsReferenceDataOperations + :ivar server_vulnerability_assessment: ServerVulnerabilityAssessmentOperations operations + :vartype server_vulnerability_assessment: + azure.mgmt.security.operations.ServerVulnerabilityAssessmentOperations + :ivar topology: TopologyOperations operations + :vartype topology: azure.mgmt.security.operations.TopologyOperations + :ivar alerts: AlertsOperations operations + :vartype alerts: azure.mgmt.security.operations.AlertsOperations + :ivar settings: SettingsOperations operations + :vartype settings: azure.mgmt.security.operations.SettingsOperations + :ivar server_vulnerability_assessments_settings: + ServerVulnerabilityAssessmentsSettingsOperations operations + :vartype server_vulnerability_assessments_settings: + azure.mgmt.security.operations.ServerVulnerabilityAssessmentsSettingsOperations + :ivar api_collections: APICollectionsOperations operations + :vartype api_collections: azure.mgmt.security.operations.APICollectionsOperations + :ivar pricings: PricingsOperations operations + :vartype pricings: azure.mgmt.security.operations.PricingsOperations + :ivar security_standards: SecurityStandardsOperations operations + :vartype security_standards: azure.mgmt.security.operations.SecurityStandardsOperations + :ivar standard_assignments: StandardAssignmentsOperations operations + :vartype standard_assignments: azure.mgmt.security.operations.StandardAssignmentsOperations + :ivar custom_recommendations: CustomRecommendationsOperations operations + :vartype custom_recommendations: azure.mgmt.security.operations.CustomRecommendationsOperations + :ivar azure_dev_ops_orgs: AzureDevOpsOrgsOperations operations + :vartype azure_dev_ops_orgs: azure.mgmt.security.operations.AzureDevOpsOrgsOperations + :ivar azure_dev_ops_projects: AzureDevOpsProjectsOperations operations + :vartype azure_dev_ops_projects: azure.mgmt.security.operations.AzureDevOpsProjectsOperations + :ivar azure_dev_ops_repos: AzureDevOpsReposOperations operations + :vartype azure_dev_ops_repos: azure.mgmt.security.operations.AzureDevOpsReposOperations + :ivar dev_ops_configurations: DevOpsConfigurationsOperations operations + :vartype dev_ops_configurations: azure.mgmt.security.operations.DevOpsConfigurationsOperations + :ivar git_hub_owners: GitHubOwnersOperations operations + :vartype git_hub_owners: azure.mgmt.security.operations.GitHubOwnersOperations + :ivar git_hub_repos: GitHubReposOperations operations + :vartype git_hub_repos: azure.mgmt.security.operations.GitHubReposOperations + :ivar git_lab_groups: GitLabGroupsOperations operations + :vartype git_lab_groups: azure.mgmt.security.operations.GitLabGroupsOperations + :ivar git_lab_subgroups: GitLabSubgroupsOperations operations + :vartype git_lab_subgroups: azure.mgmt.security.operations.GitLabSubgroupsOperations + :ivar git_lab_projects: GitLabProjectsOperations operations + :vartype git_lab_projects: azure.mgmt.security.operations.GitLabProjectsOperations + :ivar dev_ops_operation_results: DevOpsOperationResultsOperations operations + :vartype dev_ops_operation_results: + azure.mgmt.security.operations.DevOpsOperationResultsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: Azure subscription ID. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is None. :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2024-04-01' - _PROFILE_TAG = "azure.mgmt.security.SecurityCenter" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - 'adaptive_application_controls': '2020-01-01', - 'adaptive_network_hardenings': '2020-01-01', - 'advanced_threat_protection': '2019-01-01', - 'alerts': '2022-01-01', - 'alerts_suppression_rules': '2019-01-01-preview', - 'allowed_connections': '2020-01-01', - 'api_collection': '2022-11-20-preview', - 'api_collection_offboarding': '2022-11-20-preview', - 'api_collection_onboarding': '2022-11-20-preview', - 'api_collections': '2023-11-15', - 'application': '2022-07-01-preview', - 'applications': '2022-07-01-preview', - 'assessments': '2021-06-01', - 'assessments_metadata': '2021-06-01', - 'auto_provisioning_settings': '2017-08-01-preview', - 'automations': '2019-01-01-preview', - 'compliance_results': '2017-08-01', - 'compliances': '2017-08-01-preview', - 'connectors': '2020-01-01-preview', - 'custom_assessment_automations': '2021-07-01-preview', - 'custom_entity_store_assignments': '2021-07-01-preview', - 'defender_for_storage': '2022-12-01-preview', - 'device_security_groups': '2019-08-01', - 'discovered_security_solutions': '2020-01-01', - 'external_security_solutions': '2020-01-01', - 'governance_assignments': '2022-01-01-preview', - 'governance_rules': '2022-01-01-preview', - 'health_report': '2023-02-01-preview', - 'health_reports': '2023-05-01-preview', - 'information_protection_policies': '2017-08-01-preview', - 'iot_security_solution': '2019-08-01', - 'iot_security_solution_analytics': '2019-08-01', - 'iot_security_solutions_analytics_aggregated_alert': '2019-08-01', - 'iot_security_solutions_analytics_recommendation': '2019-08-01', - 'jit_network_access_policies': '2020-01-01', - 'locations': '2015-06-01-preview', - 'mde_onboardings': '2021-10-01-preview', - 'operations': '2015-06-01-preview', - 'pricings': '2024-01-01', - 'regulatory_compliance_assessments': '2019-01-01-preview', - 'regulatory_compliance_controls': '2019-01-01-preview', - 'regulatory_compliance_standards': '2019-01-01-preview', - 'secure_score_control_definitions': '2020-01-01', - 'secure_score_controls': '2020-01-01', - 'secure_scores': '2020-01-01', - 'security_connector_application': '2022-07-01-preview', - 'security_connector_applications': '2022-07-01-preview', - 'security_connectors': '2023-10-01-preview', - 'security_contacts': '2020-01-01-preview', - 'security_operators': '2023-01-01-preview', - 'security_solutions': '2020-01-01', - 'security_solutions_reference_data': '2020-01-01', - 'sensitivity_settings': '2023-02-15-preview', - 'server_vulnerability_assessment': '2020-01-01', - 'server_vulnerability_assessments_settings': '2023-05-01', - 'settings': '2022-05-01', - 'software_inventories': '2021-05-01-preview', - 'sql_vulnerability_assessment_baseline_rules': '2023-02-01-preview', - 'sql_vulnerability_assessment_scan_results': '2023-02-01-preview', - 'sql_vulnerability_assessment_scans': '2023-02-01-preview', - 'sub_assessments': '2019-01-01-preview', - 'tasks': '2015-06-01-preview', - 'topology': '2020-01-01', - 'workspace_settings': '2017-08-01-preview', - }}, - _PROFILE_TAG + " latest" - ) - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - api_version: Optional[str]=None, - base_url: str = "https://management.azure.com", - profile: KnownProfiles=KnownProfiles.default, - **kwargs: Any - ): - if api_version: - kwargs.setdefault('api_version', api_version) - self._config = SecurityCenterConfiguration(credential, subscription_id, **kwargs) + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + _cloud = kwargs.pop("cloud_setting", None) 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 = SecurityCenterConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -158,1292 +323,217 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - super(SecurityCenter, self).__init__( - api_version=api_version, - profile=profile + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tasks = TasksOperations(self._client, self._config, self._serialize, self._deserialize) + self.auto_provisioning_settings = AutoProvisioningSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.compliances = CompliancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.information_protection_policies = InformationProtectionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_settings = WorkspaceSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alerts_suppression_rules = AlertsSuppressionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.regulatory_compliance_standards = RegulatoryComplianceStandardsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.regulatory_compliance_controls = RegulatoryComplianceControlsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.regulatory_compliance_assessments = RegulatoryComplianceAssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sub_assessments = SubAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.connectors = ConnectorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.software_inventories = SoftwareInventoriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.custom_assessment_automations = CustomAssessmentAutomationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.custom_entity_store_assignments = CustomEntityStoreAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.mde_onboardings = MdeOnboardingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.governance_assignments = GovernanceAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.governance_rules = GovernanceRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.application = ApplicationOperations(self._client, self._config, self._serialize, self._deserialize) + self.security_connector_applications = SecurityConnectorApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_connector_application = SecurityConnectorApplicationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_operators = SecurityOperatorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sensitivity_settings = SensitivitySettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.health_reports = HealthReportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.automations = AutomationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.security_contacts = SecurityContactsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_connectors = SecurityConnectorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.defender_for_storage = DefenderForStorageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.assessments_metadata = AssessmentsMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.assessments = AssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_links = PrivateLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.compliance_results = ComplianceResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.advanced_threat_protection = AdvancedThreatProtectionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.device_security_groups = DeviceSecurityGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.iot_security_solution_analytics = IotSecuritySolutionAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.iot_security_solutions_analytics_aggregated_alert = IotSecuritySolutionsAnalyticsAggregatedAlertOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.iot_security_solutions_analytics_recommendation = IotSecuritySolutionsAnalyticsRecommendationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.iot_security_solution = IotSecuritySolutionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.allowed_connections = AllowedConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.external_security_solutions = ExternalSecuritySolutionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.secure_scores = SecureScoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.secure_score_controls = SecureScoreControlsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.secure_score_control_definitions = SecureScoreControlDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_solutions = SecuritySolutionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.server_vulnerability_assessment = ServerVulnerabilityAssessmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.topology = TopologyOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_vulnerability_assessments_settings = ServerVulnerabilityAssessmentsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_collections = APICollectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.security_standards = SecurityStandardsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.standard_assignments = StandardAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.custom_recommendations = CustomRecommendationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.azure_dev_ops_orgs = AzureDevOpsOrgsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.azure_dev_ops_projects = AzureDevOpsProjectsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.azure_dev_ops_repos = AzureDevOpsReposOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dev_ops_configurations = DevOpsConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.git_hub_owners = GitHubOwnersOperations(self._client, self._config, self._serialize, self._deserialize) + self.git_hub_repos = GitHubReposOperations(self._client, self._config, self._serialize, self._deserialize) + self.git_lab_groups = GitLabGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.git_lab_subgroups = GitLabSubgroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.git_lab_projects = GitLabProjectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.dev_ops_operation_results = DevOpsOperationResultsOperations( + self._client, self._config, self._serialize, self._deserialize ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2015-06-01-preview: :mod:`v2015_06_01_preview.models` - * 2017-08-01: :mod:`v2017_08_01.models` - * 2017-08-01-preview: :mod:`v2017_08_01_preview.models` - * 2018-06-01: :mod:`v2018_06_01.models` - * 2019-01-01: :mod:`v2019_01_01.models` - * 2019-01-01-preview: :mod:`v2019_01_01_preview.models` - * 2019-08-01: :mod:`v2019_08_01.models` - * 2020-01-01: :mod:`v2020_01_01.models` - * 2020-01-01-preview: :mod:`v2020_01_01_preview.models` - * 2020-07-01-preview: :mod:`v2020_07_01_preview.models` - * 2021-01-01: :mod:`v2021_01_01.models` - * 2021-05-01-preview: :mod:`v2021_05_01_preview.models` - * 2021-06-01: :mod:`v2021_06_01.models` - * 2021-07-01: :mod:`v2021_07_01.models` - * 2021-07-01-preview: :mod:`v2021_07_01_preview.models` - * 2021-10-01-preview: :mod:`v2021_10_01_preview.models` - * 2022-01-01: :mod:`v2022_01_01.models` - * 2022-01-01-preview: :mod:`v2022_01_01_preview.models` - * 2022-03-01: :mod:`v2022_03_01.models` - * 2022-05-01: :mod:`v2022_05_01.models` - * 2022-05-01-preview: :mod:`v2022_05_01_preview.models` - * 2022-07-01-preview: :mod:`v2022_07_01_preview.models` - * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` - * 2022-11-20-preview: :mod:`v2022_11_20_preview.models` - * 2022-12-01-preview: :mod:`v2022_12_01_preview.models` - * 2023-01-01: :mod:`v2023_01_01.models` - * 2023-01-01-preview: :mod:`v2023_01_01_preview.models` - * 2023-02-01-preview: :mod:`v2023_02_01_preview.models` - * 2023-02-15-preview: :mod:`v2023_02_15_preview.models` - * 2023-03-01-preview: :mod:`v2023_03_01_preview.models` - * 2023-05-01: :mod:`v2023_05_01.models` - * 2023-05-01-preview: :mod:`v2023_05_01_preview.models` - * 2023-09-01-preview: :mod:`v2023_09_01_preview.models` - * 2023-10-01-preview: :mod:`v2023_10_01_preview.models` - * 2023-11-15: :mod:`v2023_11_15.models` - * 2024-01-01: :mod:`v2024_01_01.models` - * 2024-04-01: :mod:`v2024_04_01.models` - """ - if api_version == '2015-06-01-preview': - from .v2015_06_01_preview import models - return models - elif api_version == '2017-08-01': - from .v2017_08_01 import models - return models - elif api_version == '2017-08-01-preview': - from .v2017_08_01_preview import models - return models - elif api_version == '2018-06-01': - from .v2018_06_01 import models - return models - elif api_version == '2019-01-01': - from .v2019_01_01 import models - return models - elif api_version == '2019-01-01-preview': - from .v2019_01_01_preview import models - return models - elif api_version == '2019-08-01': - from .v2019_08_01 import models - return models - elif api_version == '2020-01-01': - from .v2020_01_01 import models - return models - elif api_version == '2020-01-01-preview': - from .v2020_01_01_preview import models - return models - elif api_version == '2020-07-01-preview': - from .v2020_07_01_preview import models - return models - elif api_version == '2021-01-01': - from .v2021_01_01 import models - return models - elif api_version == '2021-05-01-preview': - from .v2021_05_01_preview import models - return models - elif api_version == '2021-06-01': - from .v2021_06_01 import models - return models - elif api_version == '2021-07-01': - from .v2021_07_01 import models - return models - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview import models - return models - elif api_version == '2021-10-01-preview': - from .v2021_10_01_preview import models - return models - elif api_version == '2022-01-01': - from .v2022_01_01 import models - return models - elif api_version == '2022-01-01-preview': - from .v2022_01_01_preview import models - return models - elif api_version == '2022-03-01': - from .v2022_03_01 import models - return models - elif api_version == '2022-05-01': - from .v2022_05_01 import models - return models - elif api_version == '2022-05-01-preview': - from .v2022_05_01_preview import models - return models - elif api_version == '2022-07-01-preview': - from .v2022_07_01_preview import models - return models - elif api_version == '2022-08-01-preview': - from .v2022_08_01_preview import models - return models - elif api_version == '2022-11-20-preview': - from .v2022_11_20_preview import models - return models - elif api_version == '2022-12-01-preview': - from .v2022_12_01_preview import models - return models - elif api_version == '2023-01-01': - from .v2023_01_01 import models - return models - elif api_version == '2023-01-01-preview': - from .v2023_01_01_preview import models - return models - elif api_version == '2023-02-01-preview': - from .v2023_02_01_preview import models - return models - elif api_version == '2023-02-15-preview': - from .v2023_02_15_preview import models - return models - elif api_version == '2023-03-01-preview': - from .v2023_03_01_preview import models - return models - elif api_version == '2023-05-01': - from .v2023_05_01 import models - return models - elif api_version == '2023-05-01-preview': - from .v2023_05_01_preview import models - return models - elif api_version == '2023-09-01-preview': - from .v2023_09_01_preview import models - return models - elif api_version == '2023-10-01-preview': - from .v2023_10_01_preview import models - return models - elif api_version == '2023-11-15': - from .v2023_11_15 import models - return models - elif api_version == '2024-01-01': - from .v2024_01_01 import models - return models - elif api_version == '2024-04-01': - from .v2024_04_01 import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def adaptive_application_controls(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AdaptiveApplicationControlsOperations` - """ - api_version = self._get_api_version('adaptive_application_controls') - if api_version == '2020-01-01': - from .v2020_01_01.operations import AdaptiveApplicationControlsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'adaptive_application_controls'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def adaptive_network_hardenings(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AdaptiveNetworkHardeningsOperations` - """ - api_version = self._get_api_version('adaptive_network_hardenings') - if api_version == '2020-01-01': - from .v2020_01_01.operations import AdaptiveNetworkHardeningsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'adaptive_network_hardenings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def advanced_threat_protection(self): - """Instance depends on the API version: - - * 2019-01-01: :class:`AdvancedThreatProtectionOperations` - """ - api_version = self._get_api_version('advanced_threat_protection') - if api_version == '2019-01-01': - from .v2019_01_01.operations import AdvancedThreatProtectionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'advanced_threat_protection'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alerts(self): - """Instance depends on the API version: - - * 2021-01-01: :class:`AlertsOperations` - * 2022-01-01: :class:`AlertsOperations` - """ - api_version = self._get_api_version('alerts') - if api_version == '2021-01-01': - from .v2021_01_01.operations import AlertsOperations as OperationClass - elif api_version == '2022-01-01': - from .v2022_01_01.operations import AlertsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alerts_suppression_rules(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`AlertsSuppressionRulesOperations` - """ - api_version = self._get_api_version('alerts_suppression_rules') - if api_version == '2019-01-01-preview': - from .v2019_01_01_preview.operations import AlertsSuppressionRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alerts_suppression_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def allowed_connections(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AllowedConnectionsOperations` - """ - api_version = self._get_api_version('allowed_connections') - if api_version == '2020-01-01': - from .v2020_01_01.operations import AllowedConnectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'allowed_connections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def api_collection(self): - """Instance depends on the API version: - - * 2022-11-20-preview: :class:`APICollectionOperations` - """ - api_version = self._get_api_version('api_collection') - if api_version == '2022-11-20-preview': - from .v2022_11_20_preview.operations import APICollectionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'api_collection'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def api_collection_offboarding(self): - """Instance depends on the API version: - - * 2022-11-20-preview: :class:`APICollectionOffboardingOperations` - """ - api_version = self._get_api_version('api_collection_offboarding') - if api_version == '2022-11-20-preview': - from .v2022_11_20_preview.operations import APICollectionOffboardingOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'api_collection_offboarding'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def api_collection_onboarding(self): - """Instance depends on the API version: - - * 2022-11-20-preview: :class:`APICollectionOnboardingOperations` - """ - api_version = self._get_api_version('api_collection_onboarding') - if api_version == '2022-11-20-preview': - from .v2022_11_20_preview.operations import APICollectionOnboardingOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'api_collection_onboarding'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def api_collections(self): - """Instance depends on the API version: - - * 2023-11-15: :class:`APICollectionsOperations` - """ - api_version = self._get_api_version('api_collections') - if api_version == '2023-11-15': - from .v2023_11_15.operations import APICollectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'api_collections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def application(self): - """Instance depends on the API version: - - * 2022-07-01-preview: :class:`ApplicationOperations` - """ - api_version = self._get_api_version('application') - if api_version == '2022-07-01-preview': - from .v2022_07_01_preview.operations import ApplicationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'application'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def applications(self): - """Instance depends on the API version: - - * 2022-07-01-preview: :class:`ApplicationsOperations` - """ - api_version = self._get_api_version('applications') - if api_version == '2022-07-01-preview': - from .v2022_07_01_preview.operations import ApplicationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def assessments(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AssessmentsOperations` - * 2021-06-01: :class:`AssessmentsOperations` - """ - api_version = self._get_api_version('assessments') - if api_version == '2020-01-01': - from .v2020_01_01.operations import AssessmentsOperations as OperationClass - elif api_version == '2021-06-01': - from .v2021_06_01.operations import AssessmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'assessments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def assessments_metadata(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AssessmentsMetadataOperations` - * 2021-06-01: :class:`AssessmentsMetadataOperations` - """ - api_version = self._get_api_version('assessments_metadata') - if api_version == '2020-01-01': - from .v2020_01_01.operations import AssessmentsMetadataOperations as OperationClass - elif api_version == '2021-06-01': - from .v2021_06_01.operations import AssessmentsMetadataOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'assessments_metadata'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def auto_provisioning_settings(self): - """Instance depends on the API version: - - * 2017-08-01-preview: :class:`AutoProvisioningSettingsOperations` - """ - api_version = self._get_api_version('auto_provisioning_settings') - if api_version == '2017-08-01-preview': - from .v2017_08_01_preview.operations import AutoProvisioningSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'auto_provisioning_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def automations(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`AutomationsOperations` - """ - api_version = self._get_api_version('automations') - if api_version == '2019-01-01-preview': - from .v2019_01_01_preview.operations import AutomationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'automations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def azure_dev_ops_orgs(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`AzureDevOpsOrgsOperations` - * 2024-04-01: :class:`AzureDevOpsOrgsOperations` - """ - api_version = self._get_api_version('azure_dev_ops_orgs') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import AzureDevOpsOrgsOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import AzureDevOpsOrgsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'azure_dev_ops_orgs'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def azure_dev_ops_projects(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`AzureDevOpsProjectsOperations` - * 2024-04-01: :class:`AzureDevOpsProjectsOperations` - """ - api_version = self._get_api_version('azure_dev_ops_projects') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import AzureDevOpsProjectsOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import AzureDevOpsProjectsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'azure_dev_ops_projects'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def azure_dev_ops_repos(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`AzureDevOpsReposOperations` - * 2024-04-01: :class:`AzureDevOpsReposOperations` - """ - api_version = self._get_api_version('azure_dev_ops_repos') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import AzureDevOpsReposOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import AzureDevOpsReposOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'azure_dev_ops_repos'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def compliance_results(self): - """Instance depends on the API version: - - * 2017-08-01: :class:`ComplianceResultsOperations` - """ - api_version = self._get_api_version('compliance_results') - if api_version == '2017-08-01': - from .v2017_08_01.operations import ComplianceResultsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'compliance_results'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def compliances(self): - """Instance depends on the API version: - - * 2017-08-01-preview: :class:`CompliancesOperations` - """ - api_version = self._get_api_version('compliances') - if api_version == '2017-08-01-preview': - from .v2017_08_01_preview.operations import CompliancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'compliances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def connectors(self): - """Instance depends on the API version: - - * 2020-01-01-preview: :class:`ConnectorsOperations` - """ - api_version = self._get_api_version('connectors') - if api_version == '2020-01-01-preview': - from .v2020_01_01_preview.operations import ConnectorsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'connectors'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def custom_assessment_automations(self): - """Instance depends on the API version: - - * 2021-07-01-preview: :class:`CustomAssessmentAutomationsOperations` - """ - api_version = self._get_api_version('custom_assessment_automations') - if api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import CustomAssessmentAutomationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'custom_assessment_automations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def custom_entity_store_assignments(self): - """Instance depends on the API version: - - * 2021-07-01-preview: :class:`CustomEntityStoreAssignmentsOperations` - """ - api_version = self._get_api_version('custom_entity_store_assignments') - if api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import CustomEntityStoreAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'custom_entity_store_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def defender_for_storage(self): - """Instance depends on the API version: - - * 2022-12-01-preview: :class:`DefenderForStorageOperations` - """ - api_version = self._get_api_version('defender_for_storage') - if api_version == '2022-12-01-preview': - from .v2022_12_01_preview.operations import DefenderForStorageOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'defender_for_storage'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def dev_ops_configurations(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`DevOpsConfigurationsOperations` - * 2024-04-01: :class:`DevOpsConfigurationsOperations` - """ - api_version = self._get_api_version('dev_ops_configurations') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import DevOpsConfigurationsOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import DevOpsConfigurationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'dev_ops_configurations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def dev_ops_operation_results(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`DevOpsOperationResultsOperations` - * 2024-04-01: :class:`DevOpsOperationResultsOperations` - """ - api_version = self._get_api_version('dev_ops_operation_results') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import DevOpsOperationResultsOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import DevOpsOperationResultsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'dev_ops_operation_results'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def device_security_groups(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`DeviceSecurityGroupsOperations` - """ - api_version = self._get_api_version('device_security_groups') - if api_version == '2019-08-01': - from .v2019_08_01.operations import DeviceSecurityGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'device_security_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def discovered_security_solutions(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`DiscoveredSecuritySolutionsOperations` - """ - api_version = self._get_api_version('discovered_security_solutions') - if api_version == '2020-01-01': - from .v2020_01_01.operations import DiscoveredSecuritySolutionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'discovered_security_solutions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def external_security_solutions(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`ExternalSecuritySolutionsOperations` - """ - api_version = self._get_api_version('external_security_solutions') - if api_version == '2020-01-01': - from .v2020_01_01.operations import ExternalSecuritySolutionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'external_security_solutions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_hub_owners(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitHubOwnersOperations` - * 2024-04-01: :class:`GitHubOwnersOperations` - """ - api_version = self._get_api_version('git_hub_owners') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import GitHubOwnersOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import GitHubOwnersOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_hub_owners'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_hub_repos(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitHubReposOperations` - * 2024-04-01: :class:`GitHubReposOperations` - """ - api_version = self._get_api_version('git_hub_repos') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import GitHubReposOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import GitHubReposOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_hub_repos'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_lab_groups(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitLabGroupsOperations` - * 2024-04-01: :class:`GitLabGroupsOperations` - """ - api_version = self._get_api_version('git_lab_groups') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import GitLabGroupsOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import GitLabGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_lab_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_lab_projects(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitLabProjectsOperations` - * 2024-04-01: :class:`GitLabProjectsOperations` - """ - api_version = self._get_api_version('git_lab_projects') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import GitLabProjectsOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import GitLabProjectsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_lab_projects'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_lab_subgroups(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitLabSubgroupsOperations` - * 2024-04-01: :class:`GitLabSubgroupsOperations` - """ - api_version = self._get_api_version('git_lab_subgroups') - if api_version == '2023-09-01-preview': - from .v2023_09_01_preview.operations import GitLabSubgroupsOperations as OperationClass - elif api_version == '2024-04-01': - from .v2024_04_01.operations import GitLabSubgroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_lab_subgroups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def governance_assignments(self): - """Instance depends on the API version: - - * 2022-01-01-preview: :class:`GovernanceAssignmentsOperations` - """ - api_version = self._get_api_version('governance_assignments') - if api_version == '2022-01-01-preview': - from .v2022_01_01_preview.operations import GovernanceAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'governance_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def governance_rules(self): - """Instance depends on the API version: - - * 2022-01-01-preview: :class:`GovernanceRulesOperations` - """ - api_version = self._get_api_version('governance_rules') - if api_version == '2022-01-01-preview': - from .v2022_01_01_preview.operations import GovernanceRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'governance_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def health_report(self): - """Instance depends on the API version: - - * 2023-02-01-preview: :class:`HealthReportOperations` - """ - api_version = self._get_api_version('health_report') - if api_version == '2023-02-01-preview': - from .v2023_02_01_preview.operations import HealthReportOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'health_report'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def health_reports(self): - """Instance depends on the API version: - - * 2023-02-01-preview: :class:`HealthReportsOperations` - * 2023-05-01-preview: :class:`HealthReportsOperations` - """ - api_version = self._get_api_version('health_reports') - if api_version == '2023-02-01-preview': - from .v2023_02_01_preview.operations import HealthReportsOperations as OperationClass - elif api_version == '2023-05-01-preview': - from .v2023_05_01_preview.operations import HealthReportsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'health_reports'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def information_protection_policies(self): - """Instance depends on the API version: - - * 2017-08-01-preview: :class:`InformationProtectionPoliciesOperations` - """ - api_version = self._get_api_version('information_protection_policies') - if api_version == '2017-08-01-preview': - from .v2017_08_01_preview.operations import InformationProtectionPoliciesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'information_protection_policies'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def iot_security_solution(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`IotSecuritySolutionOperations` - """ - api_version = self._get_api_version('iot_security_solution') - if api_version == '2019-08-01': - from .v2019_08_01.operations import IotSecuritySolutionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'iot_security_solution'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def iot_security_solution_analytics(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`IotSecuritySolutionAnalyticsOperations` - """ - api_version = self._get_api_version('iot_security_solution_analytics') - if api_version == '2019-08-01': - from .v2019_08_01.operations import IotSecuritySolutionAnalyticsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'iot_security_solution_analytics'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def iot_security_solutions_analytics_aggregated_alert(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`IotSecuritySolutionsAnalyticsAggregatedAlertOperations` - """ - api_version = self._get_api_version('iot_security_solutions_analytics_aggregated_alert') - if api_version == '2019-08-01': - from .v2019_08_01.operations import IotSecuritySolutionsAnalyticsAggregatedAlertOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_aggregated_alert'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def iot_security_solutions_analytics_recommendation(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`IotSecuritySolutionsAnalyticsRecommendationOperations` - """ - api_version = self._get_api_version('iot_security_solutions_analytics_recommendation') - if api_version == '2019-08-01': - from .v2019_08_01.operations import IotSecuritySolutionsAnalyticsRecommendationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_recommendation'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def jit_network_access_policies(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`JitNetworkAccessPoliciesOperations` - """ - api_version = self._get_api_version('jit_network_access_policies') - if api_version == '2020-01-01': - from .v2020_01_01.operations import JitNetworkAccessPoliciesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'jit_network_access_policies'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def locations(self): - """Instance depends on the API version: - - * 2015-06-01-preview: :class:`LocationsOperations` - """ - api_version = self._get_api_version('locations') - if api_version == '2015-06-01-preview': - from .v2015_06_01_preview.operations import LocationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'locations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def mde_onboardings(self): - """Instance depends on the API version: - - * 2021-10-01-preview: :class:`MdeOnboardingsOperations` - """ - api_version = self._get_api_version('mde_onboardings') - if api_version == '2021-10-01-preview': - from .v2021_10_01_preview.operations import MdeOnboardingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'mde_onboardings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def operations(self): - """Instance depends on the API version: - - * 2015-06-01-preview: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2015-06-01-preview': - from .v2015_06_01_preview.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def pricings(self): - """Instance depends on the API version: - - * 2018-06-01: :class:`PricingsOperations` - * 2022-03-01: :class:`PricingsOperations` - * 2023-01-01: :class:`PricingsOperations` - * 2024-01-01: :class:`PricingsOperations` - """ - api_version = self._get_api_version('pricings') - if api_version == '2018-06-01': - from .v2018_06_01.operations import PricingsOperations as OperationClass - elif api_version == '2022-03-01': - from .v2022_03_01.operations import PricingsOperations as OperationClass - elif api_version == '2023-01-01': - from .v2023_01_01.operations import PricingsOperations as OperationClass - elif api_version == '2024-01-01': - from .v2024_01_01.operations import PricingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'pricings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def regulatory_compliance_assessments(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`RegulatoryComplianceAssessmentsOperations` - """ - api_version = self._get_api_version('regulatory_compliance_assessments') - if api_version == '2019-01-01-preview': - from .v2019_01_01_preview.operations import RegulatoryComplianceAssessmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'regulatory_compliance_assessments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def regulatory_compliance_controls(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`RegulatoryComplianceControlsOperations` - """ - api_version = self._get_api_version('regulatory_compliance_controls') - if api_version == '2019-01-01-preview': - from .v2019_01_01_preview.operations import RegulatoryComplianceControlsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'regulatory_compliance_controls'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def regulatory_compliance_standards(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`RegulatoryComplianceStandardsOperations` - """ - api_version = self._get_api_version('regulatory_compliance_standards') - if api_version == '2019-01-01-preview': - from .v2019_01_01_preview.operations import RegulatoryComplianceStandardsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'regulatory_compliance_standards'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def secure_score_control_definitions(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecureScoreControlDefinitionsOperations` - """ - api_version = self._get_api_version('secure_score_control_definitions') - if api_version == '2020-01-01': - from .v2020_01_01.operations import SecureScoreControlDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'secure_score_control_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def secure_score_controls(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecureScoreControlsOperations` - """ - api_version = self._get_api_version('secure_score_controls') - if api_version == '2020-01-01': - from .v2020_01_01.operations import SecureScoreControlsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'secure_score_controls'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def secure_scores(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecureScoresOperations` - """ - api_version = self._get_api_version('secure_scores') - if api_version == '2020-01-01': - from .v2020_01_01.operations import SecureScoresOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'secure_scores'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_connector_application(self): - """Instance depends on the API version: - - * 2022-07-01-preview: :class:`SecurityConnectorApplicationOperations` - """ - api_version = self._get_api_version('security_connector_application') - if api_version == '2022-07-01-preview': - from .v2022_07_01_preview.operations import SecurityConnectorApplicationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_connector_application'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_connector_applications(self): - """Instance depends on the API version: - - * 2022-07-01-preview: :class:`SecurityConnectorApplicationsOperations` - """ - api_version = self._get_api_version('security_connector_applications') - if api_version == '2022-07-01-preview': - from .v2022_07_01_preview.operations import SecurityConnectorApplicationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_connector_applications'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_connectors(self): - """Instance depends on the API version: - - * 2021-07-01-preview: :class:`SecurityConnectorsOperations` - * 2022-05-01-preview: :class:`SecurityConnectorsOperations` - * 2022-08-01-preview: :class:`SecurityConnectorsOperations` - * 2023-03-01-preview: :class:`SecurityConnectorsOperations` - * 2023-10-01-preview: :class:`SecurityConnectorsOperations` - """ - api_version = self._get_api_version('security_connectors') - if api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import SecurityConnectorsOperations as OperationClass - elif api_version == '2022-05-01-preview': - from .v2022_05_01_preview.operations import SecurityConnectorsOperations as OperationClass - elif api_version == '2022-08-01-preview': - from .v2022_08_01_preview.operations import SecurityConnectorsOperations as OperationClass - elif api_version == '2023-03-01-preview': - from .v2023_03_01_preview.operations import SecurityConnectorsOperations as OperationClass - elif api_version == '2023-10-01-preview': - from .v2023_10_01_preview.operations import SecurityConnectorsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_connectors'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_contacts(self): - """Instance depends on the API version: - - * 2017-08-01-preview: :class:`SecurityContactsOperations` - * 2020-01-01-preview: :class:`SecurityContactsOperations` - """ - api_version = self._get_api_version('security_contacts') - if api_version == '2017-08-01-preview': - from .v2017_08_01_preview.operations import SecurityContactsOperations as OperationClass - elif api_version == '2020-01-01-preview': - from .v2020_01_01_preview.operations import SecurityContactsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_contacts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_operators(self): - """Instance depends on the API version: - - * 2023-01-01-preview: :class:`SecurityOperatorsOperations` - """ - api_version = self._get_api_version('security_operators') - if api_version == '2023-01-01-preview': - from .v2023_01_01_preview.operations import SecurityOperatorsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_operators'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_solutions(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecuritySolutionsOperations` - """ - api_version = self._get_api_version('security_solutions') - if api_version == '2020-01-01': - from .v2020_01_01.operations import SecuritySolutionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_solutions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_solutions_reference_data(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecuritySolutionsReferenceDataOperations` - """ - api_version = self._get_api_version('security_solutions_reference_data') - if api_version == '2020-01-01': - from .v2020_01_01.operations import SecuritySolutionsReferenceDataOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_solutions_reference_data'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sensitivity_settings(self): - """Instance depends on the API version: - - * 2023-02-15-preview: :class:`SensitivitySettingsOperations` - """ - api_version = self._get_api_version('sensitivity_settings') - if api_version == '2023-02-15-preview': - from .v2023_02_15_preview.operations import SensitivitySettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sensitivity_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def server_vulnerability_assessment(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`ServerVulnerabilityAssessmentOperations` - """ - api_version = self._get_api_version('server_vulnerability_assessment') - if api_version == '2020-01-01': - from .v2020_01_01.operations import ServerVulnerabilityAssessmentOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'server_vulnerability_assessment'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def server_vulnerability_assessments_settings(self): - """Instance depends on the API version: - - * 2023-05-01: :class:`ServerVulnerabilityAssessmentsSettingsOperations` - """ - api_version = self._get_api_version('server_vulnerability_assessments_settings') - if api_version == '2023-05-01': - from .v2023_05_01.operations import ServerVulnerabilityAssessmentsSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'server_vulnerability_assessments_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def settings(self): - """Instance depends on the API version: - - * 2021-06-01: :class:`SettingsOperations` - * 2021-07-01: :class:`SettingsOperations` - * 2022-05-01: :class:`SettingsOperations` - """ - api_version = self._get_api_version('settings') - if api_version == '2021-06-01': - from .v2021_06_01.operations import SettingsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import SettingsOperations as OperationClass - elif api_version == '2022-05-01': - from .v2022_05_01.operations import SettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def software_inventories(self): - """Instance depends on the API version: - - * 2021-05-01-preview: :class:`SoftwareInventoriesOperations` - """ - api_version = self._get_api_version('software_inventories') - if api_version == '2021-05-01-preview': - from .v2021_05_01_preview.operations import SoftwareInventoriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'software_inventories'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sql_vulnerability_assessment_baseline_rules(self): - """Instance depends on the API version: - - * 2020-07-01-preview: :class:`SqlVulnerabilityAssessmentBaselineRulesOperations` - * 2023-02-01-preview: :class:`SqlVulnerabilityAssessmentBaselineRulesOperations` - """ - api_version = self._get_api_version('sql_vulnerability_assessment_baseline_rules') - if api_version == '2020-07-01-preview': - from .v2020_07_01_preview.operations import SqlVulnerabilityAssessmentBaselineRulesOperations as OperationClass - elif api_version == '2023-02-01-preview': - from .v2023_02_01_preview.operations import SqlVulnerabilityAssessmentBaselineRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_baseline_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sql_vulnerability_assessment_scan_results(self): - """Instance depends on the API version: - - * 2020-07-01-preview: :class:`SqlVulnerabilityAssessmentScanResultsOperations` - * 2023-02-01-preview: :class:`SqlVulnerabilityAssessmentScanResultsOperations` - """ - api_version = self._get_api_version('sql_vulnerability_assessment_scan_results') - if api_version == '2020-07-01-preview': - from .v2020_07_01_preview.operations import SqlVulnerabilityAssessmentScanResultsOperations as OperationClass - elif api_version == '2023-02-01-preview': - from .v2023_02_01_preview.operations import SqlVulnerabilityAssessmentScanResultsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scan_results'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sql_vulnerability_assessment_scans(self): - """Instance depends on the API version: - - * 2020-07-01-preview: :class:`SqlVulnerabilityAssessmentScansOperations` - * 2023-02-01-preview: :class:`SqlVulnerabilityAssessmentScansOperations` - """ - api_version = self._get_api_version('sql_vulnerability_assessment_scans') - if api_version == '2020-07-01-preview': - from .v2020_07_01_preview.operations import SqlVulnerabilityAssessmentScansOperations as OperationClass - elif api_version == '2023-02-01-preview': - from .v2023_02_01_preview.operations import SqlVulnerabilityAssessmentScansOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scans'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sub_assessments(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`SubAssessmentsOperations` - """ - api_version = self._get_api_version('sub_assessments') - if api_version == '2019-01-01-preview': - from .v2019_01_01_preview.operations import SubAssessmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sub_assessments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def tasks(self): - """Instance depends on the API version: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. - * 2015-06-01-preview: :class:`TasksOperations` - """ - api_version = self._get_api_version('tasks') - if api_version == '2015-06-01-preview': - from .v2015_06_01_preview.operations import TasksOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'tasks'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + - @property - def topology(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2020-01-01: :class:`TopologyOperations` + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse """ - api_version = self._get_api_version('topology') - if api_version == '2020-01-01': - from .v2020_01_01.operations import TopologyOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'topology'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - @property - def workspace_settings(self): - """Instance depends on the API version: + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - * 2017-08-01-preview: :class:`WorkspaceSettingsOperations` - """ - api_version = self._get_api_version('workspace_settings') - if api_version == '2017-08-01-preview': - from .v2017_08_01_preview.operations import WorkspaceSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'workspace_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - def close(self): + def close(self) -> None: self._client.close() - def __enter__(self): + + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details): + + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_serialization.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_serialization.py deleted file mode 100644 index 75e26c415d2c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_serialization.py +++ /dev/null @@ -1,2004 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - -# pylint: skip-file -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - TypeVar, - MutableMapping, - Type, - List, - Mapping, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -ModelType = TypeVar("ModelType", bound="Model") -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node.""" - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[ - [str, Dict[str, Any], Any], Any - ] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises: DeserializationError if something went wrong - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls: Type[ModelType], - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> ModelType: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises: DeserializationError if something went wrong - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - """ - return key.replace("\\.", ".") - - -class Serializer(object): - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]]=None): - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize(self, target_obj, data_type=None, **kwargs): - """Serialize data into a string according to type. - - :param target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises: SerializationError if serialization fails. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() - try: - attributes = target_obj._attribute_map - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - else: - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. - :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get('skip_quote', False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - elif data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - else: - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param data: Object to be serialized. - :param str data_type: Type of object in the iterable. - """ - 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 - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param data: Object to be serialized. - :rtype: str - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - else: - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list attr: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. - Defaults to False. - :rtype: list, str - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get('do_quote', False): - serialized = [ - '' if s is None else quote(str(s), safe='') - for s - in serialized - ] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. - :rtype: dict - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) - - @staticmethod - def serialize_bytearray(attr, **kwargs): - """Serialize bytearray into base-64 string. - - :param attr: Object to be serialized. - :rtype: str - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): - """Serialize str into base-64 string. - - :param attr: Object to be serialized. - :rtype: str - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): - """Serialize Decimal object to float. - - :param attr: Object to be serialized. - :rtype: float - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): - """Serialize long (Py2) or int (Py3). - - :param attr: Object to be serialized. - :rtype: int/long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises: TypeError if format invalid. - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises: SerializationError if format invalid. - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises: SerializationError if format invalid - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") - - -def rest_key_extractor(attr, attr_desc, data): - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor(attr, attr_desc, data): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer(object): - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]]=None): - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - 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 - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. - :return: Deserialized object. - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. - :return: Deserialized object. - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None: - return data - try: - attributes = response._attribute_map # type: ignore - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - """ - try: - return self(target_obj, data, content_type=content_type) - except: - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param response: The response model class. - :param d_attrs: The deserialized response attributes. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) - - def deserialize_data(self, data, data_type): - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. - :return: Deserialized object. - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - else: - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :rtype: dict - :raises: TypeError if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node is empty string. - return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - elif isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - elif attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - else: - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :rtype: bytearray - :raises: TypeError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :rtype: bytearray - :raises: TypeError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :rtype: long or int - :raises: ValueError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :rtype: TimeDelta - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - else: - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :rtype: Date - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :rtype: datetime.time - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: Datetime - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - else: - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: Datetime - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.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") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - else: - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :rtype: Datetime - :raises: DeserializationError if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - else: - return date_obj diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_utils/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_utils/__init__.py new file mode 100644 index 000000000000..0af9b28f6607 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_utils/serialization.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_utils/serialization.py new file mode 100644 index 000000000000..f5187701d7be --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_utils/serialization.py @@ -0,0 +1,2032 @@ +# 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. +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + 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. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + 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 + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + 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 + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.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") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_version.py index 99fc271627d8..82b28d01aba7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "7.0.0" +VERSION = "8.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/__init__.py index caee127a8081..183995ca7061 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/__init__.py @@ -5,6 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._security_center import SecurityCenter -__all__ = ['SecurityCenter'] +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._security_center import SecurityCenter # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_configuration.py index 8e89676a2259..a05605c8d931 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_configuration.py @@ -1,13 +1,11 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,10 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SecurityCenterConfiguration: + +class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for SecurityCenter. Note that all parameters used to create this instance are saved as instance @@ -27,16 +25,11 @@ class SecurityCenterConfiguration: :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: Azure subscription ID. Required. :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -44,23 +37,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-security/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_patch.py @@ -0,0 +1,21 @@ +# 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 + + +def patch_sdk(): + """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/security/azure-mgmt-security/azure/mgmt/security/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_security_center.py index d39f0414d90e..dea2813e28f4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_security_center.py @@ -1,145 +1,318 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast +from typing_extensions import Self from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.tools import get_arm_endpoints -from .._serialization import Deserializer, Serializer +from .. import models as _models +from .._utils.serialization import Deserializer, Serializer from ._configuration import SecurityCenterConfiguration +from .operations import ( + APICollectionsOperations, + AdvancedThreatProtectionOperations, + AlertsOperations, + AlertsSuppressionRulesOperations, + AllowedConnectionsOperations, + ApplicationOperations, + ApplicationsOperations, + AssessmentsMetadataOperations, + AssessmentsOperations, + AutoProvisioningSettingsOperations, + AutomationsOperations, + AzureDevOpsOrgsOperations, + AzureDevOpsProjectsOperations, + AzureDevOpsReposOperations, + ComplianceResultsOperations, + CompliancesOperations, + ConnectorsOperations, + CustomAssessmentAutomationsOperations, + CustomEntityStoreAssignmentsOperations, + CustomRecommendationsOperations, + DefenderForStorageOperations, + DevOpsConfigurationsOperations, + DevOpsOperationResultsOperations, + DeviceSecurityGroupsOperations, + DiscoveredSecuritySolutionsOperations, + ExternalSecuritySolutionsOperations, + GitHubOwnersOperations, + GitHubReposOperations, + GitLabGroupsOperations, + GitLabProjectsOperations, + GitLabSubgroupsOperations, + GovernanceAssignmentsOperations, + GovernanceRulesOperations, + HealthReportsOperations, + InformationProtectionPoliciesOperations, + IotSecuritySolutionAnalyticsOperations, + IotSecuritySolutionOperations, + IotSecuritySolutionsAnalyticsAggregatedAlertOperations, + IotSecuritySolutionsAnalyticsRecommendationOperations, + JitNetworkAccessPoliciesOperations, + LocationsOperations, + MdeOnboardingsOperations, + Operations, + PricingsOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + PrivateLinksOperations, + RegulatoryComplianceAssessmentsOperations, + RegulatoryComplianceControlsOperations, + RegulatoryComplianceStandardsOperations, + SecureScoreControlDefinitionsOperations, + SecureScoreControlsOperations, + SecureScoresOperations, + SecurityConnectorApplicationOperations, + SecurityConnectorApplicationsOperations, + SecurityConnectorsOperations, + SecurityContactsOperations, + SecurityOperatorsOperations, + SecuritySolutionsOperations, + SecuritySolutionsReferenceDataOperations, + SecurityStandardsOperations, + SensitivitySettingsOperations, + ServerVulnerabilityAssessmentOperations, + ServerVulnerabilityAssessmentsSettingsOperations, + SettingsOperations, + SoftwareInventoriesOperations, + SqlVulnerabilityAssessmentBaselineRulesOperations, + SqlVulnerabilityAssessmentScanResultsOperations, + SqlVulnerabilityAssessmentScansOperations, + StandardAssignmentsOperations, + SubAssessmentsOperations, + TasksOperations, + TopologyOperations, + WorkspaceSettingsOperations, +) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class SecurityCenter(MultiApiClientMixin, _SDKClient): +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """API spec for Microsoft.Security (Azure Security Center) resource provider. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar locations: LocationsOperations operations + :vartype locations: azure.mgmt.security.aio.operations.LocationsOperations + :ivar tasks: TasksOperations operations + :vartype tasks: azure.mgmt.security.aio.operations.TasksOperations + :ivar auto_provisioning_settings: AutoProvisioningSettingsOperations operations + :vartype auto_provisioning_settings: + azure.mgmt.security.aio.operations.AutoProvisioningSettingsOperations + :ivar compliances: CompliancesOperations operations + :vartype compliances: azure.mgmt.security.aio.operations.CompliancesOperations + :ivar information_protection_policies: InformationProtectionPoliciesOperations operations + :vartype information_protection_policies: + azure.mgmt.security.aio.operations.InformationProtectionPoliciesOperations + :ivar workspace_settings: WorkspaceSettingsOperations operations + :vartype workspace_settings: azure.mgmt.security.aio.operations.WorkspaceSettingsOperations + :ivar alerts_suppression_rules: AlertsSuppressionRulesOperations operations + :vartype alerts_suppression_rules: + azure.mgmt.security.aio.operations.AlertsSuppressionRulesOperations + :ivar regulatory_compliance_standards: RegulatoryComplianceStandardsOperations operations + :vartype regulatory_compliance_standards: + azure.mgmt.security.aio.operations.RegulatoryComplianceStandardsOperations + :ivar regulatory_compliance_controls: RegulatoryComplianceControlsOperations operations + :vartype regulatory_compliance_controls: + azure.mgmt.security.aio.operations.RegulatoryComplianceControlsOperations + :ivar regulatory_compliance_assessments: RegulatoryComplianceAssessmentsOperations operations + :vartype regulatory_compliance_assessments: + azure.mgmt.security.aio.operations.RegulatoryComplianceAssessmentsOperations + :ivar sub_assessments: SubAssessmentsOperations operations + :vartype sub_assessments: azure.mgmt.security.aio.operations.SubAssessmentsOperations + :ivar connectors: ConnectorsOperations operations + :vartype connectors: azure.mgmt.security.aio.operations.ConnectorsOperations + :ivar software_inventories: SoftwareInventoriesOperations operations + :vartype software_inventories: azure.mgmt.security.aio.operations.SoftwareInventoriesOperations + :ivar custom_assessment_automations: CustomAssessmentAutomationsOperations operations + :vartype custom_assessment_automations: + azure.mgmt.security.aio.operations.CustomAssessmentAutomationsOperations + :ivar custom_entity_store_assignments: CustomEntityStoreAssignmentsOperations operations + :vartype custom_entity_store_assignments: + azure.mgmt.security.aio.operations.CustomEntityStoreAssignmentsOperations + :ivar mde_onboardings: MdeOnboardingsOperations operations + :vartype mde_onboardings: azure.mgmt.security.aio.operations.MdeOnboardingsOperations + :ivar governance_assignments: GovernanceAssignmentsOperations operations + :vartype governance_assignments: + azure.mgmt.security.aio.operations.GovernanceAssignmentsOperations + :ivar governance_rules: GovernanceRulesOperations operations + :vartype governance_rules: azure.mgmt.security.aio.operations.GovernanceRulesOperations + :ivar applications: ApplicationsOperations operations + :vartype applications: azure.mgmt.security.aio.operations.ApplicationsOperations + :ivar application: ApplicationOperations operations + :vartype application: azure.mgmt.security.aio.operations.ApplicationOperations + :ivar security_connector_applications: SecurityConnectorApplicationsOperations operations + :vartype security_connector_applications: + azure.mgmt.security.aio.operations.SecurityConnectorApplicationsOperations + :ivar security_connector_application: SecurityConnectorApplicationOperations operations + :vartype security_connector_application: + azure.mgmt.security.aio.operations.SecurityConnectorApplicationOperations + :ivar security_operators: SecurityOperatorsOperations operations + :vartype security_operators: azure.mgmt.security.aio.operations.SecurityOperatorsOperations + :ivar sql_vulnerability_assessment_baseline_rules: + SqlVulnerabilityAssessmentBaselineRulesOperations operations + :vartype sql_vulnerability_assessment_baseline_rules: + azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations + :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations + :vartype sql_vulnerability_assessment_scans: + azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentScansOperations + :ivar sql_vulnerability_assessment_scan_results: + SqlVulnerabilityAssessmentScanResultsOperations operations + :vartype sql_vulnerability_assessment_scan_results: + azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentScanResultsOperations + :ivar sensitivity_settings: SensitivitySettingsOperations operations + :vartype sensitivity_settings: azure.mgmt.security.aio.operations.SensitivitySettingsOperations + :ivar health_reports: HealthReportsOperations operations + :vartype health_reports: azure.mgmt.security.aio.operations.HealthReportsOperations + :ivar automations: AutomationsOperations operations + :vartype automations: azure.mgmt.security.aio.operations.AutomationsOperations + :ivar security_contacts: SecurityContactsOperations operations + :vartype security_contacts: azure.mgmt.security.aio.operations.SecurityContactsOperations + :ivar security_connectors: SecurityConnectorsOperations operations + :vartype security_connectors: azure.mgmt.security.aio.operations.SecurityConnectorsOperations + :ivar defender_for_storage: DefenderForStorageOperations operations + :vartype defender_for_storage: azure.mgmt.security.aio.operations.DefenderForStorageOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.security.aio.operations.Operations + :ivar assessments_metadata: AssessmentsMetadataOperations operations + :vartype assessments_metadata: azure.mgmt.security.aio.operations.AssessmentsMetadataOperations + :ivar assessments: AssessmentsOperations operations + :vartype assessments: azure.mgmt.security.aio.operations.AssessmentsOperations + :ivar private_links: PrivateLinksOperations operations + :vartype private_links: azure.mgmt.security.aio.operations.PrivateLinksOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.security.aio.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.security.aio.operations.PrivateEndpointConnectionsOperations + :ivar compliance_results: ComplianceResultsOperations operations + :vartype compliance_results: azure.mgmt.security.aio.operations.ComplianceResultsOperations + :ivar advanced_threat_protection: AdvancedThreatProtectionOperations operations + :vartype advanced_threat_protection: + azure.mgmt.security.aio.operations.AdvancedThreatProtectionOperations + :ivar device_security_groups: DeviceSecurityGroupsOperations operations + :vartype device_security_groups: + azure.mgmt.security.aio.operations.DeviceSecurityGroupsOperations + :ivar iot_security_solution_analytics: IotSecuritySolutionAnalyticsOperations operations + :vartype iot_security_solution_analytics: + azure.mgmt.security.aio.operations.IotSecuritySolutionAnalyticsOperations + :ivar iot_security_solutions_analytics_aggregated_alert: + IotSecuritySolutionsAnalyticsAggregatedAlertOperations operations + :vartype iot_security_solutions_analytics_aggregated_alert: + azure.mgmt.security.aio.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations + :ivar iot_security_solutions_analytics_recommendation: + IotSecuritySolutionsAnalyticsRecommendationOperations operations + :vartype iot_security_solutions_analytics_recommendation: + azure.mgmt.security.aio.operations.IotSecuritySolutionsAnalyticsRecommendationOperations + :ivar iot_security_solution: IotSecuritySolutionOperations operations + :vartype iot_security_solution: + azure.mgmt.security.aio.operations.IotSecuritySolutionOperations + :ivar allowed_connections: AllowedConnectionsOperations operations + :vartype allowed_connections: azure.mgmt.security.aio.operations.AllowedConnectionsOperations + :ivar discovered_security_solutions: DiscoveredSecuritySolutionsOperations operations + :vartype discovered_security_solutions: + azure.mgmt.security.aio.operations.DiscoveredSecuritySolutionsOperations + :ivar external_security_solutions: ExternalSecuritySolutionsOperations operations + :vartype external_security_solutions: + azure.mgmt.security.aio.operations.ExternalSecuritySolutionsOperations + :ivar jit_network_access_policies: JitNetworkAccessPoliciesOperations operations + :vartype jit_network_access_policies: + azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations + :ivar secure_scores: SecureScoresOperations operations + :vartype secure_scores: azure.mgmt.security.aio.operations.SecureScoresOperations + :ivar secure_score_controls: SecureScoreControlsOperations operations + :vartype secure_score_controls: + azure.mgmt.security.aio.operations.SecureScoreControlsOperations + :ivar secure_score_control_definitions: SecureScoreControlDefinitionsOperations operations + :vartype secure_score_control_definitions: + azure.mgmt.security.aio.operations.SecureScoreControlDefinitionsOperations + :ivar security_solutions: SecuritySolutionsOperations operations + :vartype security_solutions: azure.mgmt.security.aio.operations.SecuritySolutionsOperations + :ivar security_solutions_reference_data: SecuritySolutionsReferenceDataOperations operations + :vartype security_solutions_reference_data: + azure.mgmt.security.aio.operations.SecuritySolutionsReferenceDataOperations + :ivar server_vulnerability_assessment: ServerVulnerabilityAssessmentOperations operations + :vartype server_vulnerability_assessment: + azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentOperations + :ivar topology: TopologyOperations operations + :vartype topology: azure.mgmt.security.aio.operations.TopologyOperations + :ivar alerts: AlertsOperations operations + :vartype alerts: azure.mgmt.security.aio.operations.AlertsOperations + :ivar settings: SettingsOperations operations + :vartype settings: azure.mgmt.security.aio.operations.SettingsOperations + :ivar server_vulnerability_assessments_settings: + ServerVulnerabilityAssessmentsSettingsOperations operations + :vartype server_vulnerability_assessments_settings: + azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentsSettingsOperations + :ivar api_collections: APICollectionsOperations operations + :vartype api_collections: azure.mgmt.security.aio.operations.APICollectionsOperations + :ivar pricings: PricingsOperations operations + :vartype pricings: azure.mgmt.security.aio.operations.PricingsOperations + :ivar security_standards: SecurityStandardsOperations operations + :vartype security_standards: azure.mgmt.security.aio.operations.SecurityStandardsOperations + :ivar standard_assignments: StandardAssignmentsOperations operations + :vartype standard_assignments: azure.mgmt.security.aio.operations.StandardAssignmentsOperations + :ivar custom_recommendations: CustomRecommendationsOperations operations + :vartype custom_recommendations: + azure.mgmt.security.aio.operations.CustomRecommendationsOperations + :ivar azure_dev_ops_orgs: AzureDevOpsOrgsOperations operations + :vartype azure_dev_ops_orgs: azure.mgmt.security.aio.operations.AzureDevOpsOrgsOperations + :ivar azure_dev_ops_projects: AzureDevOpsProjectsOperations operations + :vartype azure_dev_ops_projects: + azure.mgmt.security.aio.operations.AzureDevOpsProjectsOperations + :ivar azure_dev_ops_repos: AzureDevOpsReposOperations operations + :vartype azure_dev_ops_repos: azure.mgmt.security.aio.operations.AzureDevOpsReposOperations + :ivar dev_ops_configurations: DevOpsConfigurationsOperations operations + :vartype dev_ops_configurations: + azure.mgmt.security.aio.operations.DevOpsConfigurationsOperations + :ivar git_hub_owners: GitHubOwnersOperations operations + :vartype git_hub_owners: azure.mgmt.security.aio.operations.GitHubOwnersOperations + :ivar git_hub_repos: GitHubReposOperations operations + :vartype git_hub_repos: azure.mgmt.security.aio.operations.GitHubReposOperations + :ivar git_lab_groups: GitLabGroupsOperations operations + :vartype git_lab_groups: azure.mgmt.security.aio.operations.GitLabGroupsOperations + :ivar git_lab_subgroups: GitLabSubgroupsOperations operations + :vartype git_lab_subgroups: azure.mgmt.security.aio.operations.GitLabSubgroupsOperations + :ivar git_lab_projects: GitLabProjectsOperations operations + :vartype git_lab_projects: azure.mgmt.security.aio.operations.GitLabProjectsOperations + :ivar dev_ops_operation_results: DevOpsOperationResultsOperations operations + :vartype dev_ops_operation_results: + azure.mgmt.security.aio.operations.DevOpsOperationResultsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: Azure subscription ID. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is None. :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2024-04-01' - _PROFILE_TAG = "azure.mgmt.security.SecurityCenter" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - 'adaptive_application_controls': '2020-01-01', - 'adaptive_network_hardenings': '2020-01-01', - 'advanced_threat_protection': '2019-01-01', - 'alerts': '2022-01-01', - 'alerts_suppression_rules': '2019-01-01-preview', - 'allowed_connections': '2020-01-01', - 'api_collection': '2022-11-20-preview', - 'api_collection_offboarding': '2022-11-20-preview', - 'api_collection_onboarding': '2022-11-20-preview', - 'api_collections': '2023-11-15', - 'application': '2022-07-01-preview', - 'applications': '2022-07-01-preview', - 'assessments': '2021-06-01', - 'assessments_metadata': '2021-06-01', - 'auto_provisioning_settings': '2017-08-01-preview', - 'automations': '2019-01-01-preview', - 'compliance_results': '2017-08-01', - 'compliances': '2017-08-01-preview', - 'connectors': '2020-01-01-preview', - 'custom_assessment_automations': '2021-07-01-preview', - 'custom_entity_store_assignments': '2021-07-01-preview', - 'defender_for_storage': '2022-12-01-preview', - 'device_security_groups': '2019-08-01', - 'discovered_security_solutions': '2020-01-01', - 'external_security_solutions': '2020-01-01', - 'governance_assignments': '2022-01-01-preview', - 'governance_rules': '2022-01-01-preview', - 'health_report': '2023-02-01-preview', - 'health_reports': '2023-05-01-preview', - 'information_protection_policies': '2017-08-01-preview', - 'iot_security_solution': '2019-08-01', - 'iot_security_solution_analytics': '2019-08-01', - 'iot_security_solutions_analytics_aggregated_alert': '2019-08-01', - 'iot_security_solutions_analytics_recommendation': '2019-08-01', - 'jit_network_access_policies': '2020-01-01', - 'locations': '2015-06-01-preview', - 'mde_onboardings': '2021-10-01-preview', - 'operations': '2015-06-01-preview', - 'pricings': '2024-01-01', - 'regulatory_compliance_assessments': '2019-01-01-preview', - 'regulatory_compliance_controls': '2019-01-01-preview', - 'regulatory_compliance_standards': '2019-01-01-preview', - 'secure_score_control_definitions': '2020-01-01', - 'secure_score_controls': '2020-01-01', - 'secure_scores': '2020-01-01', - 'security_connector_application': '2022-07-01-preview', - 'security_connector_applications': '2022-07-01-preview', - 'security_connectors': '2023-10-01-preview', - 'security_contacts': '2020-01-01-preview', - 'security_operators': '2023-01-01-preview', - 'security_solutions': '2020-01-01', - 'security_solutions_reference_data': '2020-01-01', - 'sensitivity_settings': '2023-02-15-preview', - 'server_vulnerability_assessment': '2020-01-01', - 'server_vulnerability_assessments_settings': '2023-05-01', - 'settings': '2022-05-01', - 'software_inventories': '2021-05-01-preview', - 'sql_vulnerability_assessment_baseline_rules': '2023-02-01-preview', - 'sql_vulnerability_assessment_scan_results': '2023-02-01-preview', - 'sql_vulnerability_assessment_scans': '2023-02-01-preview', - 'sub_assessments': '2019-01-01-preview', - 'tasks': '2015-06-01-preview', - 'topology': '2020-01-01', - 'workspace_settings': '2017-08-01-preview', - }}, - _PROFILE_TAG + " latest" - ) - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - api_version: Optional[str] = None, - base_url: str = "https://management.azure.com", - profile: KnownProfiles = KnownProfiles.default, - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: - if api_version: - kwargs.setdefault('api_version', api_version) - self._config = SecurityCenterConfiguration(credential, subscription_id, **kwargs) + _cloud = kwargs.pop("cloud_setting", None) 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 = SecurityCenterConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -158,1292 +331,221 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - super(SecurityCenter, self).__init__( - api_version=api_version, - profile=profile + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2015-06-01-preview: :mod:`v2015_06_01_preview.models` - * 2017-08-01: :mod:`v2017_08_01.models` - * 2017-08-01-preview: :mod:`v2017_08_01_preview.models` - * 2018-06-01: :mod:`v2018_06_01.models` - * 2019-01-01: :mod:`v2019_01_01.models` - * 2019-01-01-preview: :mod:`v2019_01_01_preview.models` - * 2019-08-01: :mod:`v2019_08_01.models` - * 2020-01-01: :mod:`v2020_01_01.models` - * 2020-01-01-preview: :mod:`v2020_01_01_preview.models` - * 2020-07-01-preview: :mod:`v2020_07_01_preview.models` - * 2021-01-01: :mod:`v2021_01_01.models` - * 2021-05-01-preview: :mod:`v2021_05_01_preview.models` - * 2021-06-01: :mod:`v2021_06_01.models` - * 2021-07-01: :mod:`v2021_07_01.models` - * 2021-07-01-preview: :mod:`v2021_07_01_preview.models` - * 2021-10-01-preview: :mod:`v2021_10_01_preview.models` - * 2022-01-01: :mod:`v2022_01_01.models` - * 2022-01-01-preview: :mod:`v2022_01_01_preview.models` - * 2022-03-01: :mod:`v2022_03_01.models` - * 2022-05-01: :mod:`v2022_05_01.models` - * 2022-05-01-preview: :mod:`v2022_05_01_preview.models` - * 2022-07-01-preview: :mod:`v2022_07_01_preview.models` - * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` - * 2022-11-20-preview: :mod:`v2022_11_20_preview.models` - * 2022-12-01-preview: :mod:`v2022_12_01_preview.models` - * 2023-01-01: :mod:`v2023_01_01.models` - * 2023-01-01-preview: :mod:`v2023_01_01_preview.models` - * 2023-02-01-preview: :mod:`v2023_02_01_preview.models` - * 2023-02-15-preview: :mod:`v2023_02_15_preview.models` - * 2023-03-01-preview: :mod:`v2023_03_01_preview.models` - * 2023-05-01: :mod:`v2023_05_01.models` - * 2023-05-01-preview: :mod:`v2023_05_01_preview.models` - * 2023-09-01-preview: :mod:`v2023_09_01_preview.models` - * 2023-10-01-preview: :mod:`v2023_10_01_preview.models` - * 2023-11-15: :mod:`v2023_11_15.models` - * 2024-01-01: :mod:`v2024_01_01.models` - * 2024-04-01: :mod:`v2024_04_01.models` - """ - if api_version == '2015-06-01-preview': - from ..v2015_06_01_preview import models - return models - elif api_version == '2017-08-01': - from ..v2017_08_01 import models - return models - elif api_version == '2017-08-01-preview': - from ..v2017_08_01_preview import models - return models - elif api_version == '2018-06-01': - from ..v2018_06_01 import models - return models - elif api_version == '2019-01-01': - from ..v2019_01_01 import models - return models - elif api_version == '2019-01-01-preview': - from ..v2019_01_01_preview import models - return models - elif api_version == '2019-08-01': - from ..v2019_08_01 import models - return models - elif api_version == '2020-01-01': - from ..v2020_01_01 import models - return models - elif api_version == '2020-01-01-preview': - from ..v2020_01_01_preview import models - return models - elif api_version == '2020-07-01-preview': - from ..v2020_07_01_preview import models - return models - elif api_version == '2021-01-01': - from ..v2021_01_01 import models - return models - elif api_version == '2021-05-01-preview': - from ..v2021_05_01_preview import models - return models - elif api_version == '2021-06-01': - from ..v2021_06_01 import models - return models - elif api_version == '2021-07-01': - from ..v2021_07_01 import models - return models - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview import models - return models - elif api_version == '2021-10-01-preview': - from ..v2021_10_01_preview import models - return models - elif api_version == '2022-01-01': - from ..v2022_01_01 import models - return models - elif api_version == '2022-01-01-preview': - from ..v2022_01_01_preview import models - return models - elif api_version == '2022-03-01': - from ..v2022_03_01 import models - return models - elif api_version == '2022-05-01': - from ..v2022_05_01 import models - return models - elif api_version == '2022-05-01-preview': - from ..v2022_05_01_preview import models - return models - elif api_version == '2022-07-01-preview': - from ..v2022_07_01_preview import models - return models - elif api_version == '2022-08-01-preview': - from ..v2022_08_01_preview import models - return models - elif api_version == '2022-11-20-preview': - from ..v2022_11_20_preview import models - return models - elif api_version == '2022-12-01-preview': - from ..v2022_12_01_preview import models - return models - elif api_version == '2023-01-01': - from ..v2023_01_01 import models - return models - elif api_version == '2023-01-01-preview': - from ..v2023_01_01_preview import models - return models - elif api_version == '2023-02-01-preview': - from ..v2023_02_01_preview import models - return models - elif api_version == '2023-02-15-preview': - from ..v2023_02_15_preview import models - return models - elif api_version == '2023-03-01-preview': - from ..v2023_03_01_preview import models - return models - elif api_version == '2023-05-01': - from ..v2023_05_01 import models - return models - elif api_version == '2023-05-01-preview': - from ..v2023_05_01_preview import models - return models - elif api_version == '2023-09-01-preview': - from ..v2023_09_01_preview import models - return models - elif api_version == '2023-10-01-preview': - from ..v2023_10_01_preview import models - return models - elif api_version == '2023-11-15': - from ..v2023_11_15 import models - return models - elif api_version == '2024-01-01': - from ..v2024_01_01 import models - return models - elif api_version == '2024-04-01': - from ..v2024_04_01 import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def adaptive_application_controls(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AdaptiveApplicationControlsOperations` - """ - api_version = self._get_api_version('adaptive_application_controls') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import AdaptiveApplicationControlsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'adaptive_application_controls'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def adaptive_network_hardenings(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AdaptiveNetworkHardeningsOperations` - """ - api_version = self._get_api_version('adaptive_network_hardenings') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import AdaptiveNetworkHardeningsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'adaptive_network_hardenings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def advanced_threat_protection(self): - """Instance depends on the API version: - - * 2019-01-01: :class:`AdvancedThreatProtectionOperations` - """ - api_version = self._get_api_version('advanced_threat_protection') - if api_version == '2019-01-01': - from ..v2019_01_01.aio.operations import AdvancedThreatProtectionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'advanced_threat_protection'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alerts(self): - """Instance depends on the API version: - - * 2021-01-01: :class:`AlertsOperations` - * 2022-01-01: :class:`AlertsOperations` - """ - api_version = self._get_api_version('alerts') - if api_version == '2021-01-01': - from ..v2021_01_01.aio.operations import AlertsOperations as OperationClass - elif api_version == '2022-01-01': - from ..v2022_01_01.aio.operations import AlertsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alerts_suppression_rules(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`AlertsSuppressionRulesOperations` - """ - api_version = self._get_api_version('alerts_suppression_rules') - if api_version == '2019-01-01-preview': - from ..v2019_01_01_preview.aio.operations import AlertsSuppressionRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alerts_suppression_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def allowed_connections(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AllowedConnectionsOperations` - """ - api_version = self._get_api_version('allowed_connections') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import AllowedConnectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'allowed_connections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def api_collection(self): - """Instance depends on the API version: - - * 2022-11-20-preview: :class:`APICollectionOperations` - """ - api_version = self._get_api_version('api_collection') - if api_version == '2022-11-20-preview': - from ..v2022_11_20_preview.aio.operations import APICollectionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'api_collection'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def api_collection_offboarding(self): - """Instance depends on the API version: - - * 2022-11-20-preview: :class:`APICollectionOffboardingOperations` - """ - api_version = self._get_api_version('api_collection_offboarding') - if api_version == '2022-11-20-preview': - from ..v2022_11_20_preview.aio.operations import APICollectionOffboardingOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'api_collection_offboarding'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def api_collection_onboarding(self): - """Instance depends on the API version: - - * 2022-11-20-preview: :class:`APICollectionOnboardingOperations` - """ - api_version = self._get_api_version('api_collection_onboarding') - if api_version == '2022-11-20-preview': - from ..v2022_11_20_preview.aio.operations import APICollectionOnboardingOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'api_collection_onboarding'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def api_collections(self): - """Instance depends on the API version: - - * 2023-11-15: :class:`APICollectionsOperations` - """ - api_version = self._get_api_version('api_collections') - if api_version == '2023-11-15': - from ..v2023_11_15.aio.operations import APICollectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'api_collections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def application(self): - """Instance depends on the API version: - - * 2022-07-01-preview: :class:`ApplicationOperations` - """ - api_version = self._get_api_version('application') - if api_version == '2022-07-01-preview': - from ..v2022_07_01_preview.aio.operations import ApplicationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'application'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def applications(self): - """Instance depends on the API version: - - * 2022-07-01-preview: :class:`ApplicationsOperations` - """ - api_version = self._get_api_version('applications') - if api_version == '2022-07-01-preview': - from ..v2022_07_01_preview.aio.operations import ApplicationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def assessments(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AssessmentsOperations` - * 2021-06-01: :class:`AssessmentsOperations` - """ - api_version = self._get_api_version('assessments') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import AssessmentsOperations as OperationClass - elif api_version == '2021-06-01': - from ..v2021_06_01.aio.operations import AssessmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'assessments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def assessments_metadata(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`AssessmentsMetadataOperations` - * 2021-06-01: :class:`AssessmentsMetadataOperations` - """ - api_version = self._get_api_version('assessments_metadata') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import AssessmentsMetadataOperations as OperationClass - elif api_version == '2021-06-01': - from ..v2021_06_01.aio.operations import AssessmentsMetadataOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'assessments_metadata'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def auto_provisioning_settings(self): - """Instance depends on the API version: - - * 2017-08-01-preview: :class:`AutoProvisioningSettingsOperations` - """ - api_version = self._get_api_version('auto_provisioning_settings') - if api_version == '2017-08-01-preview': - from ..v2017_08_01_preview.aio.operations import AutoProvisioningSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'auto_provisioning_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def automations(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`AutomationsOperations` - """ - api_version = self._get_api_version('automations') - if api_version == '2019-01-01-preview': - from ..v2019_01_01_preview.aio.operations import AutomationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'automations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def azure_dev_ops_orgs(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`AzureDevOpsOrgsOperations` - * 2024-04-01: :class:`AzureDevOpsOrgsOperations` - """ - api_version = self._get_api_version('azure_dev_ops_orgs') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import AzureDevOpsOrgsOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import AzureDevOpsOrgsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'azure_dev_ops_orgs'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def azure_dev_ops_projects(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`AzureDevOpsProjectsOperations` - * 2024-04-01: :class:`AzureDevOpsProjectsOperations` - """ - api_version = self._get_api_version('azure_dev_ops_projects') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import AzureDevOpsProjectsOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import AzureDevOpsProjectsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'azure_dev_ops_projects'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def azure_dev_ops_repos(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`AzureDevOpsReposOperations` - * 2024-04-01: :class:`AzureDevOpsReposOperations` - """ - api_version = self._get_api_version('azure_dev_ops_repos') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import AzureDevOpsReposOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import AzureDevOpsReposOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'azure_dev_ops_repos'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def compliance_results(self): - """Instance depends on the API version: - - * 2017-08-01: :class:`ComplianceResultsOperations` - """ - api_version = self._get_api_version('compliance_results') - if api_version == '2017-08-01': - from ..v2017_08_01.aio.operations import ComplianceResultsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'compliance_results'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def compliances(self): - """Instance depends on the API version: - - * 2017-08-01-preview: :class:`CompliancesOperations` - """ - api_version = self._get_api_version('compliances') - if api_version == '2017-08-01-preview': - from ..v2017_08_01_preview.aio.operations import CompliancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'compliances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def connectors(self): - """Instance depends on the API version: - - * 2020-01-01-preview: :class:`ConnectorsOperations` - """ - api_version = self._get_api_version('connectors') - if api_version == '2020-01-01-preview': - from ..v2020_01_01_preview.aio.operations import ConnectorsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'connectors'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def custom_assessment_automations(self): - """Instance depends on the API version: - - * 2021-07-01-preview: :class:`CustomAssessmentAutomationsOperations` - """ - api_version = self._get_api_version('custom_assessment_automations') - if api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import CustomAssessmentAutomationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'custom_assessment_automations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def custom_entity_store_assignments(self): - """Instance depends on the API version: - - * 2021-07-01-preview: :class:`CustomEntityStoreAssignmentsOperations` - """ - api_version = self._get_api_version('custom_entity_store_assignments') - if api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import CustomEntityStoreAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'custom_entity_store_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def defender_for_storage(self): - """Instance depends on the API version: - - * 2022-12-01-preview: :class:`DefenderForStorageOperations` - """ - api_version = self._get_api_version('defender_for_storage') - if api_version == '2022-12-01-preview': - from ..v2022_12_01_preview.aio.operations import DefenderForStorageOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'defender_for_storage'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def dev_ops_configurations(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`DevOpsConfigurationsOperations` - * 2024-04-01: :class:`DevOpsConfigurationsOperations` - """ - api_version = self._get_api_version('dev_ops_configurations') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import DevOpsConfigurationsOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import DevOpsConfigurationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'dev_ops_configurations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def dev_ops_operation_results(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`DevOpsOperationResultsOperations` - * 2024-04-01: :class:`DevOpsOperationResultsOperations` - """ - api_version = self._get_api_version('dev_ops_operation_results') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import DevOpsOperationResultsOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import DevOpsOperationResultsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'dev_ops_operation_results'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def device_security_groups(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`DeviceSecurityGroupsOperations` - """ - api_version = self._get_api_version('device_security_groups') - if api_version == '2019-08-01': - from ..v2019_08_01.aio.operations import DeviceSecurityGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'device_security_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def discovered_security_solutions(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`DiscoveredSecuritySolutionsOperations` - """ - api_version = self._get_api_version('discovered_security_solutions') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import DiscoveredSecuritySolutionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'discovered_security_solutions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def external_security_solutions(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`ExternalSecuritySolutionsOperations` - """ - api_version = self._get_api_version('external_security_solutions') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import ExternalSecuritySolutionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'external_security_solutions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_hub_owners(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitHubOwnersOperations` - * 2024-04-01: :class:`GitHubOwnersOperations` - """ - api_version = self._get_api_version('git_hub_owners') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import GitHubOwnersOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import GitHubOwnersOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_hub_owners'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_hub_repos(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitHubReposOperations` - * 2024-04-01: :class:`GitHubReposOperations` - """ - api_version = self._get_api_version('git_hub_repos') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import GitHubReposOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import GitHubReposOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_hub_repos'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_lab_groups(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitLabGroupsOperations` - * 2024-04-01: :class:`GitLabGroupsOperations` - """ - api_version = self._get_api_version('git_lab_groups') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import GitLabGroupsOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import GitLabGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_lab_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_lab_projects(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitLabProjectsOperations` - * 2024-04-01: :class:`GitLabProjectsOperations` - """ - api_version = self._get_api_version('git_lab_projects') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import GitLabProjectsOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import GitLabProjectsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_lab_projects'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def git_lab_subgroups(self): - """Instance depends on the API version: - - * 2023-09-01-preview: :class:`GitLabSubgroupsOperations` - * 2024-04-01: :class:`GitLabSubgroupsOperations` - """ - api_version = self._get_api_version('git_lab_subgroups') - if api_version == '2023-09-01-preview': - from ..v2023_09_01_preview.aio.operations import GitLabSubgroupsOperations as OperationClass - elif api_version == '2024-04-01': - from ..v2024_04_01.aio.operations import GitLabSubgroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'git_lab_subgroups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def governance_assignments(self): - """Instance depends on the API version: - - * 2022-01-01-preview: :class:`GovernanceAssignmentsOperations` - """ - api_version = self._get_api_version('governance_assignments') - if api_version == '2022-01-01-preview': - from ..v2022_01_01_preview.aio.operations import GovernanceAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'governance_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def governance_rules(self): - """Instance depends on the API version: - - * 2022-01-01-preview: :class:`GovernanceRulesOperations` - """ - api_version = self._get_api_version('governance_rules') - if api_version == '2022-01-01-preview': - from ..v2022_01_01_preview.aio.operations import GovernanceRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'governance_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def health_report(self): - """Instance depends on the API version: - - * 2023-02-01-preview: :class:`HealthReportOperations` - """ - api_version = self._get_api_version('health_report') - if api_version == '2023-02-01-preview': - from ..v2023_02_01_preview.aio.operations import HealthReportOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'health_report'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def health_reports(self): - """Instance depends on the API version: - - * 2023-02-01-preview: :class:`HealthReportsOperations` - * 2023-05-01-preview: :class:`HealthReportsOperations` - """ - api_version = self._get_api_version('health_reports') - if api_version == '2023-02-01-preview': - from ..v2023_02_01_preview.aio.operations import HealthReportsOperations as OperationClass - elif api_version == '2023-05-01-preview': - from ..v2023_05_01_preview.aio.operations import HealthReportsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'health_reports'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def information_protection_policies(self): - """Instance depends on the API version: - - * 2017-08-01-preview: :class:`InformationProtectionPoliciesOperations` - """ - api_version = self._get_api_version('information_protection_policies') - if api_version == '2017-08-01-preview': - from ..v2017_08_01_preview.aio.operations import InformationProtectionPoliciesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'information_protection_policies'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def iot_security_solution(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`IotSecuritySolutionOperations` - """ - api_version = self._get_api_version('iot_security_solution') - if api_version == '2019-08-01': - from ..v2019_08_01.aio.operations import IotSecuritySolutionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'iot_security_solution'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def iot_security_solution_analytics(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`IotSecuritySolutionAnalyticsOperations` - """ - api_version = self._get_api_version('iot_security_solution_analytics') - if api_version == '2019-08-01': - from ..v2019_08_01.aio.operations import IotSecuritySolutionAnalyticsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'iot_security_solution_analytics'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def iot_security_solutions_analytics_aggregated_alert(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`IotSecuritySolutionsAnalyticsAggregatedAlertOperations` - """ - api_version = self._get_api_version('iot_security_solutions_analytics_aggregated_alert') - if api_version == '2019-08-01': - from ..v2019_08_01.aio.operations import IotSecuritySolutionsAnalyticsAggregatedAlertOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_aggregated_alert'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def iot_security_solutions_analytics_recommendation(self): - """Instance depends on the API version: - - * 2019-08-01: :class:`IotSecuritySolutionsAnalyticsRecommendationOperations` - """ - api_version = self._get_api_version('iot_security_solutions_analytics_recommendation') - if api_version == '2019-08-01': - from ..v2019_08_01.aio.operations import IotSecuritySolutionsAnalyticsRecommendationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_recommendation'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def jit_network_access_policies(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`JitNetworkAccessPoliciesOperations` - """ - api_version = self._get_api_version('jit_network_access_policies') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import JitNetworkAccessPoliciesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'jit_network_access_policies'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def locations(self): - """Instance depends on the API version: - - * 2015-06-01-preview: :class:`LocationsOperations` - """ - api_version = self._get_api_version('locations') - if api_version == '2015-06-01-preview': - from ..v2015_06_01_preview.aio.operations import LocationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'locations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def mde_onboardings(self): - """Instance depends on the API version: - - * 2021-10-01-preview: :class:`MdeOnboardingsOperations` - """ - api_version = self._get_api_version('mde_onboardings') - if api_version == '2021-10-01-preview': - from ..v2021_10_01_preview.aio.operations import MdeOnboardingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'mde_onboardings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def operations(self): - """Instance depends on the API version: - - * 2015-06-01-preview: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2015-06-01-preview': - from ..v2015_06_01_preview.aio.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def pricings(self): - """Instance depends on the API version: - - * 2018-06-01: :class:`PricingsOperations` - * 2022-03-01: :class:`PricingsOperations` - * 2023-01-01: :class:`PricingsOperations` - * 2024-01-01: :class:`PricingsOperations` - """ - api_version = self._get_api_version('pricings') - if api_version == '2018-06-01': - from ..v2018_06_01.aio.operations import PricingsOperations as OperationClass - elif api_version == '2022-03-01': - from ..v2022_03_01.aio.operations import PricingsOperations as OperationClass - elif api_version == '2023-01-01': - from ..v2023_01_01.aio.operations import PricingsOperations as OperationClass - elif api_version == '2024-01-01': - from ..v2024_01_01.aio.operations import PricingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'pricings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def regulatory_compliance_assessments(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`RegulatoryComplianceAssessmentsOperations` - """ - api_version = self._get_api_version('regulatory_compliance_assessments') - if api_version == '2019-01-01-preview': - from ..v2019_01_01_preview.aio.operations import RegulatoryComplianceAssessmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'regulatory_compliance_assessments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def regulatory_compliance_controls(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`RegulatoryComplianceControlsOperations` - """ - api_version = self._get_api_version('regulatory_compliance_controls') - if api_version == '2019-01-01-preview': - from ..v2019_01_01_preview.aio.operations import RegulatoryComplianceControlsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'regulatory_compliance_controls'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def regulatory_compliance_standards(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`RegulatoryComplianceStandardsOperations` - """ - api_version = self._get_api_version('regulatory_compliance_standards') - if api_version == '2019-01-01-preview': - from ..v2019_01_01_preview.aio.operations import RegulatoryComplianceStandardsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'regulatory_compliance_standards'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def secure_score_control_definitions(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecureScoreControlDefinitionsOperations` - """ - api_version = self._get_api_version('secure_score_control_definitions') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import SecureScoreControlDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'secure_score_control_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def secure_score_controls(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecureScoreControlsOperations` - """ - api_version = self._get_api_version('secure_score_controls') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import SecureScoreControlsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'secure_score_controls'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def secure_scores(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecureScoresOperations` - """ - api_version = self._get_api_version('secure_scores') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import SecureScoresOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'secure_scores'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_connector_application(self): - """Instance depends on the API version: - - * 2022-07-01-preview: :class:`SecurityConnectorApplicationOperations` - """ - api_version = self._get_api_version('security_connector_application') - if api_version == '2022-07-01-preview': - from ..v2022_07_01_preview.aio.operations import SecurityConnectorApplicationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_connector_application'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_connector_applications(self): - """Instance depends on the API version: - - * 2022-07-01-preview: :class:`SecurityConnectorApplicationsOperations` - """ - api_version = self._get_api_version('security_connector_applications') - if api_version == '2022-07-01-preview': - from ..v2022_07_01_preview.aio.operations import SecurityConnectorApplicationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_connector_applications'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_connectors(self): - """Instance depends on the API version: - - * 2021-07-01-preview: :class:`SecurityConnectorsOperations` - * 2022-05-01-preview: :class:`SecurityConnectorsOperations` - * 2022-08-01-preview: :class:`SecurityConnectorsOperations` - * 2023-03-01-preview: :class:`SecurityConnectorsOperations` - * 2023-10-01-preview: :class:`SecurityConnectorsOperations` - """ - api_version = self._get_api_version('security_connectors') - if api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass - elif api_version == '2022-05-01-preview': - from ..v2022_05_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass - elif api_version == '2022-08-01-preview': - from ..v2022_08_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass - elif api_version == '2023-03-01-preview': - from ..v2023_03_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass - elif api_version == '2023-10-01-preview': - from ..v2023_10_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_connectors'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_contacts(self): - """Instance depends on the API version: - - * 2017-08-01-preview: :class:`SecurityContactsOperations` - * 2020-01-01-preview: :class:`SecurityContactsOperations` - """ - api_version = self._get_api_version('security_contacts') - if api_version == '2017-08-01-preview': - from ..v2017_08_01_preview.aio.operations import SecurityContactsOperations as OperationClass - elif api_version == '2020-01-01-preview': - from ..v2020_01_01_preview.aio.operations import SecurityContactsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_contacts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_operators(self): - """Instance depends on the API version: - - * 2023-01-01-preview: :class:`SecurityOperatorsOperations` - """ - api_version = self._get_api_version('security_operators') - if api_version == '2023-01-01-preview': - from ..v2023_01_01_preview.aio.operations import SecurityOperatorsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_operators'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_solutions(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecuritySolutionsOperations` - """ - api_version = self._get_api_version('security_solutions') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import SecuritySolutionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_solutions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def security_solutions_reference_data(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`SecuritySolutionsReferenceDataOperations` - """ - api_version = self._get_api_version('security_solutions_reference_data') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import SecuritySolutionsReferenceDataOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'security_solutions_reference_data'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sensitivity_settings(self): - """Instance depends on the API version: - - * 2023-02-15-preview: :class:`SensitivitySettingsOperations` - """ - api_version = self._get_api_version('sensitivity_settings') - if api_version == '2023-02-15-preview': - from ..v2023_02_15_preview.aio.operations import SensitivitySettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sensitivity_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def server_vulnerability_assessment(self): - """Instance depends on the API version: - - * 2020-01-01: :class:`ServerVulnerabilityAssessmentOperations` - """ - api_version = self._get_api_version('server_vulnerability_assessment') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import ServerVulnerabilityAssessmentOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'server_vulnerability_assessment'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def server_vulnerability_assessments_settings(self): - """Instance depends on the API version: - - * 2023-05-01: :class:`ServerVulnerabilityAssessmentsSettingsOperations` - """ - api_version = self._get_api_version('server_vulnerability_assessments_settings') - if api_version == '2023-05-01': - from ..v2023_05_01.aio.operations import ServerVulnerabilityAssessmentsSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'server_vulnerability_assessments_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def settings(self): - """Instance depends on the API version: - - * 2021-06-01: :class:`SettingsOperations` - * 2021-07-01: :class:`SettingsOperations` - * 2022-05-01: :class:`SettingsOperations` - """ - api_version = self._get_api_version('settings') - if api_version == '2021-06-01': - from ..v2021_06_01.aio.operations import SettingsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import SettingsOperations as OperationClass - elif api_version == '2022-05-01': - from ..v2022_05_01.aio.operations import SettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def software_inventories(self): - """Instance depends on the API version: - - * 2021-05-01-preview: :class:`SoftwareInventoriesOperations` - """ - api_version = self._get_api_version('software_inventories') - if api_version == '2021-05-01-preview': - from ..v2021_05_01_preview.aio.operations import SoftwareInventoriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'software_inventories'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sql_vulnerability_assessment_baseline_rules(self): - """Instance depends on the API version: - - * 2020-07-01-preview: :class:`SqlVulnerabilityAssessmentBaselineRulesOperations` - * 2023-02-01-preview: :class:`SqlVulnerabilityAssessmentBaselineRulesOperations` - """ - api_version = self._get_api_version('sql_vulnerability_assessment_baseline_rules') - if api_version == '2020-07-01-preview': - from ..v2020_07_01_preview.aio.operations import SqlVulnerabilityAssessmentBaselineRulesOperations as OperationClass - elif api_version == '2023-02-01-preview': - from ..v2023_02_01_preview.aio.operations import SqlVulnerabilityAssessmentBaselineRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_baseline_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sql_vulnerability_assessment_scan_results(self): - """Instance depends on the API version: - - * 2020-07-01-preview: :class:`SqlVulnerabilityAssessmentScanResultsOperations` - * 2023-02-01-preview: :class:`SqlVulnerabilityAssessmentScanResultsOperations` - """ - api_version = self._get_api_version('sql_vulnerability_assessment_scan_results') - if api_version == '2020-07-01-preview': - from ..v2020_07_01_preview.aio.operations import SqlVulnerabilityAssessmentScanResultsOperations as OperationClass - elif api_version == '2023-02-01-preview': - from ..v2023_02_01_preview.aio.operations import SqlVulnerabilityAssessmentScanResultsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scan_results'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sql_vulnerability_assessment_scans(self): - """Instance depends on the API version: - - * 2020-07-01-preview: :class:`SqlVulnerabilityAssessmentScansOperations` - * 2023-02-01-preview: :class:`SqlVulnerabilityAssessmentScansOperations` - """ - api_version = self._get_api_version('sql_vulnerability_assessment_scans') - if api_version == '2020-07-01-preview': - from ..v2020_07_01_preview.aio.operations import SqlVulnerabilityAssessmentScansOperations as OperationClass - elif api_version == '2023-02-01-preview': - from ..v2023_02_01_preview.aio.operations import SqlVulnerabilityAssessmentScansOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scans'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def sub_assessments(self): - """Instance depends on the API version: - - * 2019-01-01-preview: :class:`SubAssessmentsOperations` - """ - api_version = self._get_api_version('sub_assessments') - if api_version == '2019-01-01-preview': - from ..v2019_01_01_preview.aio.operations import SubAssessmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'sub_assessments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tasks = TasksOperations(self._client, self._config, self._serialize, self._deserialize) + self.auto_provisioning_settings = AutoProvisioningSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.compliances = CompliancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.information_protection_policies = InformationProtectionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_settings = WorkspaceSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alerts_suppression_rules = AlertsSuppressionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.regulatory_compliance_standards = RegulatoryComplianceStandardsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.regulatory_compliance_controls = RegulatoryComplianceControlsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.regulatory_compliance_assessments = RegulatoryComplianceAssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sub_assessments = SubAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.connectors = ConnectorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.software_inventories = SoftwareInventoriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.custom_assessment_automations = CustomAssessmentAutomationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.custom_entity_store_assignments = CustomEntityStoreAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.mde_onboardings = MdeOnboardingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.governance_assignments = GovernanceAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.governance_rules = GovernanceRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.application = ApplicationOperations(self._client, self._config, self._serialize, self._deserialize) + self.security_connector_applications = SecurityConnectorApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_connector_application = SecurityConnectorApplicationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_operators = SecurityOperatorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sensitivity_settings = SensitivitySettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.health_reports = HealthReportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.automations = AutomationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.security_contacts = SecurityContactsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_connectors = SecurityConnectorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.defender_for_storage = DefenderForStorageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.assessments_metadata = AssessmentsMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.assessments = AssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_links = PrivateLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.compliance_results = ComplianceResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.advanced_threat_protection = AdvancedThreatProtectionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.device_security_groups = DeviceSecurityGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.iot_security_solution_analytics = IotSecuritySolutionAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.iot_security_solutions_analytics_aggregated_alert = IotSecuritySolutionsAnalyticsAggregatedAlertOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.iot_security_solutions_analytics_recommendation = IotSecuritySolutionsAnalyticsRecommendationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.iot_security_solution = IotSecuritySolutionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.allowed_connections = AllowedConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.external_security_solutions = ExternalSecuritySolutionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.secure_scores = SecureScoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.secure_score_controls = SecureScoreControlsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.secure_score_control_definitions = SecureScoreControlDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_solutions = SecuritySolutionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.server_vulnerability_assessment = ServerVulnerabilityAssessmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.topology = TopologyOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_vulnerability_assessments_settings = ServerVulnerabilityAssessmentsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_collections = APICollectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.security_standards = SecurityStandardsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.standard_assignments = StandardAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.custom_recommendations = CustomRecommendationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.azure_dev_ops_orgs = AzureDevOpsOrgsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.azure_dev_ops_projects = AzureDevOpsProjectsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.azure_dev_ops_repos = AzureDevOpsReposOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dev_ops_configurations = DevOpsConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.git_hub_owners = GitHubOwnersOperations(self._client, self._config, self._serialize, self._deserialize) + self.git_hub_repos = GitHubReposOperations(self._client, self._config, self._serialize, self._deserialize) + self.git_lab_groups = GitLabGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.git_lab_subgroups = GitLabSubgroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.git_lab_projects = GitLabProjectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.dev_ops_operation_results = DevOpsOperationResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - @property - def tasks(self): - """Instance depends on the API version: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. - * 2015-06-01-preview: :class:`TasksOperations` - """ - api_version = self._get_api_version('tasks') - if api_version == '2015-06-01-preview': - from ..v2015_06_01_preview.aio.operations import TasksOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'tasks'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + - @property - def topology(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2020-01-01: :class:`TopologyOperations` + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse """ - api_version = self._get_api_version('topology') - if api_version == '2020-01-01': - from ..v2020_01_01.aio.operations import TopologyOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'topology'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - @property - def workspace_settings(self): - """Instance depends on the API version: + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - * 2017-08-01-preview: :class:`WorkspaceSettingsOperations` - """ - api_version = self._get_api_version('workspace_settings') - if api_version == '2017-08-01-preview': - from ..v2017_08_01_preview.aio.operations import WorkspaceSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'workspace_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - async def close(self): + async def close(self) -> None: await self._client.close() - async def __aenter__(self): + + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details): + + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/__init__.py new file mode 100644 index 000000000000..7cefa0cf68cd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/__init__.py @@ -0,0 +1,172 @@ +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._locations_operations import LocationsOperations # type: ignore +from ._tasks_operations import TasksOperations # type: ignore +from ._auto_provisioning_settings_operations import AutoProvisioningSettingsOperations # type: ignore +from ._compliances_operations import CompliancesOperations # type: ignore +from ._information_protection_policies_operations import InformationProtectionPoliciesOperations # type: ignore +from ._workspace_settings_operations import WorkspaceSettingsOperations # type: ignore +from ._alerts_suppression_rules_operations import AlertsSuppressionRulesOperations # type: ignore +from ._regulatory_compliance_standards_operations import RegulatoryComplianceStandardsOperations # type: ignore +from ._regulatory_compliance_controls_operations import RegulatoryComplianceControlsOperations # type: ignore +from ._regulatory_compliance_assessments_operations import RegulatoryComplianceAssessmentsOperations # type: ignore +from ._sub_assessments_operations import SubAssessmentsOperations # type: ignore +from ._connectors_operations import ConnectorsOperations # type: ignore +from ._software_inventories_operations import SoftwareInventoriesOperations # type: ignore +from ._custom_assessment_automations_operations import CustomAssessmentAutomationsOperations # type: ignore +from ._custom_entity_store_assignments_operations import CustomEntityStoreAssignmentsOperations # type: ignore +from ._mde_onboardings_operations import MdeOnboardingsOperations # type: ignore +from ._governance_assignments_operations import GovernanceAssignmentsOperations # type: ignore +from ._governance_rules_operations import GovernanceRulesOperations # type: ignore +from ._applications_operations import ApplicationsOperations # type: ignore +from ._application_operations import ApplicationOperations # type: ignore +from ._security_connector_applications_operations import SecurityConnectorApplicationsOperations # type: ignore +from ._security_connector_application_operations import SecurityConnectorApplicationOperations # type: ignore +from ._security_operators_operations import SecurityOperatorsOperations # type: ignore +from ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations # type: ignore +from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations # type: ignore +from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations # type: ignore +from ._sensitivity_settings_operations import SensitivitySettingsOperations # type: ignore +from ._health_reports_operations import HealthReportsOperations # type: ignore +from ._automations_operations import AutomationsOperations # type: ignore +from ._security_contacts_operations import SecurityContactsOperations # type: ignore +from ._security_connectors_operations import SecurityConnectorsOperations # type: ignore +from ._defender_for_storage_operations import DefenderForStorageOperations # type: ignore +from ._operations import Operations # type: ignore +from ._assessments_metadata_operations import AssessmentsMetadataOperations # type: ignore +from ._assessments_operations import AssessmentsOperations # type: ignore +from ._private_links_operations import PrivateLinksOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._compliance_results_operations import ComplianceResultsOperations # type: ignore +from ._advanced_threat_protection_operations import AdvancedThreatProtectionOperations # type: ignore +from ._device_security_groups_operations import DeviceSecurityGroupsOperations # type: ignore +from ._iot_security_solution_analytics_operations import IotSecuritySolutionAnalyticsOperations # type: ignore +from ._iot_security_solutions_analytics_aggregated_alert_operations import IotSecuritySolutionsAnalyticsAggregatedAlertOperations # type: ignore +from ._iot_security_solutions_analytics_recommendation_operations import IotSecuritySolutionsAnalyticsRecommendationOperations # type: ignore +from ._iot_security_solution_operations import IotSecuritySolutionOperations # type: ignore +from ._allowed_connections_operations import AllowedConnectionsOperations # type: ignore +from ._discovered_security_solutions_operations import DiscoveredSecuritySolutionsOperations # type: ignore +from ._external_security_solutions_operations import ExternalSecuritySolutionsOperations # type: ignore +from ._jit_network_access_policies_operations import JitNetworkAccessPoliciesOperations # type: ignore +from ._secure_scores_operations import SecureScoresOperations # type: ignore +from ._secure_score_controls_operations import SecureScoreControlsOperations # type: ignore +from ._secure_score_control_definitions_operations import SecureScoreControlDefinitionsOperations # type: ignore +from ._security_solutions_operations import SecuritySolutionsOperations # type: ignore +from ._security_solutions_reference_data_operations import SecuritySolutionsReferenceDataOperations # type: ignore +from ._server_vulnerability_assessment_operations import ServerVulnerabilityAssessmentOperations # type: ignore +from ._topology_operations import TopologyOperations # type: ignore +from ._alerts_operations import AlertsOperations # type: ignore +from ._settings_operations import SettingsOperations # type: ignore +from ._server_vulnerability_assessments_settings_operations import ServerVulnerabilityAssessmentsSettingsOperations # type: ignore +from ._api_collections_operations import APICollectionsOperations # type: ignore +from ._pricings_operations import PricingsOperations # type: ignore +from ._security_standards_operations import SecurityStandardsOperations # type: ignore +from ._standard_assignments_operations import StandardAssignmentsOperations # type: ignore +from ._custom_recommendations_operations import CustomRecommendationsOperations # type: ignore +from ._azure_dev_ops_orgs_operations import AzureDevOpsOrgsOperations # type: ignore +from ._azure_dev_ops_projects_operations import AzureDevOpsProjectsOperations # type: ignore +from ._azure_dev_ops_repos_operations import AzureDevOpsReposOperations # type: ignore +from ._dev_ops_configurations_operations import DevOpsConfigurationsOperations # type: ignore +from ._git_hub_owners_operations import GitHubOwnersOperations # type: ignore +from ._git_hub_repos_operations import GitHubReposOperations # type: ignore +from ._git_lab_groups_operations import GitLabGroupsOperations # type: ignore +from ._git_lab_subgroups_operations import GitLabSubgroupsOperations # type: ignore +from ._git_lab_projects_operations import GitLabProjectsOperations # type: ignore +from ._dev_ops_operation_results_operations import DevOpsOperationResultsOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "LocationsOperations", + "TasksOperations", + "AutoProvisioningSettingsOperations", + "CompliancesOperations", + "InformationProtectionPoliciesOperations", + "WorkspaceSettingsOperations", + "AlertsSuppressionRulesOperations", + "RegulatoryComplianceStandardsOperations", + "RegulatoryComplianceControlsOperations", + "RegulatoryComplianceAssessmentsOperations", + "SubAssessmentsOperations", + "ConnectorsOperations", + "SoftwareInventoriesOperations", + "CustomAssessmentAutomationsOperations", + "CustomEntityStoreAssignmentsOperations", + "MdeOnboardingsOperations", + "GovernanceAssignmentsOperations", + "GovernanceRulesOperations", + "ApplicationsOperations", + "ApplicationOperations", + "SecurityConnectorApplicationsOperations", + "SecurityConnectorApplicationOperations", + "SecurityOperatorsOperations", + "SqlVulnerabilityAssessmentBaselineRulesOperations", + "SqlVulnerabilityAssessmentScansOperations", + "SqlVulnerabilityAssessmentScanResultsOperations", + "SensitivitySettingsOperations", + "HealthReportsOperations", + "AutomationsOperations", + "SecurityContactsOperations", + "SecurityConnectorsOperations", + "DefenderForStorageOperations", + "Operations", + "AssessmentsMetadataOperations", + "AssessmentsOperations", + "PrivateLinksOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", + "ComplianceResultsOperations", + "AdvancedThreatProtectionOperations", + "DeviceSecurityGroupsOperations", + "IotSecuritySolutionAnalyticsOperations", + "IotSecuritySolutionsAnalyticsAggregatedAlertOperations", + "IotSecuritySolutionsAnalyticsRecommendationOperations", + "IotSecuritySolutionOperations", + "AllowedConnectionsOperations", + "DiscoveredSecuritySolutionsOperations", + "ExternalSecuritySolutionsOperations", + "JitNetworkAccessPoliciesOperations", + "SecureScoresOperations", + "SecureScoreControlsOperations", + "SecureScoreControlDefinitionsOperations", + "SecuritySolutionsOperations", + "SecuritySolutionsReferenceDataOperations", + "ServerVulnerabilityAssessmentOperations", + "TopologyOperations", + "AlertsOperations", + "SettingsOperations", + "ServerVulnerabilityAssessmentsSettingsOperations", + "APICollectionsOperations", + "PricingsOperations", + "SecurityStandardsOperations", + "StandardAssignmentsOperations", + "CustomRecommendationsOperations", + "AzureDevOpsOrgsOperations", + "AzureDevOpsProjectsOperations", + "AzureDevOpsReposOperations", + "DevOpsConfigurationsOperations", + "GitHubOwnersOperations", + "GitHubReposOperations", + "GitLabGroupsOperations", + "GitLabSubgroupsOperations", + "GitLabProjectsOperations", + "DevOpsOperationResultsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_advanced_threat_protection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_advanced_threat_protection_operations.py new file mode 100644 index 000000000000..df9da295fa8f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_advanced_threat_protection_operations.py @@ -0,0 +1,225 @@ +# 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, Literal, Optional, TypeVar, Union, overload + +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._advanced_threat_protection_operations import build_create_request, build_get_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AdvancedThreatProtectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`advanced_threat_protection` 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: SecurityCenterConfiguration = 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_id: str, **kwargs: Any) -> _models.AdvancedThreatProtectionSetting: + """Gets the Advanced Threat Protection settings for the specified resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :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", "2019-01-01")) + setting_name: Literal["current"] = kwargs.pop("setting_name", "current") + cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + api_version=api_version, + setting_name=setting_name, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvancedThreatProtectionSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_id: str, + advanced_threat_protection_setting: _models.AdvancedThreatProtectionSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AdvancedThreatProtectionSetting: + """Creates or updates the Advanced Threat Protection settings on a specified resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Required. + :type advanced_threat_protection_setting: + ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_id: str, + advanced_threat_protection_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AdvancedThreatProtectionSetting: + """Creates or updates the Advanced Threat Protection settings on a specified resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Required. + :type advanced_threat_protection_setting: 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: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_id: str, + advanced_threat_protection_setting: Union[_models.AdvancedThreatProtectionSetting, IO[bytes]], + **kwargs: Any + ) -> _models.AdvancedThreatProtectionSetting: + """Creates or updates the Advanced Threat Protection settings on a specified resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Is either a + AdvancedThreatProtectionSetting type or a IO[bytes] type. Required. + :type advanced_threat_protection_setting: + ~azure.mgmt.security.models.AdvancedThreatProtectionSetting or IO[bytes] + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :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", "2019-01-01")) + setting_name: Literal["current"] = kwargs.pop("setting_name", "current") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(advanced_threat_protection_setting, (IOBase, bytes)): + _content = advanced_threat_protection_setting + else: + _json = self._serialize.body(advanced_threat_protection_setting, "AdvancedThreatProtectionSetting") + + _request = build_create_request( + resource_id=resource_id, + api_version=api_version, + setting_name=setting_name, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvancedThreatProtectionSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_alerts_operations.py new file mode 100644 index 000000000000..51c765090632 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_alerts_operations.py @@ -0,0 +1,1081 @@ +# 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 + +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._alerts_operations import ( + build_get_resource_group_level_request, + build_get_subscription_level_request, + build_list_by_resource_group_request, + build_list_request, + build_list_resource_group_level_by_region_request, + build_list_subscription_level_by_region_request, + build_simulate_request, + build_update_resource_group_level_state_to_activate_request, + build_update_resource_group_level_state_to_dismiss_request, + build_update_resource_group_level_state_to_in_progress_request, + build_update_resource_group_level_state_to_resolve_request, + build_update_subscription_level_state_to_activate_request, + build_update_subscription_level_state_to_dismiss_request, + build_update_subscription_level_state_to_in_progress_request, + build_update_subscription_level_state_to_resolve_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`alerts` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.Alert"]: + """List all the alerts that are associated with the subscription. + + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Alert] + :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", "2022-01-01")) + cls: ClsType[_models.AlertList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Alert"]: + """List all the alerts that are associated with the resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Alert] + :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", "2022-01-01")) + cls: ClsType[_models.AlertList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> AsyncItemPaged["_models.Alert"]: + """List all the alerts that are associated with the subscription that are stored in a specific + location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Alert] + :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", "2022-01-01")) + cls: ClsType[_models.AlertList] = 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_subscription_level_by_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_resource_group_level_by_region( + self, asc_location: str, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Alert"]: + """List all the alerts that are associated with the resource group that are stored in a specific + location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Alert] + :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", "2022-01-01")) + cls: ClsType[_models.AlertList] = 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_resource_group_level_by_region_request( + asc_location=asc_location, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: Any) -> _models.Alert: + """Get an alert that is associated with a subscription. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_name: str + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Alert + :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", "2022-01-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + _request = build_get_subscription_level_request( + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Alert", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_resource_group_level( + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> _models.Alert: + """Get an alert that is associated a resource group or a resource in a resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_name: str + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Alert + :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", "2022-01-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + _request = build_get_resource_group_level_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Alert", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def update_subscription_level_state_to_dismiss( # pylint: disable=name-too-long + self, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_state_to_dismiss_request( + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def update_subscription_level_state_to_resolve( # pylint: disable=name-too-long + self, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_state_to_resolve_request( + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def update_subscription_level_state_to_activate( # pylint: disable=name-too-long + self, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_state_to_activate_request( + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def update_subscription_level_state_to_in_progress( # pylint: disable=name-too-long + self, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_state_to_in_progress_request( + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def update_resource_group_level_state_to_resolve( # pylint: disable=name-too-long + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_state_to_resolve_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def update_resource_group_level_state_to_dismiss( # pylint: disable=name-too-long + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_state_to_dismiss_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def update_resource_group_level_state_to_activate( # pylint: disable=name-too-long + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_state_to_activate_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def update_resource_group_level_state_to_in_progress( # pylint: disable=name-too-long + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_state_to_in_progress_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + async def _simulate_initial( + self, + asc_location: str, + alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, 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", "2022-01-01")) + 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(alert_simulator_request_body, (IOBase, bytes)): + _content = alert_simulator_request_body + else: + _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") + + _request = build_simulate_request( + asc_location=asc_location, + 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 [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_simulate( + self, + asc_location: str, + alert_simulator_request_body: _models.AlertSimulatorRequestBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Simulate security alerts. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_simulator_request_body: Alert Simulator Request Properties. Required. + :type alert_simulator_request_body: ~azure.mgmt.security.models.AlertSimulatorRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_simulate( + self, + asc_location: str, + alert_simulator_request_body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Simulate security alerts. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_simulator_request_body: Alert Simulator Request Properties. Required. + :type alert_simulator_request_body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_simulate( + self, + asc_location: str, + alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Simulate security alerts. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_simulator_request_body: Alert Simulator Request Properties. Is either a + AlertSimulatorRequestBody type or a IO[bytes] type. Required. + :type alert_simulator_request_body: ~azure.mgmt.security.models.AlertSimulatorRequestBody or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._simulate_initial( + asc_location=asc_location, + alert_simulator_request_body=alert_simulator_request_body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # 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": "original-uri"}, **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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_alerts_suppression_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_alerts_suppression_rules_operations.py new file mode 100644 index 000000000000..34f673b1dce7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_alerts_suppression_rules_operations.py @@ -0,0 +1,343 @@ +# 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 + +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._alerts_suppression_rules_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AlertsSuppressionRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`alerts_suppression_rules` 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: SecurityCenterConfiguration = 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, alert_type: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.AlertsSuppressionRule"]: + """List of all the dismiss rules for the given subscription. + + :param alert_type: Type of the alert to get rules for. Default value is None. + :type alert_type: str + :return: An iterator like instance of either AlertsSuppressionRule or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AlertsSuppressionRule] + :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", "2019-01-01-preview")) + cls: ClsType[_models.AlertsSuppressionRulesList] = 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( + subscription_id=self._config.subscription_id, + alert_type=alert_type, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertsSuppressionRulesList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, alerts_suppression_rule_name: str, **kwargs: Any) -> _models.AlertsSuppressionRule: + """Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_name: str + :return: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule + :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", "2019-01-01-preview")) + cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) + + _request = build_get_request( + alerts_suppression_rule_name=alerts_suppression_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AlertsSuppressionRule", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + alerts_suppression_rule_name: str, + alerts_suppression_rule: _models.AlertsSuppressionRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertsSuppressionRule: + """Update existing rule or create new rule if it doesn't exist. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_name: str + :param alerts_suppression_rule: Suppression rule object. Required. + :type alerts_suppression_rule: ~azure.mgmt.security.models.AlertsSuppressionRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + alerts_suppression_rule_name: str, + alerts_suppression_rule: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertsSuppressionRule: + """Update existing rule or create new rule if it doesn't exist. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_name: str + :param alerts_suppression_rule: Suppression rule object. Required. + :type alerts_suppression_rule: 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: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + alerts_suppression_rule_name: str, + alerts_suppression_rule: Union[_models.AlertsSuppressionRule, IO[bytes]], + **kwargs: Any + ) -> _models.AlertsSuppressionRule: + """Update existing rule or create new rule if it doesn't exist. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_name: str + :param alerts_suppression_rule: Suppression rule object. Is either a AlertsSuppressionRule type + or a IO[bytes] type. Required. + :type alerts_suppression_rule: ~azure.mgmt.security.models.AlertsSuppressionRule or IO[bytes] + :return: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule + :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", "2019-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alerts_suppression_rule, (IOBase, bytes)): + _content = alerts_suppression_rule + else: + _json = self._serialize.body(alerts_suppression_rule, "AlertsSuppressionRule") + + _request = build_update_request( + alerts_suppression_rule_name=alerts_suppression_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AlertsSuppressionRule", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, alerts_suppression_rule_name: str, **kwargs: Any) -> None: + """Delete dismiss alert rule for this subscription. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_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", "2019-01-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + alerts_suppression_rule_name=alerts_suppression_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_allowed_connections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_allowed_connections_operations.py new file mode 100644 index 000000000000..d1ed4e31ede8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_allowed_connections_operations.py @@ -0,0 +1,261 @@ +# 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, Union + +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._allowed_connections_operations import ( + build_get_request, + build_list_by_home_region_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AllowedConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`allowed_connections` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.AllowedConnectionsResource"]: + """Gets the list of all possible traffic between resources for the subscription. + + :return: An iterator like instance of either AllowedConnectionsResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AllowedConnectionsResource] + :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", "2020-01-01")) + cls: ClsType[_models.AllowedConnectionsList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AllowedConnectionsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region( + self, asc_location: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AllowedConnectionsResource"]: + """Gets the list of all possible traffic between resources for the subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either AllowedConnectionsResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AllowedConnectionsResource] + :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", "2020-01-01")) + cls: ClsType[_models.AllowedConnectionsList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AllowedConnectionsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + asc_location: str, + connection_type: Union[str, _models.ConnectionType], + **kwargs: Any + ) -> _models.AllowedConnectionsResource: + """Gets the list of all possible traffic between resources for the subscription and location, + based on connection type. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param connection_type: The type of allowed connections (Internal, External). Known values are: + "Internal" and "External". Required. + :type connection_type: str or ~azure.mgmt.security.models.ConnectionType + :return: AllowedConnectionsResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AllowedConnectionsResource + :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", "2020-01-01")) + cls: ClsType[_models.AllowedConnectionsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + connection_type=connection_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AllowedConnectionsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_api_collections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_api_collections_operations.py new file mode 100644 index 000000000000..5d09d70a2eef --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_api_collections_operations.py @@ -0,0 +1,537 @@ +# 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, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast + +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._api_collections_operations import ( + build_get_by_azure_api_management_service_request, + build_list_by_azure_api_management_service_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_offboard_azure_api_management_api_request, + build_onboard_azure_api_management_api_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class APICollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`api_collections` 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: SecurityCenterConfiguration = 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_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.ApiCollection"]: + """Gets a list of API collections within a subscription. + + Gets a list of API collections within a subscription that have been onboarded to Microsoft + Defender for APIs. + + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ApiCollection] + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", 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_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ApiCollection"]: + """Gets a list of API collections within a resource group. + + Gets a list of API collections within a resource group that have been onboarded to Microsoft + Defender for APIs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ApiCollection] + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", 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_by_azure_api_management_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ApiCollection"]: + """Gets a list of onboarded Azure API Management APIs. + + Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for + APIs. If an Azure API Management API is onboarded to Microsoft Defender for APIs, the system + will monitor the operations within the Azure API Management API for intrusive behaviors and + provide alerts for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ApiCollection] + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = 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_by_azure_api_management_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", 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_by_azure_api_management_service( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> _models.ApiCollection: + """Gets an onboarded Azure API Management API. + + Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an + Azure API Management API is onboarded to Microsoft Defender for APIs, the system will monitor + the operations within the Azure API Management API for intrusive behaviors and provide alerts + for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: ApiCollection or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ApiCollection + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + + _request = build_get_by_azure_api_management_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_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("ApiCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _onboard_azure_api_management_api_initial( # pylint: disable=name-too-long + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_onboard_azure_api_management_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + 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 [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["Location"] = self._deserialize("str", response.headers.get("Location")) + + 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_onboard_azure_api_management_api( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ApiCollection]: + """Onboard an Azure API Management API to Microsoft Defender for APIs. + + Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start + monitoring the operations within the Azure Management API for intrusive behaviors and provide + alerts for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: An instance of AsyncLROPoller that returns either ApiCollection or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.ApiCollection] + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollection] = 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._onboard_azure_api_management_api_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApiCollection", 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.ApiCollection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiCollection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def offboard_azure_api_management_api( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> None: + """Offboard an Azure API Management API from Microsoft Defender for APIs. + + Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop + monitoring the operations within the Azure API Management API for intrusive behaviors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: 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", "2023-11-15")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_offboard_azure_api_management_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_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, 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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_application_operations.py new file mode 100644 index 000000000000..727a663980f0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_application_operations.py @@ -0,0 +1,269 @@ +# 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 + +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._application_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApplicationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`application` 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: SecurityCenterConfiguration = 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, application_id: str, **kwargs: Any) -> _models.Application: + """Get a specific application for the requested scope by applicationId. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :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", "2022-07-01-preview")) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + + _request = build_get_request( + application_id=application_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + application_id: str, + application: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Creates or update a security application on the given subscription. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Required. + :type application: ~azure.mgmt.security.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, application_id: str, application: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Application: + """Creates or update a security application on the given subscription. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Required. + :type application: 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: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, application_id: str, application: Union[_models.Application, IO[bytes]], **kwargs: Any + ) -> _models.Application: + """Creates or update a security application on the given subscription. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Is either a Application type or a + IO[bytes] type. Required. + :type application: ~azure.mgmt.security.models.Application or IO[bytes] + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :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", "2022-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application, (IOBase, bytes)): + _content = application + else: + _json = self._serialize.body(application, "Application") + + _request = build_create_or_update_request( + application_id=application_id, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, application_id: str, **kwargs: Any) -> None: + """Delete an Application over a given scope. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: 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", "2022-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + application_id=application_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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_applications_operations.py new file mode 100644 index 000000000000..4b1d8ad892cc --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_applications_operations.py @@ -0,0 +1,116 @@ +# 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.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.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._applications_operations import build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`applications` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.Application"]: + """Get a list of all relevant applications over a subscription level scope. + + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + cls: ClsType[_models.ApplicationsList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_assessments_metadata_operations.py new file mode 100644 index 000000000000..0170d3b1b77a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_assessments_metadata_operations.py @@ -0,0 +1,466 @@ +# 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 + +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._assessments_metadata_operations import ( + build_create_in_subscription_request, + build_delete_in_subscription_request, + build_get_in_subscription_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AssessmentsMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`assessments_metadata` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.SecurityAssessmentMetadataResponse"]: + """Get metadata information on all assessment types. + + :return: An iterator like instance of either SecurityAssessmentMetadataResponse or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityAssessmentMetadataResponse] + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = 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( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityAssessmentMetadataResponseList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityAssessmentMetadataResponse: + """Get metadata information on an assessment type. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + assessment_metadata_name=assessment_metadata_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.SecurityAssessmentMetadataResponse"]: + """Get metadata information on all assessment types in a specific subscription. + + :return: An iterator like instance of either SecurityAssessmentMetadataResponse or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityAssessmentMetadataResponse] + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityAssessmentMetadataResponseList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_in_subscription( + self, assessment_metadata_name: str, **kwargs: Any + ) -> _models.SecurityAssessmentMetadataResponse: + """Get metadata information on an assessment type in a specific subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) + + _request = build_get_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_in_subscription( + self, + assessment_metadata_name: str, + assessment_metadata: _models.SecurityAssessmentMetadataResponse, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityAssessmentMetadataResponse: + """Create metadata information on an assessment type in a specific subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :param assessment_metadata: AssessmentMetadata object. Required. + :type assessment_metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_in_subscription( + self, + assessment_metadata_name: str, + assessment_metadata: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityAssessmentMetadataResponse: + """Create metadata information on an assessment type in a specific subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :param assessment_metadata: AssessmentMetadata object. Required. + :type assessment_metadata: 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: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_in_subscription( + self, + assessment_metadata_name: str, + assessment_metadata: Union[_models.SecurityAssessmentMetadataResponse, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityAssessmentMetadataResponse: + """Create metadata information on an assessment type in a specific subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :param assessment_metadata: AssessmentMetadata object. Is either a + SecurityAssessmentMetadataResponse type or a IO[bytes] type. Required. + :type assessment_metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse or + IO[bytes] + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :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", "2025-05-04-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment_metadata, (IOBase, bytes)): + _content = assessment_metadata + else: + _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadataResponse") + + _request = build_create_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_in_subscription(self, assessment_metadata_name: str, **kwargs: Any) -> None: + """Delete metadata information on an assessment type in a specific subscription, will cause the + deletion of all the assessments of that type in that subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_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", "2025-05-04-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_assessments_operations.py new file mode 100644 index 000000000000..220af1b63565 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_assessments_operations.py @@ -0,0 +1,371 @@ +# 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 + +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._assessments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`assessments` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.SecurityAssessmentResponse"]: + """Get security assessments on all your scanned resources inside a scope. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either SecurityAssessmentResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityAssessmentResponse] + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityAssessmentList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_id: str, + assessment_name: str, + expand: Optional[Union[str, _models.ExpandEnum]] = None, + **kwargs: Any + ) -> _models.SecurityAssessmentResponse: + """Get a security assessment on your scanned resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param expand: OData expand. Optional. Known values are: "links" and "metadata". Default value + is None. + :type expand: str or ~azure.mgmt.security.models.ExpandEnum + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentResponse + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + assessment_name=assessment_name, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentResponse", 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_id: str, + assessment_name: str, + assessment: _models.SecurityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityAssessmentResponse: + """Create a security assessment on your resource. An assessment metadata that describes this + assessment must be predefined with the same name before inserting the assessment result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. + :type assessment: ~azure.mgmt.security.models.SecurityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_id: str, + assessment_name: str, + assessment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityAssessmentResponse: + """Create a security assessment on your resource. An assessment metadata that describes this + assessment must be predefined with the same name before inserting the assessment result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. + :type assessment: 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: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_id: str, + assessment_name: str, + assessment: Union[_models.SecurityAssessment, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityAssessmentResponse: + """Create a security assessment on your resource. An assessment metadata that describes this + assessment must be predefined with the same name before inserting the assessment result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param assessment: Calculated assessment on a pre-defined assessment metadata. Is either a + SecurityAssessment type or a IO[bytes] type. Required. + :type assessment: ~azure.mgmt.security.models.SecurityAssessment or IO[bytes] + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentResponse + :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", "2025-05-04-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment, (IOBase, bytes)): + _content = assessment + else: + _json = self._serialize.body(assessment, "SecurityAssessment") + + _request = build_create_or_update_request( + resource_id=resource_id, + assessment_name=assessment_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentResponse", 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_id: str, assessment_name: str, **kwargs: Any) -> None: + """Delete a security assessment on your resource. An assessment metadata that describes this + assessment must be predefined with the same name before inserting the assessment result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_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", "2025-05-04-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_id=resource_id, + assessment_name=assessment_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_auto_provisioning_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_auto_provisioning_settings_operations.py new file mode 100644 index 000000000000..b53c1e829dd6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_auto_provisioning_settings_operations.py @@ -0,0 +1,284 @@ +# 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 + +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._auto_provisioning_settings_operations import ( + build_create_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AutoProvisioningSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`auto_provisioning_settings` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.AutoProvisioningSetting"]: + """Exposes the auto provisioning settings of the subscriptions. + + :return: An iterator like instance of either AutoProvisioningSetting or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AutoProvisioningSetting] + :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", "2017-08-01-preview")) + cls: ClsType[_models.AutoProvisioningSettingList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AutoProvisioningSettingList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, setting_name: str, **kwargs: Any) -> _models.AutoProvisioningSetting: + """Details of a specific setting. + + :param setting_name: Auto provisioning setting key. Required. + :type setting_name: str + :return: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting + :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", "2017-08-01-preview")) + cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoProvisioningSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + setting_name: str, + setting: _models.AutoProvisioningSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoProvisioningSetting: + """Details of a specific setting. + + :param setting_name: Auto provisioning setting key. Required. + :type setting_name: str + :param setting: Auto provisioning setting key. Required. + :type setting: ~azure.mgmt.security.models.AutoProvisioningSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, setting_name: str, setting: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AutoProvisioningSetting: + """Details of a specific setting. + + :param setting_name: Auto provisioning setting key. Required. + :type setting_name: str + :param setting: Auto provisioning setting key. Required. + :type setting: 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: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, setting_name: str, setting: Union[_models.AutoProvisioningSetting, IO[bytes]], **kwargs: Any + ) -> _models.AutoProvisioningSetting: + """Details of a specific setting. + + :param setting_name: Auto provisioning setting key. Required. + :type setting_name: str + :param setting: Auto provisioning setting key. Is either a AutoProvisioningSetting type or a + IO[bytes] type. Required. + :type setting: ~azure.mgmt.security.models.AutoProvisioningSetting or IO[bytes] + :return: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting + :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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IOBase, bytes)): + _content = setting + else: + _json = self._serialize.body(setting, "AutoProvisioningSetting") + + _request = build_create_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoProvisioningSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_automations_operations.py new file mode 100644 index 000000000000..b53a47af4bd9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_automations_operations.py @@ -0,0 +1,697 @@ +# 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 + +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._automations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, + build_validate_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AutomationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`automations` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.Automation"]: + """Lists all the security automations in the specified subscription. Use the 'nextLink' property + in the response to get the next page of security automations for the specified subscription. + + :return: An iterator like instance of either Automation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Automation] + :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", "2023-12-01-preview")) + cls: ClsType[_models.AutomationList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AutomationList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Automation"]: + """Lists all the security automations in the specified resource group. Use the 'nextLink' property + in the response to get the next page of security automations for the specified resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either Automation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Automation] + :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", "2023-12-01-preview")) + cls: ClsType[_models.AutomationList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AutomationList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_group_name: str, automation_name: str, **kwargs: Any) -> _models.Automation: + """Retrieves information about the model of a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :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", "2023-12-01-preview")) + cls: ClsType[_models.Automation] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + automation_name=automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Automation", 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, + automation_name: str, + automation: _models.Automation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Automation: + """Creates or updates a security automation. If a security automation is already created and a + subsequent request is issued for the same automation id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Required. + :type automation: ~azure.mgmt.security.models.Automation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + automation_name: str, + automation: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Automation: + """Creates or updates a security automation. If a security automation is already created and a + subsequent request is issued for the same automation id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Required. + :type automation: 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: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + automation_name: str, + automation: Union[_models.Automation, IO[bytes]], + **kwargs: Any + ) -> _models.Automation: + """Creates or updates a security automation. If a security automation is already created and a + subsequent request is issued for the same automation id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Is either a Automation type or a IO[bytes] + type. Required. + :type automation: ~azure.mgmt.security.models.Automation or IO[bytes] + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :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", "2023-12-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Automation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IOBase, bytes)): + _content = automation + else: + _json = self._serialize.body(automation, "Automation") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_name=automation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Automation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + automation_name: str, + automation: _models.AutomationUpdateModel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Automation: + """Updates a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The update model of security automation resource. Required. + :type automation: ~azure.mgmt.security.models.AutomationUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + automation_name: str, + automation: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Automation: + """Updates a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The update model of security automation resource. Required. + :type automation: 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: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + automation_name: str, + automation: Union[_models.AutomationUpdateModel, IO[bytes]], + **kwargs: Any + ) -> _models.Automation: + """Updates a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The update model of security automation resource. Is either a + AutomationUpdateModel type or a IO[bytes] type. Required. + :type automation: ~azure.mgmt.security.models.AutomationUpdateModel or IO[bytes] + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :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", "2023-12-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Automation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IOBase, bytes)): + _content = automation + else: + _json = self._serialize.body(automation, "AutomationUpdateModel") + + _request = build_update_request( + resource_group_name=resource_group_name, + automation_name=automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Automation", 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, automation_name: str, **kwargs: Any) -> None: + """Deletes a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_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", "2023-12-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + automation_name=automation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def validate( + self, + resource_group_name: str, + automation_name: str, + automation: _models.Automation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutomationValidationStatus: + """Validates the security automation model before create or update. Any validation errors are + returned to the client. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Required. + :type automation: ~azure.mgmt.security.models.Automation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AutomationValidationStatus or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutomationValidationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + automation_name: str, + automation: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutomationValidationStatus: + """Validates the security automation model before create or update. Any validation errors are + returned to the client. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Required. + :type automation: 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: AutomationValidationStatus or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutomationValidationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, + resource_group_name: str, + automation_name: str, + automation: Union[_models.Automation, IO[bytes]], + **kwargs: Any + ) -> _models.AutomationValidationStatus: + """Validates the security automation model before create or update. Any validation errors are + returned to the client. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Is either a Automation type or a IO[bytes] + type. Required. + :type automation: ~azure.mgmt.security.models.Automation or IO[bytes] + :return: AutomationValidationStatus or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutomationValidationStatus + :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", "2023-12-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutomationValidationStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IOBase, bytes)): + _content = automation + else: + _json = self._serialize.body(automation, "Automation") + + _request = build_validate_request( + resource_group_name=resource_group_name, + automation_name=automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutomationValidationStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_azure_dev_ops_orgs_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_azure_dev_ops_orgs_operations.py new file mode 100644 index 000000000000..6378fe16bfd4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_azure_dev_ops_orgs_operations.py @@ -0,0 +1,693 @@ +# 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 + +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._azure_dev_ops_orgs_operations import ( + build_create_or_update_request, + build_get_request, + build_list_available_request, + build_list_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AzureDevOpsOrgsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`azure_dev_ops_orgs` 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: SecurityCenterConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.AzureDevOpsOrgListResponse: + """Returns a list of all Azure DevOps organizations accessible by the user token consumed by the + connector. + + Returns a list of all Azure DevOps organizations accessible by the user token consumed by the + connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: AzureDevOpsOrgListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AzureDevOpsOrgListResponse + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) + + _request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AzureDevOpsOrg"]: + """Returns a list of Azure DevOps organizations onboarded to the connector. + + Returns a list of Azure DevOps organizations onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either AzureDevOpsOrg or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AzureDevOpsOrg] + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsOrgListResponse] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsOrgListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, org_name: str, **kwargs: Any + ) -> _models.AzureDevOpsOrg: + """Returns a monitored Azure DevOps organization resource. + + Returns a monitored Azure DevOps organization resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :return: AzureDevOpsOrg or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AzureDevOpsOrg + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsOrg", 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, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, 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", "2025-03-01")) + 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(azure_dev_ops_org, (IOBase, bytes)): + _content = azure_dev_ops_org + else: + _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: _models.AzureDevOpsOrg, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.models.AzureDevOpsOrg + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a + AzureDevOpsOrg type or a IO[bytes] type. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.models.AzureDevOpsOrg or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + azure_dev_ops_org=azure_dev_ops_org, + 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("AzureDevOpsOrg", 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.AzureDevOpsOrg].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AzureDevOpsOrg]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, 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", "2025-03-01")) + 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(azure_dev_ops_org, (IOBase, bytes)): + _content = azure_dev_ops_org + else: + _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: _models.AzureDevOpsOrg, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.models.AzureDevOpsOrg + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a + AzureDevOpsOrg type or a IO[bytes] type. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.models.AzureDevOpsOrg or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + azure_dev_ops_org=azure_dev_ops_org, + 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("AzureDevOpsOrg", 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.AzureDevOpsOrg].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AzureDevOpsOrg]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_azure_dev_ops_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_azure_dev_ops_projects_operations.py new file mode 100644 index 000000000000..80bc991c8f5c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_azure_dev_ops_projects_operations.py @@ -0,0 +1,660 @@ +# 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 + +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._azure_dev_ops_projects_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AzureDevOpsProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`azure_dev_ops_projects` 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: SecurityCenterConfiguration = 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, security_connector_name: str, org_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AzureDevOpsProject"]: + """Returns a list of Azure DevOps projects onboarded to the connector. + + Returns a list of Azure DevOps projects onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :return: An iterator like instance of either AzureDevOpsProject or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AzureDevOpsProject] + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsProjectListResponse] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsProjectListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any + ) -> _models.AzureDevOpsProject: + """Returns a monitored Azure DevOps project resource. + + Returns a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :return: AzureDevOpsProject or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AzureDevOpsProject + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsProject", 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, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, 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", "2025-03-01")) + 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(azure_dev_ops_project, (IOBase, bytes)): + _content = azure_dev_ops_project + else: + _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: _models.AzureDevOpsProject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.models.AzureDevOpsProject + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a + AzureDevOpsProject type or a IO[bytes] type. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.models.AzureDevOpsProject or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + azure_dev_ops_project=azure_dev_ops_project, + 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("AzureDevOpsProject", 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.AzureDevOpsProject].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AzureDevOpsProject]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, 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", "2025-03-01")) + 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(azure_dev_ops_project, (IOBase, bytes)): + _content = azure_dev_ops_project + else: + _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: _models.AzureDevOpsProject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.models.AzureDevOpsProject + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a + AzureDevOpsProject type or a IO[bytes] type. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.models.AzureDevOpsProject or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + azure_dev_ops_project=azure_dev_ops_project, + 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("AzureDevOpsProject", 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.AzureDevOpsProject].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AzureDevOpsProject]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_azure_dev_ops_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_azure_dev_ops_repos_operations.py new file mode 100644 index 000000000000..efd6e745423f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_azure_dev_ops_repos_operations.py @@ -0,0 +1,698 @@ +# 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 + +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._azure_dev_ops_repos_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AzureDevOpsReposOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`azure_dev_ops_repos` 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: SecurityCenterConfiguration = 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, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AzureDevOpsRepository"]: + """Returns a list of Azure DevOps repositories onboarded to the connector. + + Returns a list of Azure DevOps repositories onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :return: An iterator like instance of either AzureDevOpsRepository or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AzureDevOpsRepository] + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsRepositoryListResponse] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsRepositoryListResponse", 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.ErrorResponseAutoGenerated2, 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, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + **kwargs: Any + ) -> _models.AzureDevOpsRepository: + """Returns a monitored Azure DevOps repository resource. + + Returns a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :return: AzureDevOpsRepository or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AzureDevOpsRepository + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsRepository", 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, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, 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", "2025-03-01")) + 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(azure_dev_ops_repository, (IOBase, bytes)): + _content = azure_dev_ops_repository + else: + _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: _models.AzureDevOpsRepository, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: ~azure.mgmt.security.models.AzureDevOpsRepository + :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 AzureDevOpsRepository or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a + AzureDevOpsRepository type or a IO[bytes] type. Required. + :type azure_dev_ops_repository: ~azure.mgmt.security.models.AzureDevOpsRepository or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AzureDevOpsRepository or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + azure_dev_ops_repository=azure_dev_ops_repository, + 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("AzureDevOpsRepository", 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.AzureDevOpsRepository].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AzureDevOpsRepository]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, 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", "2025-03-01")) + 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(azure_dev_ops_repository, (IOBase, bytes)): + _content = azure_dev_ops_repository + else: + _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: _models.AzureDevOpsRepository, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: ~azure.mgmt.security.models.AzureDevOpsRepository + :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 AzureDevOpsRepository or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a + AzureDevOpsRepository type or a IO[bytes] type. Required. + :type azure_dev_ops_repository: ~azure.mgmt.security.models.AzureDevOpsRepository or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AzureDevOpsRepository or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + azure_dev_ops_repository=azure_dev_ops_repository, + 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("AzureDevOpsRepository", 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.AzureDevOpsRepository].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AzureDevOpsRepository]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_compliance_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_compliance_results_operations.py new file mode 100644 index 000000000000..849ab05b6e10 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_compliance_results_operations.py @@ -0,0 +1,174 @@ +# 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.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._compliance_results_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ComplianceResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`compliance_results` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.ComplianceResult"]: + """Security compliance results in the subscription. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either ComplianceResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ComplianceResult] + :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", "2017-08-01")) + cls: ClsType[_models.ComplianceResultList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ComplianceResultList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_id: str, compliance_result_name: str, **kwargs: Any) -> _models.ComplianceResult: + """Security Compliance Result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param compliance_result_name: name of the desired assessment compliance result. Required. + :type compliance_result_name: str + :return: ComplianceResult or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ComplianceResult + :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", "2017-08-01")) + cls: ClsType[_models.ComplianceResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + compliance_result_name=compliance_result_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComplianceResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_compliances_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_compliances_operations.py new file mode 100644 index 000000000000..1ddbc6583920 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_compliances_operations.py @@ -0,0 +1,176 @@ +# 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.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._compliances_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CompliancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`compliances` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.Compliance"]: + """The Compliance scores of the specific management group. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either Compliance or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Compliance] + :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", "2017-08-01-preview")) + cls: ClsType[_models.ComplianceList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ComplianceList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, scope: str, compliance_name: str, **kwargs: Any) -> _models.Compliance: + """Details of a specific Compliance. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param compliance_name: name of the Compliance. Required. + :type compliance_name: str + :return: Compliance or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Compliance + :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", "2017-08-01-preview")) + cls: ClsType[_models.Compliance] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + compliance_name=compliance_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Compliance", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_connectors_operations.py new file mode 100644 index 000000000000..421bb631437c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_connectors_operations.py @@ -0,0 +1,341 @@ +# 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 + +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._connectors_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConnectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`connectors` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.ConnectorSetting"]: + """Cloud accounts connectors of a subscription. + + :return: An iterator like instance of either ConnectorSetting or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ConnectorSetting] + :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", "2020-01-01-preview")) + cls: ClsType[_models.ConnectorSettingList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectorSettingList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, connector_name: str, **kwargs: Any) -> _models.ConnectorSetting: + """Details of a specific cloud account connector. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_name: str + :return: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ConnectorSetting + :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", "2020-01-01-preview")) + cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + connector_name=connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectorSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + connector_name: str, + connector_setting: _models.ConnectorSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectorSetting: + """Create a cloud account connector or update an existing one. Connect to your cloud account. For + AWS, use either account credentials or role-based authentication. For GCP, use account + organization credentials. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_name: str + :param connector_setting: Settings for the cloud account connector. Required. + :type connector_setting: ~azure.mgmt.security.models.ConnectorSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ConnectorSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + connector_name: str, + connector_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectorSetting: + """Create a cloud account connector or update an existing one. Connect to your cloud account. For + AWS, use either account credentials or role-based authentication. For GCP, use account + organization credentials. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_name: str + :param connector_setting: Settings for the cloud account connector. Required. + :type connector_setting: 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: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ConnectorSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, connector_name: str, connector_setting: Union[_models.ConnectorSetting, IO[bytes]], **kwargs: Any + ) -> _models.ConnectorSetting: + """Create a cloud account connector or update an existing one. Connect to your cloud account. For + AWS, use either account credentials or role-based authentication. For GCP, use account + organization credentials. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_name: str + :param connector_setting: Settings for the cloud account connector. Is either a + ConnectorSetting type or a IO[bytes] type. Required. + :type connector_setting: ~azure.mgmt.security.models.ConnectorSetting or IO[bytes] + :return: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ConnectorSetting + :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", "2020-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connector_setting, (IOBase, bytes)): + _content = connector_setting + else: + _json = self._serialize.body(connector_setting, "ConnectorSetting") + + _request = build_create_or_update_request( + connector_name=connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectorSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, connector_name: str, **kwargs: Any) -> None: + """Delete a cloud account connector from a subscription. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_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", "2020-01-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + connector_name=connector_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_custom_assessment_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_custom_assessment_automations_operations.py new file mode 100644 index 000000000000..02e26c0342e0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_custom_assessment_automations_operations.py @@ -0,0 +1,455 @@ +# 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 + +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._custom_assessment_automations_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CustomAssessmentAutomationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`custom_assessment_automations` 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: SecurityCenterConfiguration = 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, custom_assessment_automation_name: str, **kwargs: Any + ) -> _models.CustomAssessmentAutomation: + """Gets a custom assessment automation. + + Gets a single custom assessment automation by name for the provided subscription and resource + group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_name: str + :return: CustomAssessmentAutomation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomAssessmentAutomation + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + custom_assessment_automation_name=custom_assessment_automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomAssessmentAutomation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + custom_assessment_automation_name: str, + custom_assessment_automation_body: _models.CustomAssessmentAutomationRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomAssessmentAutomation: + """Creates a custom assessment automation. + + Creates or updates a custom assessment automation for the provided subscription. Please note + that providing an existing custom assessment automation will replace the existing record. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_name: str + :param custom_assessment_automation_body: Custom Assessment Automation body. Required. + :type custom_assessment_automation_body: + ~azure.mgmt.security.models.CustomAssessmentAutomationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CustomAssessmentAutomation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomAssessmentAutomation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + custom_assessment_automation_name: str, + custom_assessment_automation_body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomAssessmentAutomation: + """Creates a custom assessment automation. + + Creates or updates a custom assessment automation for the provided subscription. Please note + that providing an existing custom assessment automation will replace the existing record. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_name: str + :param custom_assessment_automation_body: Custom Assessment Automation body. Required. + :type custom_assessment_automation_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: CustomAssessmentAutomation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomAssessmentAutomation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + custom_assessment_automation_name: str, + custom_assessment_automation_body: Union[_models.CustomAssessmentAutomationRequest, IO[bytes]], + **kwargs: Any + ) -> _models.CustomAssessmentAutomation: + """Creates a custom assessment automation. + + Creates or updates a custom assessment automation for the provided subscription. Please note + that providing an existing custom assessment automation will replace the existing record. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_name: str + :param custom_assessment_automation_body: Custom Assessment Automation body. Is either a + CustomAssessmentAutomationRequest type or a IO[bytes] type. Required. + :type custom_assessment_automation_body: + ~azure.mgmt.security.models.CustomAssessmentAutomationRequest or IO[bytes] + :return: CustomAssessmentAutomation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomAssessmentAutomation + :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", "2021-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(custom_assessment_automation_body, (IOBase, bytes)): + _content = custom_assessment_automation_body + else: + _json = self._serialize.body(custom_assessment_automation_body, "CustomAssessmentAutomationRequest") + + _request = build_create_request( + resource_group_name=resource_group_name, + custom_assessment_automation_name=custom_assessment_automation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomAssessmentAutomation", 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, custom_assessment_automation_name: str, **kwargs: Any) -> None: + """Deletes a custom assessment automation. + + Deletes a custom assessment automation by name for a provided subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_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", "2021-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + custom_assessment_automation_name=custom_assessment_automation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CustomAssessmentAutomation"]: + """List custom assessment automations in a subscription and a resource group. + + List custom assessment automations by provided subscription and resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either CustomAssessmentAutomation or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.CustomAssessmentAutomation] + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomAssessmentAutomationsListResult] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CustomAssessmentAutomationsListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.CustomAssessmentAutomation"]: + """List custom assessment automations in a subscription. + + List custom assessment automations by provided subscription. + + :return: An iterator like instance of either CustomAssessmentAutomation or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.CustomAssessmentAutomation] + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomAssessmentAutomationsListResult] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CustomAssessmentAutomationsListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_custom_entity_store_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_custom_entity_store_assignments_operations.py new file mode 100644 index 000000000000..ac9b8b6c9b9c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_custom_entity_store_assignments_operations.py @@ -0,0 +1,461 @@ +# 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 + +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._custom_entity_store_assignments_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CustomEntityStoreAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`custom_entity_store_assignments` 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: SecurityCenterConfiguration = 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, custom_entity_store_assignment_name: str, **kwargs: Any + ) -> _models.CustomEntityStoreAssignment: + """Gets a custom entity store assignment. + + Gets a single custom entity store assignment by name for the provided subscription and resource + group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_name: str + :return: CustomEntityStoreAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomEntityStoreAssignment + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + custom_entity_store_assignment_name=custom_entity_store_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomEntityStoreAssignment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + custom_entity_store_assignment_name: str, + custom_entity_store_assignment_request_body: _models.CustomEntityStoreAssignmentRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomEntityStoreAssignment: + """Creates a custom entity store assignment. + + Creates a custom entity store assignment for the provided subscription, if not already exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_name: str + :param custom_entity_store_assignment_request_body: Custom entity store assignment body. + Required. + :type custom_entity_store_assignment_request_body: + ~azure.mgmt.security.models.CustomEntityStoreAssignmentRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CustomEntityStoreAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomEntityStoreAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + custom_entity_store_assignment_name: str, + custom_entity_store_assignment_request_body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomEntityStoreAssignment: + """Creates a custom entity store assignment. + + Creates a custom entity store assignment for the provided subscription, if not already exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_name: str + :param custom_entity_store_assignment_request_body: Custom entity store assignment body. + Required. + :type custom_entity_store_assignment_request_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: CustomEntityStoreAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomEntityStoreAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + custom_entity_store_assignment_name: str, + custom_entity_store_assignment_request_body: Union[_models.CustomEntityStoreAssignmentRequest, IO[bytes]], + **kwargs: Any + ) -> _models.CustomEntityStoreAssignment: + """Creates a custom entity store assignment. + + Creates a custom entity store assignment for the provided subscription, if not already exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_name: str + :param custom_entity_store_assignment_request_body: Custom entity store assignment body. Is + either a CustomEntityStoreAssignmentRequest type or a IO[bytes] type. Required. + :type custom_entity_store_assignment_request_body: + ~azure.mgmt.security.models.CustomEntityStoreAssignmentRequest or IO[bytes] + :return: CustomEntityStoreAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomEntityStoreAssignment + :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", "2021-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(custom_entity_store_assignment_request_body, (IOBase, bytes)): + _content = custom_entity_store_assignment_request_body + else: + _json = self._serialize.body( + custom_entity_store_assignment_request_body, "CustomEntityStoreAssignmentRequest" + ) + + _request = build_create_request( + resource_group_name=resource_group_name, + custom_entity_store_assignment_name=custom_entity_store_assignment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomEntityStoreAssignment", 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, custom_entity_store_assignment_name: str, **kwargs: Any) -> None: + """Deleted a custom entity store assignment. + + Delete a custom entity store assignment by name for a provided subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_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", "2021-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + custom_entity_store_assignment_name=custom_entity_store_assignment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CustomEntityStoreAssignment"]: + """List custom entity store assignments in a subscription and a resource group. + + List custom entity store assignments by a provided subscription and resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either CustomEntityStoreAssignment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.CustomEntityStoreAssignment] + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CustomEntityStoreAssignmentsListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.CustomEntityStoreAssignment"]: + """List custom entity store assignments in a subscription. + + List custom entity store assignments by provided subscription. + + :return: An iterator like instance of either CustomEntityStoreAssignment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.CustomEntityStoreAssignment] + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CustomEntityStoreAssignmentsListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_custom_recommendations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_custom_recommendations_operations.py new file mode 100644 index 000000000000..077c436ebe18 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_custom_recommendations_operations.py @@ -0,0 +1,384 @@ +# 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 + +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._custom_recommendations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CustomRecommendationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`custom_recommendations` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.CustomRecommendation"]: + """Get a list of all relevant custom recommendations over a scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :return: An iterator like instance of either CustomRecommendation or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.CustomRecommendation] + :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", "2024-08-01")) + cls: ClsType[_models.CustomRecommendationsList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CustomRecommendationsList", 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, scope: str, custom_recommendation_name: str, **kwargs: Any) -> _models.CustomRecommendation: + """Get a specific custom recommendation for the requested scope by customRecommendationName. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_name: str + :return: CustomRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomRecommendation + :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", "2024-08-01")) + cls: ClsType[_models.CustomRecommendation] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + custom_recommendation_name=custom_recommendation_name, + 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("CustomRecommendation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + scope: str, + custom_recommendation_name: str, + custom_recommendation_body: _models.CustomRecommendation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomRecommendation: + """Creates or updates a custom recommendation over a given scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_name: str + :param custom_recommendation_body: Custom Recommendation body. Required. + :type custom_recommendation_body: ~azure.mgmt.security.models.CustomRecommendation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CustomRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomRecommendation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + scope: str, + custom_recommendation_name: str, + custom_recommendation_body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomRecommendation: + """Creates or updates a custom recommendation over a given scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_name: str + :param custom_recommendation_body: Custom Recommendation body. Required. + :type custom_recommendation_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: CustomRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomRecommendation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + scope: str, + custom_recommendation_name: str, + custom_recommendation_body: Union[_models.CustomRecommendation, IO[bytes]], + **kwargs: Any + ) -> _models.CustomRecommendation: + """Creates or updates a custom recommendation over a given scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_name: str + :param custom_recommendation_body: Custom Recommendation body. Is either a CustomRecommendation + type or a IO[bytes] type. Required. + :type custom_recommendation_body: ~azure.mgmt.security.models.CustomRecommendation or IO[bytes] + :return: CustomRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomRecommendation + :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", "2024-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomRecommendation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(custom_recommendation_body, (IOBase, bytes)): + _content = custom_recommendation_body + else: + _json = self._serialize.body(custom_recommendation_body, "CustomRecommendation") + + _request = build_create_or_update_request( + scope=scope, + custom_recommendation_name=custom_recommendation_name, + 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("CustomRecommendation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, scope: str, custom_recommendation_name: str, **kwargs: Any) -> None: + """Delete a custom recommendation over a given scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_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", "2024-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope=scope, + custom_recommendation_name=custom_recommendation_name, + 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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_defender_for_storage_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_defender_for_storage_operations.py new file mode 100644 index 000000000000..bdfadcf69ca3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_defender_for_storage_operations.py @@ -0,0 +1,412 @@ +# 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 + +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._defender_for_storage_operations import ( + build_cancel_malware_scan_request, + build_create_request, + build_get_malware_scan_request, + build_get_request, + build_start_malware_scan_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DefenderForStorageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`defender_for_storage` 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: SecurityCenterConfiguration = 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_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Gets the Defender for Storage settings for the specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DefenderForStorageSetting + :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", "2025-02-01-preview")) + cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + setting_name=setting_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: _models.DefenderForStorageSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Required. + :type defender_for_storage_setting: ~azure.mgmt.security.models.DefenderForStorageSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Required. + :type defender_for_storage_setting: 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: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: Union[_models.DefenderForStorageSetting, IO[bytes]], + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Is either a + DefenderForStorageSetting type or a IO[bytes] type. Required. + :type defender_for_storage_setting: ~azure.mgmt.security.models.DefenderForStorageSetting or + IO[bytes] + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DefenderForStorageSetting + :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", "2025-02-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(defender_for_storage_setting, (IOBase, bytes)): + _content = defender_for_storage_setting + else: + _json = self._serialize.body(defender_for_storage_setting, "DefenderForStorageSetting") + + _request = build_create_request( + resource_id=resource_id, + setting_name=setting_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def start_malware_scan( + self, resource_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any + ) -> _models.MalwareScan: + """Initiate a Defender for Storage malware scan for the specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :return: MalwareScan or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MalwareScan + :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", "2025-02-01-preview")) + cls: ClsType[_models.MalwareScan] = kwargs.pop("cls", None) + + _request = build_start_malware_scan_request( + resource_id=resource_id, + setting_name=setting_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MalwareScan", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def cancel_malware_scan( + self, resource_id: str, setting_name: Union[str, _models.SettingName], scan_id: str, **kwargs: Any + ) -> _models.MalwareScan: + """Cancels a Defender for Storage malware scan for the specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param scan_id: The identifier of the scan. Can be either 'latest' or a GUID. Required. + :type scan_id: str + :return: MalwareScan or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MalwareScan + :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", "2025-02-01-preview")) + cls: ClsType[_models.MalwareScan] = kwargs.pop("cls", None) + + _request = build_cancel_malware_scan_request( + resource_id=resource_id, + setting_name=setting_name, + scan_id=scan_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MalwareScan", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_malware_scan( + self, resource_id: str, setting_name: Union[str, _models.SettingName], scan_id: str, **kwargs: Any + ) -> _models.MalwareScan: + """Gets the Defender for Storage malware scan for the specified storage resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param scan_id: The identifier of the scan. Can be either 'latest' or a GUID. Required. + :type scan_id: str + :return: MalwareScan or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MalwareScan + :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", "2025-02-01-preview")) + cls: ClsType[_models.MalwareScan] = kwargs.pop("cls", None) + + _request = build_get_malware_scan_request( + resource_id=resource_id, + setting_name=setting_name, + scan_id=scan_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MalwareScan", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_dev_ops_configurations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_dev_ops_configurations_operations.py new file mode 100644 index 000000000000..ceddf6d45a7b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_dev_ops_configurations_operations.py @@ -0,0 +1,713 @@ +# 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 + +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._dev_ops_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DevOpsConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`dev_ops_configurations` 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: SecurityCenterConfiguration = 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, security_connector_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DevOpsConfiguration"]: + """List DevOps Configurations. + + List DevOps Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either DevOpsConfiguration or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.DevOpsConfiguration] + :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", "2025-03-01")) + cls: ClsType[_models.DevOpsConfigurationListResponse] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DevOpsConfigurationListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, **kwargs: Any + ) -> _models.DevOpsConfiguration: + """Gets a DevOps Configuration. + + Gets a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: DevOpsConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DevOpsConfiguration + :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", "2025-03-01")) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DevOpsConfiguration", 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, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, 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", "2025-03-01")) + 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(dev_ops_configuration, (IOBase, bytes)): + _content = dev_ops_configuration + else: + _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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, 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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: _models.DevOpsConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: ~azure.mgmt.security.models.DevOpsConfiguration + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: 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 DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Is either a + DevOpsConfiguration type or a IO[bytes] type. Required. + :type dev_ops_configuration: ~azure.mgmt.security.models.DevOpsConfiguration or IO[bytes] + :return: An instance of AsyncLROPoller that returns either DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = 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, + security_connector_name=security_connector_name, + dev_ops_configuration=dev_ops_configuration, + 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("DevOpsConfiguration", 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.DevOpsConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DevOpsConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, 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", "2025-03-01")) + 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(dev_ops_configuration, (IOBase, bytes)): + _content = dev_ops_configuration + else: + _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: _models.DevOpsConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: ~azure.mgmt.security.models.DevOpsConfiguration + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: 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 DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Is either a + DevOpsConfiguration type or a IO[bytes] type. Required. + :type dev_ops_configuration: ~azure.mgmt.security.models.DevOpsConfiguration or IO[bytes] + :return: An instance of AsyncLROPoller that returns either DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = 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, + security_connector_name=security_connector_name, + dev_ops_configuration=dev_ops_configuration, + 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("DevOpsConfiguration", 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.DevOpsConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DevOpsConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, security_connector_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", "2025-03-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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 [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a DevOps Connector. + + Deletes a DevOps Connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_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", "2025-03-01")) + 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, + security_connector_name=security_connector_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_dev_ops_operation_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_dev_ops_operation_results_operations.py new file mode 100644 index 000000000000..81f0b7130326 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_dev_ops_operation_results_operations.py @@ -0,0 +1,115 @@ +# 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._dev_ops_operation_results_operations import build_get_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DevOpsOperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`dev_ops_operation_results` 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: SecurityCenterConfiguration = 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, security_connector_name: str, operation_result_id: str, **kwargs: Any + ) -> _models.OperationStatusResult: + """Get devops long running operation result. + + Get devops long running operation result. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param operation_result_id: The operation result Id. Required. + :type operation_result_id: str + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.security.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", "2025-03-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + operation_result_id=operation_result_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.ErrorResponseAutoGenerated2, 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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_device_security_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_device_security_groups_operations.py new file mode 100644 index 000000000000..755899c73e92 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_device_security_groups_operations.py @@ -0,0 +1,364 @@ +# 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 + +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._device_security_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeviceSecurityGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`device_security_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SecurityCenterConfiguration = 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_id: str, **kwargs: Any) -> AsyncItemPaged["_models.DeviceSecurityGroup"]: + """Use this method get the list of device security groups for the specified IoT Hub resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: An iterator like instance of either DeviceSecurityGroup or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.DeviceSecurityGroup] + :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", "2019-08-01")) + cls: ClsType[_models.DeviceSecurityGroupList] = 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_id=resource_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeviceSecurityGroupList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_id: str, device_security_group_name: str, **kwargs: Any + ) -> _models.DeviceSecurityGroup: + """Use this method to get the device security group for the specified IoT Hub resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_name: str + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup + :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", "2019-08-01")) + cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeviceSecurityGroup", 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_id: str, + device_security_group_name: str, + device_security_group: _models.DeviceSecurityGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeviceSecurityGroup: + """Use this method to creates or updates the device security group on a specified IoT Hub + resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_name: str + :param device_security_group: Security group object. Required. + :type device_security_group: ~azure.mgmt.security.models.DeviceSecurityGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_id: str, + device_security_group_name: str, + device_security_group: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeviceSecurityGroup: + """Use this method to creates or updates the device security group on a specified IoT Hub + resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_name: str + :param device_security_group: Security group object. Required. + :type device_security_group: 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: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_id: str, + device_security_group_name: str, + device_security_group: Union[_models.DeviceSecurityGroup, IO[bytes]], + **kwargs: Any + ) -> _models.DeviceSecurityGroup: + """Use this method to creates or updates the device security group on a specified IoT Hub + resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_name: str + :param device_security_group: Security group object. Is either a DeviceSecurityGroup type or a + IO[bytes] type. Required. + :type device_security_group: ~azure.mgmt.security.models.DeviceSecurityGroup or IO[bytes] + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup + :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", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(device_security_group, (IOBase, bytes)): + _content = device_security_group + else: + _json = self._serialize.body(device_security_group, "DeviceSecurityGroup") + + _request = build_create_or_update_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeviceSecurityGroup", 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_id: str, device_security_group_name: str, **kwargs: Any) -> None: + """User this method to deletes the device security group. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_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", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_discovered_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_discovered_security_solutions_operations.py new file mode 100644 index 000000000000..988b182bcc78 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_discovered_security_solutions_operations.py @@ -0,0 +1,255 @@ +# 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.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._discovered_security_solutions_operations import ( + build_get_request, + build_list_by_home_region_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DiscoveredSecuritySolutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`discovered_security_solutions` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.DiscoveredSecuritySolution"]: + """Gets a list of discovered Security Solutions for the subscription. + + :return: An iterator like instance of either DiscoveredSecuritySolution or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.DiscoveredSecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.DiscoveredSecuritySolutionList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiscoveredSecuritySolutionList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region( + self, asc_location: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DiscoveredSecuritySolution"]: + """Gets a list of discovered Security Solutions for the subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either DiscoveredSecuritySolution or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.DiscoveredSecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.DiscoveredSecuritySolutionList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiscoveredSecuritySolutionList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, asc_location: str, discovered_security_solution_name: str, **kwargs: Any + ) -> _models.DiscoveredSecuritySolution: + """Gets a specific discovered Security Solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param discovered_security_solution_name: Name of a discovered security solution. Required. + :type discovered_security_solution_name: str + :return: DiscoveredSecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DiscoveredSecuritySolution + :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", "2020-01-01")) + cls: ClsType[_models.DiscoveredSecuritySolution] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + discovered_security_solution_name=discovered_security_solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiscoveredSecuritySolution", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_external_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_external_security_solutions_operations.py new file mode 100644 index 000000000000..27b5477d2616 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_external_security_solutions_operations.py @@ -0,0 +1,255 @@ +# 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.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._external_security_solutions_operations import ( + build_get_request, + build_list_by_home_region_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ExternalSecuritySolutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`external_security_solutions` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.ExternalSecuritySolution"]: + """Gets a list of external security solutions for the subscription. + + :return: An iterator like instance of either ExternalSecuritySolution or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ExternalSecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.ExternalSecuritySolutionList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ExternalSecuritySolutionList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region( + self, asc_location: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ExternalSecuritySolution"]: + """Gets a list of external Security Solutions for the subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either ExternalSecuritySolution or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ExternalSecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.ExternalSecuritySolutionList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ExternalSecuritySolutionList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, asc_location: str, external_security_solutions_name: str, **kwargs: Any + ) -> _models.ExternalSecuritySolution: + """Gets a specific external Security Solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param external_security_solutions_name: Name of an external security solution. Required. + :type external_security_solutions_name: str + :return: ExternalSecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ExternalSecuritySolution + :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", "2020-01-01")) + cls: ClsType[_models.ExternalSecuritySolution] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + external_security_solutions_name=external_security_solutions_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ExternalSecuritySolution", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_hub_owners_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_hub_owners_operations.py new file mode 100644 index 000000000000..81e49b344ead --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_hub_owners_operations.py @@ -0,0 +1,252 @@ +# 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.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._git_hub_owners_operations import build_get_request, build_list_available_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitHubOwnersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`git_hub_owners` 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: SecurityCenterConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.GitHubOwnerListResponse: + """Returns a list of all GitHub owners accessible by the user token consumed by the connector. + + Returns a list of all GitHub owners accessible by the user token consumed by the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: GitHubOwnerListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitHubOwnerListResponse + :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", "2025-03-01")) + cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) + + _request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.GitHubOwner"]: + """Returns a list of GitHub owners onboarded to the connector. + + Returns a list of GitHub owners onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either GitHubOwner or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.GitHubOwner] + :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", "2025-03-01")) + cls: ClsType[_models.GitHubOwnerListResponse] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GitHubOwnerListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, owner_name: str, **kwargs: Any + ) -> _models.GitHubOwner: + """Returns a monitored GitHub owner. + + Returns a monitored GitHub owner. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :return: GitHubOwner or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitHubOwner + :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", "2025-03-01")) + cls: ClsType[_models.GitHubOwner] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubOwner", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_hub_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_hub_repos_operations.py new file mode 100644 index 000000000000..08d28dda80fd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_hub_repos_operations.py @@ -0,0 +1,198 @@ +# 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.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._git_hub_repos_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitHubReposOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`git_hub_repos` 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: SecurityCenterConfiguration = 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, security_connector_name: str, owner_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.GitHubRepository"]: + """Returns a list of GitHub repositories onboarded to the connector. + + Returns a list of GitHub repositories onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :return: An iterator like instance of either GitHubRepository or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.GitHubRepository] + :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", "2025-03-01")) + cls: ClsType[_models.GitHubRepositoryListResponse] = 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, + security_connector_name=security_connector_name, + owner_name=owner_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GitHubRepositoryListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, owner_name: str, repo_name: str, **kwargs: Any + ) -> _models.GitHubRepository: + """Returns a monitored GitHub repository. + + Returns a monitored GitHub repository. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :return: GitHubRepository or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitHubRepository + :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", "2025-03-01")) + cls: ClsType[_models.GitHubRepository] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_name, + repo_name=repo_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubRepository", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_lab_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_lab_groups_operations.py new file mode 100644 index 000000000000..a294c73b4ed4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_lab_groups_operations.py @@ -0,0 +1,252 @@ +# 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.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._git_lab_groups_operations import build_get_request, build_list_available_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitLabGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`git_lab_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SecurityCenterConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.GitLabGroupListResponse: + """Returns a list of all GitLab groups accessible by the user token consumed by the connector. + + Returns a list of all GitLab groups accessible by the user token consumed by the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: GitLabGroupListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitLabGroupListResponse + :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", "2025-03-01")) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + _request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.GitLabGroup"]: + """Returns a list of GitLab groups onboarded to the connector. + + Returns a list of GitLab groups onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either GitLabGroup or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.GitLabGroup] + :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", "2025-03-01")) + cls: ClsType[_models.GitLabGroupListResponse] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GitLabGroupListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> _models.GitLabGroup: + """Returns a monitored GitLab Group resource for a given fully-qualified name. + + Returns a monitored GitLab Group resource for a given fully-qualified name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :return: GitLabGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitLabGroup + :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", "2025-03-01")) + cls: ClsType[_models.GitLabGroup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_lab_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_lab_projects_operations.py new file mode 100644 index 000000000000..f15150b50d8a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_lab_projects_operations.py @@ -0,0 +1,207 @@ +# 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.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._git_lab_projects_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitLabProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`git_lab_projects` 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: SecurityCenterConfiguration = 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, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.GitLabProject"]: + """Gets a list of GitLab projects that are directly owned by given group and onboarded to the + connector. + + Gets a list of GitLab projects that are directly owned by given group and onboarded to the + connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :return: An iterator like instance of either GitLabProject or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.GitLabProject] + :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", "2025-03-01")) + cls: ClsType[_models.GitLabProjectListResponse] = 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, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GitLabProjectListResponse", 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.ErrorResponseAutoGenerated2, 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, + security_connector_name: str, + group_fq_name: str, + project_name: str, + **kwargs: Any + ) -> _models.GitLabProject: + """Returns a monitored GitLab Project resource for a given fully-qualified group name and project + name. + + Returns a monitored GitLab Project resource for a given fully-qualified group name and project + name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :param project_name: The project name. Required. + :type project_name: str + :return: GitLabProject or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitLabProject + :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", "2025-03-01")) + cls: ClsType[_models.GitLabProject] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + project_name=project_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabProject", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_lab_subgroups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_lab_subgroups_operations.py new file mode 100644 index 000000000000..81a2cf27225f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_git_lab_subgroups_operations.py @@ -0,0 +1,115 @@ +# 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._git_lab_subgroups_operations import build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitLabSubgroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`git_lab_subgroups` 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: SecurityCenterConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> _models.GitLabGroupListResponse: + """Gets nested subgroups of given GitLab Group which are onboarded to the connector. + + Gets nested subgroups of given GitLab Group which are onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :return: GitLabGroupListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitLabGroupListResponse + :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", "2025-03-01")) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_governance_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_governance_assignments_operations.py new file mode 100644 index 000000000000..fe548dceb79a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_governance_assignments_operations.py @@ -0,0 +1,400 @@ +# 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 + +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._governance_assignments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GovernanceAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`governance_assignments` 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: SecurityCenterConfiguration = 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, scope: str, assessment_name: str, **kwargs: Any) -> AsyncItemPaged["_models.GovernanceAssignment"]: + """Get governance assignments on all of your resources inside a scope. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :return: An iterator like instance of either GovernanceAssignment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.GovernanceAssignment] + :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", "2022-01-01-preview")) + cls: ClsType[_models.GovernanceAssignmentsList] = 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( + scope=scope, + assessment_name=assessment_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GovernanceAssignmentsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, scope: str, assessment_name: str, assignment_key: str, **kwargs: Any + ) -> _models.GovernanceAssignment: + """Get a specific governanceAssignment for the requested scope by AssignmentKey. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: str + :return: GovernanceAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceAssignment + :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", "2022-01-01-preview")) + cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + assessment_name=assessment_name, + assignment_key=assignment_key, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GovernanceAssignment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + scope: str, + assessment_name: str, + assignment_key: str, + governance_assignment: _models.GovernanceAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GovernanceAssignment: + """Creates or updates a governance assignment on the given subscription. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: str + :param governance_assignment: Governance assignment over a subscription scope. Required. + :type governance_assignment: ~azure.mgmt.security.models.GovernanceAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GovernanceAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + scope: str, + assessment_name: str, + assignment_key: str, + governance_assignment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GovernanceAssignment: + """Creates or updates a governance assignment on the given subscription. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: str + :param governance_assignment: Governance assignment over a subscription scope. Required. + :type governance_assignment: 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: GovernanceAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + scope: str, + assessment_name: str, + assignment_key: str, + governance_assignment: Union[_models.GovernanceAssignment, IO[bytes]], + **kwargs: Any + ) -> _models.GovernanceAssignment: + """Creates or updates a governance assignment on the given subscription. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: str + :param governance_assignment: Governance assignment over a subscription scope. Is either a + GovernanceAssignment type or a IO[bytes] type. Required. + :type governance_assignment: ~azure.mgmt.security.models.GovernanceAssignment or IO[bytes] + :return: GovernanceAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceAssignment + :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", "2022-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(governance_assignment, (IOBase, bytes)): + _content = governance_assignment + else: + _json = self._serialize.body(governance_assignment, "GovernanceAssignment") + + _request = build_create_or_update_request( + scope=scope, + assessment_name=assessment_name, + assignment_key=assignment_key, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GovernanceAssignment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, scope: str, assessment_name: str, assignment_key: str, **kwargs: Any) -> None: + """Delete a GovernanceAssignment over a given scope. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: 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", "2022-01-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope=scope, + assessment_name=assessment_name, + assignment_key=assignment_key, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_governance_rules_operations.py new file mode 100644 index 000000000000..1d9e2b35a01d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_governance_rules_operations.py @@ -0,0 +1,718 @@ +# 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, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +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._governance_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_execute_request, + build_get_request, + build_list_request, + build_operation_results_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GovernanceRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`governance_rules` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.GovernanceRule"]: + """Get a list of all relevant governance rules over a scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :return: An iterator like instance of either GovernanceRule or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.GovernanceRule] + :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", "2022-01-01-preview")) + cls: ClsType[_models.GovernanceRuleList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GovernanceRuleList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, scope: str, rule_id: str, **kwargs: Any) -> _models.GovernanceRule: + """Get a specific governance rule for the requested scope by ruleId. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :return: GovernanceRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceRule + :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", "2022-01-01-preview")) + cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + rule_id=rule_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GovernanceRule", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + scope: str, + rule_id: str, + governance_rule: _models.GovernanceRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GovernanceRule: + """Creates or updates a governance rule over a given scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param governance_rule: Governance rule over a given scope. Required. + :type governance_rule: ~azure.mgmt.security.models.GovernanceRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GovernanceRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + scope: str, + rule_id: str, + governance_rule: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GovernanceRule: + """Creates or updates a governance rule over a given scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param governance_rule: Governance rule over a given scope. Required. + :type governance_rule: 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: GovernanceRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, scope: str, rule_id: str, governance_rule: Union[_models.GovernanceRule, IO[bytes]], **kwargs: Any + ) -> _models.GovernanceRule: + """Creates or updates a governance rule over a given scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param governance_rule: Governance rule over a given scope. Is either a GovernanceRule type or + a IO[bytes] type. Required. + :type governance_rule: ~azure.mgmt.security.models.GovernanceRule or IO[bytes] + :return: GovernanceRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceRule + :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", "2022-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(governance_rule, (IOBase, bytes)): + _content = governance_rule + else: + _json = self._serialize.body(governance_rule, "GovernanceRule") + + _request = build_create_or_update_request( + scope=scope, + rule_id=rule_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GovernanceRule", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial(self, scope: str, rule_id: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope=scope, + rule_id=rule_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 [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, scope: str, rule_id: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a Governance rule over a given scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: 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", "2022-01-01-preview")) + 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( + scope=scope, + rule_id=rule_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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 _execute_initial( + self, + scope: str, + rule_id: str, + execute_governance_rule_params: Optional[Union[_models.ExecuteGovernanceRuleParams, 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + 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(execute_governance_rule_params, (IOBase, bytes)): + _content = execute_governance_rule_params + else: + if execute_governance_rule_params is not None: + _json = self._serialize.body(execute_governance_rule_params, "ExecuteGovernanceRuleParams") + else: + _json = None + + _request = build_execute_request( + scope=scope, + rule_id=rule_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 [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + 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_execute( + self, + scope: str, + rule_id: str, + execute_governance_rule_params: Optional[_models.ExecuteGovernanceRuleParams] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Execute a governance rule. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param execute_governance_rule_params: Execute governance rule over a given scope. Default + value is None. + :type execute_governance_rule_params: ~azure.mgmt.security.models.ExecuteGovernanceRuleParams + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_execute( + self, + scope: str, + rule_id: str, + execute_governance_rule_params: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Execute a governance rule. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param execute_governance_rule_params: Execute governance rule over a given scope. Default + value is None. + :type execute_governance_rule_params: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_execute( + self, + scope: str, + rule_id: str, + execute_governance_rule_params: Optional[Union[_models.ExecuteGovernanceRuleParams, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Execute a governance rule. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param execute_governance_rule_params: Execute governance rule over a given scope. Is either a + ExecuteGovernanceRuleParams type or a IO[bytes] type. Default value is None. + :type execute_governance_rule_params: ~azure.mgmt.security.models.ExecuteGovernanceRuleParams + or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._execute_initial( + scope=scope, + rule_id=rule_id, + execute_governance_rule_params=execute_governance_rule_params, + 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): # 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_async + async def operation_results( + self, scope: str, rule_id: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.OperationResultAutoGenerated]: + """Get governance rules long run operation result for the requested scope by ruleId and + operationId. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param operation_id: The governance rule long running operation unique key. Required. + :type operation_id: str + :return: OperationResultAutoGenerated or None or the result of cls(response) + :rtype: ~azure.mgmt.security.models.OperationResultAutoGenerated or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + cls: ClsType[Optional[_models.OperationResultAutoGenerated]] = kwargs.pop("cls", None) + + _request = build_operation_results_request( + scope=scope, + rule_id=rule_id, + operation_id=operation_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationResultAutoGenerated", pipeline_response.http_response) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_health_reports_operations.py new file mode 100644 index 000000000000..ab1928343eb2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_health_reports_operations.py @@ -0,0 +1,178 @@ +# 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 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._health_reports_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HealthReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`health_reports` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.HealthReport"]: + """Get a list of all health reports inside a scope. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + + :param scope: The scope at which the operation is performed. Required. + :type scope: str + :return: An iterator like instance of either HealthReport or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.HealthReport] + :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", "2023-05-01-preview")) + cls: ClsType[_models.HealthReportsList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("HealthReportsList", 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_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: + """Get health report of resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param health_report_name: The health report Key - Unique key for the health report type. + Required. + :type health_report_name: str + :return: HealthReport or the result of cls(response) + :rtype: ~azure.mgmt.security.models.HealthReport + :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", "2023-05-01-preview")) + cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + health_report_name=health_report_name, + 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("HealthReport", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_information_protection_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_information_protection_policies_operations.py new file mode 100644 index 000000000000..dabf0821b572 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_information_protection_policies_operations.py @@ -0,0 +1,329 @@ +# 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 + +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._information_protection_policies_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class InformationProtectionPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`information_protection_policies` 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: SecurityCenterConfiguration = 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, + scope: str, + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], + **kwargs: Any + ) -> _models.InformationProtectionPolicy: + """Details of the information protection policy. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param information_protection_policy_name: Name of the information protection policy. Known + values are: "effective" and "custom". Required. + :type information_protection_policy_name: str or + ~azure.mgmt.security.models.InformationProtectionPolicyName + :return: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy + :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", "2017-08-01-preview")) + cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + information_protection_policy_name=information_protection_policy_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + scope: str, + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], + information_protection_policy: _models.InformationProtectionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.InformationProtectionPolicy: + """Details of the information protection policy. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param information_protection_policy_name: Name of the information protection policy. Known + values are: "effective" and "custom". Required. + :type information_protection_policy_name: str or + ~azure.mgmt.security.models.InformationProtectionPolicyName + :param information_protection_policy: Information protection policy. Required. + :type information_protection_policy: ~azure.mgmt.security.models.InformationProtectionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + scope: str, + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], + information_protection_policy: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.InformationProtectionPolicy: + """Details of the information protection policy. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param information_protection_policy_name: Name of the information protection policy. Known + values are: "effective" and "custom". Required. + :type information_protection_policy_name: str or + ~azure.mgmt.security.models.InformationProtectionPolicyName + :param information_protection_policy: Information protection policy. Required. + :type information_protection_policy: 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: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + scope: str, + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], + information_protection_policy: Union[_models.InformationProtectionPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.InformationProtectionPolicy: + """Details of the information protection policy. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param information_protection_policy_name: Name of the information protection policy. Known + values are: "effective" and "custom". Required. + :type information_protection_policy_name: str or + ~azure.mgmt.security.models.InformationProtectionPolicyName + :param information_protection_policy: Information protection policy. Is either a + InformationProtectionPolicy type or a IO[bytes] type. Required. + :type information_protection_policy: ~azure.mgmt.security.models.InformationProtectionPolicy or + IO[bytes] + :return: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy + :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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(information_protection_policy, (IOBase, bytes)): + _content = information_protection_policy + else: + _json = self._serialize.body(information_protection_policy, "InformationProtectionPolicy") + + _request = build_create_or_update_request( + scope=scope, + information_protection_policy_name=information_protection_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.InformationProtectionPolicy"]: + """Information protection policies of a specific management group. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either InformationProtectionPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.InformationProtectionPolicy] + :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", "2017-08-01-preview")) + cls: ClsType[_models.InformationProtectionPolicyList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("InformationProtectionPolicyList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solution_analytics_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solution_analytics_operations.py new file mode 100644 index 000000000000..baaa70f9c45e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solution_analytics_operations.py @@ -0,0 +1,166 @@ +# 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._iot_security_solution_analytics_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotSecuritySolutionAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`iot_security_solution_analytics` 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: SecurityCenterConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, resource_group_name: str, solution_name: str, **kwargs: Any + ) -> _models.IoTSecuritySolutionAnalyticsModelList: + """Use this method to get IoT security Analytics metrics in an array. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :return: IoTSecuritySolutionAnalyticsModelList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModelList + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionAnalyticsModelList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, solution_name: str, **kwargs: Any + ) -> _models.IoTSecuritySolutionAnalyticsModel: + """Use this method to get IoT Security Analytics metrics. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :return: IoTSecuritySolutionAnalyticsModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModel + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionAnalyticsModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionAnalyticsModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solution_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solution_operations.py new file mode 100644 index 000000000000..659c125ab7dc --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solution_operations.py @@ -0,0 +1,582 @@ +# 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 + +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._iot_security_solution_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotSecuritySolutionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`iot_security_solution` 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: SecurityCenterConfiguration = 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_by_subscription( + self, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.IoTSecuritySolutionModel"]: + """Use this method to get the list of IoT Security solutions by subscription. + + :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by + iotHubs. Default value is None. + :type filter: str + :return: An iterator like instance of either IoTSecuritySolutionModel or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.IoTSecuritySolutionModel] + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionsList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IoTSecuritySolutionsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.IoTSecuritySolutionModel"]: + """Use this method to get the list IoT Security solutions organized by resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by + iotHubs. Default value is None. + :type filter: str + :return: An iterator like instance of either IoTSecuritySolutionModel or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.IoTSecuritySolutionModel] + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionsList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IoTSecuritySolutionsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, solution_name: str, **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """User this method to get details of a specific IoT Security solution based on solution name. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionModel", 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, + solution_name: str, + iot_security_solution_data: _models.IoTSecuritySolutionModel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to create or update yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param iot_security_solution_data: The security solution data. Required. + :type iot_security_solution_data: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + solution_name: str, + iot_security_solution_data: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to create or update yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param iot_security_solution_data: The security solution data. Required. + :type iot_security_solution_data: 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: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + solution_name: str, + iot_security_solution_data: Union[_models.IoTSecuritySolutionModel, IO[bytes]], + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to create or update yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param iot_security_solution_data: The security solution data. Is either a + IoTSecuritySolutionModel type or a IO[bytes] type. Required. + :type iot_security_solution_data: ~azure.mgmt.security.models.IoTSecuritySolutionModel or + IO[bytes] + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :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", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_security_solution_data, (IOBase, bytes)): + _content = iot_security_solution_data + else: + _json = self._serialize.body(iot_security_solution_data, "IoTSecuritySolutionModel") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + solution_name=solution_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + solution_name: str, + update_iot_security_solution_data: _models.UpdateIotSecuritySolutionData, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to update existing IoT Security solution tags or user defined resources. To + update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param update_iot_security_solution_data: The security solution data. Required. + :type update_iot_security_solution_data: + ~azure.mgmt.security.models.UpdateIotSecuritySolutionData + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + solution_name: str, + update_iot_security_solution_data: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to update existing IoT Security solution tags or user defined resources. To + update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param update_iot_security_solution_data: The security solution data. Required. + :type update_iot_security_solution_data: 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: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + solution_name: str, + update_iot_security_solution_data: Union[_models.UpdateIotSecuritySolutionData, IO[bytes]], + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to update existing IoT Security solution tags or user defined resources. To + update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param update_iot_security_solution_data: The security solution data. Is either a + UpdateIotSecuritySolutionData type or a IO[bytes] type. Required. + :type update_iot_security_solution_data: + ~azure.mgmt.security.models.UpdateIotSecuritySolutionData or IO[bytes] + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :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", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_iot_security_solution_data, (IOBase, bytes)): + _content = update_iot_security_solution_data + else: + _json = self._serialize.body(update_iot_security_solution_data, "UpdateIotSecuritySolutionData") + + _request = build_update_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionModel", 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, solution_name: str, **kwargs: Any) -> None: + """Use this method to delete yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_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", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + solution_name=solution_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py new file mode 100644 index 000000000000..3bbc9b36bf65 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py @@ -0,0 +1,252 @@ +# 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.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._iot_security_solutions_analytics_aggregated_alert_operations import ( + build_dismiss_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotSecuritySolutionsAnalyticsAggregatedAlertOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`iot_security_solutions_analytics_aggregated_alert` 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: SecurityCenterConfiguration = 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, solution_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.IoTSecurityAggregatedAlert"]: + """Use this method to get the aggregated alert list of yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param top: Number of results to retrieve. Default value is None. + :type top: int + :return: An iterator like instance of either IoTSecurityAggregatedAlert or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.IoTSecurityAggregatedAlert] + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecurityAggregatedAlertList] = 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, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IoTSecurityAggregatedAlertList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, solution_name: str, aggregated_alert_name: str, **kwargs: Any + ) -> _models.IoTSecurityAggregatedAlert: + """Use this method to get a single the aggregated alert of yours IoT Security solution. This + aggregation is performed by alert name. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param aggregated_alert_name: Identifier of the aggregated alert. Required. + :type aggregated_alert_name: str + :return: IoTSecurityAggregatedAlert or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecurityAggregatedAlert + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecurityAggregatedAlert] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + aggregated_alert_name=aggregated_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecurityAggregatedAlert", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def dismiss( + self, resource_group_name: str, solution_name: str, aggregated_alert_name: str, **kwargs: Any + ) -> None: + """Use this method to dismiss an aggregated IoT Security Solution Alert. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param aggregated_alert_name: Identifier of the aggregated alert. Required. + :type aggregated_alert_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", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_dismiss_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + aggregated_alert_name=aggregated_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py new file mode 100644 index 000000000000..002f070b11b6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py @@ -0,0 +1,197 @@ +# 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.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._iot_security_solutions_analytics_recommendation_operations import ( + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotSecuritySolutionsAnalyticsRecommendationOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`iot_security_solutions_analytics_recommendation` 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: SecurityCenterConfiguration = 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, solution_name: str, aggregated_recommendation_name: str, **kwargs: Any + ) -> _models.IoTSecurityAggregatedRecommendation: + """Use this method to get the aggregated security analytics recommendation of yours IoT Security + solution. This aggregation is performed by recommendation name. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param aggregated_recommendation_name: Name of the recommendation aggregated for this query. + Required. + :type aggregated_recommendation_name: str + :return: IoTSecurityAggregatedRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecurityAggregatedRecommendation + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecurityAggregatedRecommendation] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + aggregated_recommendation_name=aggregated_recommendation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecurityAggregatedRecommendation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, solution_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.IoTSecurityAggregatedRecommendation"]: + """Use this method to get the list of aggregated security analytics recommendations of yours IoT + Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param top: Number of results to retrieve. Default value is None. + :type top: int + :return: An iterator like instance of either IoTSecurityAggregatedRecommendation or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.IoTSecurityAggregatedRecommendation] + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecurityAggregatedRecommendationList] = 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, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IoTSecurityAggregatedRecommendationList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_jit_network_access_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_jit_network_access_policies_operations.py new file mode 100644 index 000000000000..90cecf0f5f7e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_jit_network_access_policies_operations.py @@ -0,0 +1,763 @@ +# 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, Literal, Optional, TypeVar, Union, overload + +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._jit_network_access_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_initiate_request, + build_list_by_region_request, + build_list_by_resource_group_and_region_request, + build_list_by_resource_group_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class JitNetworkAccessPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`jit_network_access_policies` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control. + + :return: An iterator like instance of either JitNetworkAccessPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.JitNetworkAccessPolicy] + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPoliciesList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("JitNetworkAccessPoliciesList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_region(self, asc_location: str, **kwargs: Any) -> AsyncItemPaged["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control for the subscription, + location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either JitNetworkAccessPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.JitNetworkAccessPolicy] + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPoliciesList] = 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_by_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("JitNetworkAccessPoliciesList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control for the subscription, + location. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either JitNetworkAccessPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.JitNetworkAccessPolicy] + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPoliciesList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("JitNetworkAccessPoliciesList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group_and_region( + self, resource_group_name: str, asc_location: str, **kwargs: Any + ) -> AsyncItemPaged["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control for the subscription, + location. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either JitNetworkAccessPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.JitNetworkAccessPolicy] + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPoliciesList] = 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_by_resource_group_and_region_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("JitNetworkAccessPoliciesList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any + ) -> _models.JitNetworkAccessPolicy: + """Policies for protecting resources using Just-in-Time access control for the subscription, + location. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + jit_network_access_policy_name=jit_network_access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JitNetworkAccessPolicy", 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, + asc_location: str, + jit_network_access_policy_name: str, + body: _models.JitNetworkAccessPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitNetworkAccessPolicy: + """Create a policy for protecting resources using Just-in-Time access control. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Required. + :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitNetworkAccessPolicy: + """Create a policy for protecting resources using Just-in-Time access control. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: Union[_models.JitNetworkAccessPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.JitNetworkAccessPolicy: + """Create a policy for protecting resources using Just-in-Time access control. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Is either a JitNetworkAccessPolicy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicy or IO[bytes] + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :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", "2020-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "JitNetworkAccessPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + jit_network_access_policy_name=jit_network_access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JitNetworkAccessPolicy", 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, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any + ) -> None: + """Delete a Just-in-Time access control policy. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_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", "2020-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + jit_network_access_policy_name=jit_network_access_policy_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def initiate( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: _models.JitNetworkAccessPolicyInitiateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitNetworkAccessRequest: + """Initiate a JIT access from a specific Just-in-Time policy configuration. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Required. + :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JitNetworkAccessRequest or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessRequest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def initiate( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitNetworkAccessRequest: + """Initiate a JIT access from a specific Just-in-Time policy configuration. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JitNetworkAccessRequest or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessRequest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def initiate( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: Union[_models.JitNetworkAccessPolicyInitiateRequest, IO[bytes]], + **kwargs: Any + ) -> _models.JitNetworkAccessRequest: + """Initiate a JIT access from a specific Just-in-Time policy configuration. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Is either a JitNetworkAccessPolicyInitiateRequest type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateRequest or IO[bytes] + :return: JitNetworkAccessRequest or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessRequest + :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 {}) + + jit_network_access_policy_initiate_type: Literal["initiate"] = kwargs.pop( + "jit_network_access_policy_initiate_type", "initiate" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JitNetworkAccessRequest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "JitNetworkAccessPolicyInitiateRequest") + + _request = build_initiate_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + jit_network_access_policy_name=jit_network_access_policy_name, + subscription_id=self._config.subscription_id, + jit_network_access_policy_initiate_type=jit_network_access_policy_initiate_type, + 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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JitNetworkAccessRequest", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_locations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_locations_operations.py new file mode 100644 index 000000000000..585d6fc29ff6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_locations_operations.py @@ -0,0 +1,171 @@ +# 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.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._locations_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`locations` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.AscLocation"]: + """The location of the responsible ASC of the specific subscription (home region). For each + subscription there is only one responsible location. The location in the response should be + used to read or write other resources in ASC according to their ID. + + :return: An iterator like instance of either AscLocation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AscLocation] + :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", "2015-06-01-preview")) + cls: ClsType[_models.AscLocationList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AscLocationList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, asc_location: str, **kwargs: Any) -> _models.AscLocation: + """Details of a specific location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: AscLocation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AscLocation + :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", "2015-06-01-preview")) + cls: ClsType[_models.AscLocation] = kwargs.pop("cls", None) + + _request = build_get_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AscLocation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_mde_onboardings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_mde_onboardings_operations.py new file mode 100644 index 000000000000..3c33b8222594 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_mde_onboardings_operations.py @@ -0,0 +1,148 @@ +# 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._mde_onboardings_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MdeOnboardingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`mde_onboardings` 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: SecurityCenterConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list(self, **kwargs: Any) -> _models.MdeOnboardingDataList: + """The configuration or data needed to onboard the machine to MDE. + + :return: MdeOnboardingDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MdeOnboardingDataList + :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", "2021-10-01-preview")) + cls: ClsType[_models.MdeOnboardingDataList] = kwargs.pop("cls", None) + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MdeOnboardingDataList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, **kwargs: Any) -> _models.MdeOnboardingData: + """The default configuration or data needed to onboard the machine to MDE. + + :return: MdeOnboardingData or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MdeOnboardingData + :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", "2021-10-01-preview")) + cls: ClsType[_models.MdeOnboardingData] = kwargs.pop("cls", None) + + _request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MdeOnboardingData", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_operations.py new file mode 100644 index 000000000000..e351540e2ca2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_operations.py @@ -0,0 +1,116 @@ +# 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.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.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._operations import build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :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") + self._config: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: + """Exposes all available operations for discovery purposes. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-04-preview")) + cls: ClsType[_models.OperationListResult] = 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( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_patch.py @@ -0,0 +1,21 @@ +# 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 + + +def patch_sdk(): + """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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_pricings_operations.py new file mode 100644 index 000000000000..1a8b2f3c211f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_pricings_operations.py @@ -0,0 +1,367 @@ +# 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 + +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._pricings_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PricingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`pricings` 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: SecurityCenterConfiguration = 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, scope_id: str, pricing_name: str, **kwargs: Any) -> _models.Pricing: + """Get the Defender plans pricing configurations of the selected scope (valid scopes are resource + id or a subscription id). At the resource level, supported resource types are 'VirtualMachines, + VMSS and ARC Machines'. + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Pricing + :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", "2024-01-01")) + cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) + + _request = build_get_request( + scope_id=scope_id, + pricing_name=pricing_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Pricing", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + scope_id: str, + pricing_name: str, + pricing: _models.Pricing, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Pricing: + """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid + scopes are: subscription id or a specific resource id (Supported resources are: + 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param pricing: Pricing object. Required. + :type pricing: ~azure.mgmt.security.models.Pricing + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Pricing + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + scope_id: str, + pricing_name: str, + pricing: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Pricing: + """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid + scopes are: subscription id or a specific resource id (Supported resources are: + 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param pricing: Pricing object. Required. + :type pricing: 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: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Pricing + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, scope_id: str, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any + ) -> _models.Pricing: + """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid + scopes are: subscription id or a specific resource id (Supported resources are: + 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. + :type pricing: ~azure.mgmt.security.models.Pricing or IO[bytes] + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Pricing + :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", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pricing, (IOBase, bytes)): + _content = pricing + else: + _json = self._serialize.body(pricing, "Pricing") + + _request = build_update_request( + scope_id=scope_id, + pricing_name=pricing_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Pricing", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, scope_id: str, pricing_name: str, **kwargs: Any) -> None: + """Deletes a provided Microsoft Defender for Cloud pricing configuration in a specific resource. + Valid only for resource scope (Supported resources are: 'VirtualMachines, VMSS and ARC + MachinesS'). + + :param scope_id: The identifier of the resource, (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}). + Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_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", "2024-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope_id=scope_id, + pricing_name=pricing_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def list(self, scope_id: str, filter: Optional[str] = None, **kwargs: Any) -> _models.PricingList: + """Lists Microsoft Defender for Cloud pricing configurations of the scopeId, that match the + optional given $filter. Valid scopes are: subscription id or a specific resource id (Supported + resources are: 'VirtualMachines, VMSS and ARC Machines'). Valid $filter is: 'name in + ({planName1},{planName2},...)'. If $filter is not provided, the unfiltered list will be + returned. If '$filter=name in (planName1,planName2)' is provided, the returned list includes + the pricings set for 'planName1' and 'planName2' only. + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: PricingList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PricingList + :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", "2024-01-01")) + cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) + + _request = build_list_request( + scope_id=scope_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PricingList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_private_endpoint_connections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..11f069dd6c84 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,569 @@ +# 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 + +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._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`private_endpoint_connections` 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: SecurityCenterConfiguration = 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, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateEndpointConnection"]: + """Gets all private endpoint connections for a private link. Returns the list of private endpoints + that are connected or in the process of connecting to this private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.PrivateEndpointConnection] + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = 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: + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_list_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", 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.ErrorResponseAutoGenerated, 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, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the private link. Returns the + connection details, status, and configuration for a specific private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.security.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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-09-01-preview")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_get_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + private_endpoint_connection_name=private_endpoint_connection_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", 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, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, 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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + private_endpoint_connection_name=private_endpoint_connection_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the private link. + This operation is typically used to approve or reject pending private endpoint connections. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_endpoint_connection: The private endpoint connection resource. Required. + :type private_endpoint_connection: ~azure.mgmt.security.models.PrivateEndpointConnection + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_endpoint_connection: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the private link. + This operation is typically used to approve or reject pending private endpoint connections. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_endpoint_connection: The private endpoint connection resource. Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the private link. + This operation is typically used to approve or reject pending private endpoint connections. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_endpoint_connection: The private endpoint connection resource. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type private_endpoint_connection: ~azure.mgmt.security.models.PrivateEndpointConnection or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.PrivateEndpointConnection] + :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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = 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_endpoint_connection_name=private_endpoint_connection_name, + private_link_parameters=private_link_parameters, + private_endpoint_connection=private_endpoint_connection, + 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("PrivateEndpointConnection", 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.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + **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", "2025-09-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_delete_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + private_endpoint_connection_name=private_endpoint_connection_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + 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, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified private endpoint connection associated with the private link. This + operation will disconnect the private endpoint and remove the connection configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :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", "2025-09-01-preview")) + 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_endpoint_connection_name=private_endpoint_connection_name, + private_link_parameters=private_link_parameters, + 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": "azure-async-operation"}, **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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_private_link_resources_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..0325c6c3b054 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,201 @@ +# 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.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._private_link_resources_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SecurityCenterConfiguration = 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, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateLinkResourceAutoGenerated"]: + """List all private link resources in a private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: An iterator like instance of either PrivateLinkResourceAutoGenerated or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.PrivateLinkResourceAutoGenerated] + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinkResourceListResult] = 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: + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_list_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", 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.ErrorResponseAutoGenerated, 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, + group_id: str, + private_link_parameters: _models.PrivateLinkParameters, + **kwargs: Any + ) -> _models.PrivateLinkResourceAutoGenerated: + """Get the specified private link resource associated with the private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param group_id: The group ID of the private link resource. Required. + :type group_id: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: PrivateLinkResourceAutoGenerated or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResourceAutoGenerated + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinkResourceAutoGenerated] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_get_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + group_id=group_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResourceAutoGenerated", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_private_links_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_private_links_operations.py new file mode 100644 index 000000000000..104606f9204c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_private_links_operations.py @@ -0,0 +1,800 @@ +# 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 + +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._private_links_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_head_request, + build_list_by_subscription_request, + build_list_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`private_links` 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: SecurityCenterConfiguration = 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_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.PrivateLinkResource"]: + """Lists all the private links in the specified subscription. private links enable secure, private + connectivity to Microsoft Defender for Cloud services without exposing traffic to the public + internet. Use the 'nextLink' property in the response to get the next page of private links for + the specified subscription. + + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.PrivateLinkResource] + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinksList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinksList", 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.ErrorResponseAutoGenerated, 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, **kwargs: Any) -> AsyncItemPaged["_models.PrivateLinkResource"]: + """Lists all the private links in the specified resource group. private links enable secure, + private connectivity to Microsoft Defender for Cloud services without exposing traffic to the + public internet. Use the 'nextLink' property in the response to get the next page of private + links for the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.PrivateLinkResource] + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinksList] = 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinksList", 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.ErrorResponseAutoGenerated, 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, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Get a private link resource. Returns the configuration and status of private endpoint + connectivity for Microsoft Defender for Cloud services in the specified region. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResource + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_get_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def head( + self, resource_group_name: str, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> bool: + """Checks whether private link exists. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-09-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_head_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + async def _create_initial( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: Union[_models.PrivateLinkResource, 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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link, (IOBase, bytes)): + _content = private_link + else: + _json = self._serialize.body(private_link, "PrivateLinkResource") + + _request = build_create_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: _models.PrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateLinkResource]: + """Create a private link resource. This operation creates the necessary infrastructure to enable + private endpoint connections to Microsoft Defender for Cloud services. For updates to existing + resources, use the PATCH operation. The operation is asynchronous and may take several minutes + to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: Private link request payload containing the resource information for + create operations. Required. + :type private_link: ~azure.mgmt.security.models.PrivateLinkResource + :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 PrivateLinkResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateLinkResource]: + """Create a private link resource. This operation creates the necessary infrastructure to enable + private endpoint connections to Microsoft Defender for Cloud services. For updates to existing + resources, use the PATCH operation. The operation is asynchronous and may take several minutes + to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: Private link request payload containing the resource information for + create operations. Required. + :type private_link: 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 PrivateLinkResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: Union[_models.PrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateLinkResource]: + """Create a private link resource. This operation creates the necessary infrastructure to enable + private endpoint connections to Microsoft Defender for Cloud services. For updates to existing + resources, use the PATCH operation. The operation is asynchronous and may take several minutes + to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: Private link request payload containing the resource information for + create operations. Is either a PrivateLinkResource type or a IO[bytes] type. Required. + :type private_link: ~azure.mgmt.security.models.PrivateLinkResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either PrivateLinkResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.models.PrivateLinkResource] + :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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateLinkResource] = 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_initial( + resource_group_name=resource_group_name, + private_link_parameters=private_link_parameters, + private_link=private_link, + 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("PrivateLinkResource", 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.PrivateLinkResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def update( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: _models.PrivateLinkUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkResource: + """Update specific properties of a private link resource. Use this operation to update mutable + properties like tags without affecting the entire resource configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: private link update payload containing only the properties to be updated. + Required. + :type private_link: ~azure.mgmt.security.models.PrivateLinkUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkResource: + """Update specific properties of a private link resource. Use this operation to update mutable + properties like tags without affecting the entire resource configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: private link update payload containing only the properties to be updated. + Required. + :type private_link: 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: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: Union[_models.PrivateLinkUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateLinkResource: + """Update specific properties of a private link resource. Use this operation to update mutable + properties like tags without affecting the entire resource configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: private link update payload containing only the properties to be updated. + Is either a PrivateLinkUpdate type or a IO[bytes] type. Required. + :type private_link: ~azure.mgmt.security.models.PrivateLinkUpdate or IO[bytes] + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResource + :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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link, (IOBase, bytes)): + _content = private_link + else: + _json = self._serialize.body(private_link, "PrivateLinkUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, private_link_parameters: _models.PrivateLinkParameters, **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", "2025-09-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_delete_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + 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, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a private link resource. This operation will remove the private link infrastructure and + disconnect all associated private endpoints. This operation is asynchronous and may take + several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :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", "2025-09-01-preview")) + 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_link_parameters=private_link_parameters, + 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": "azure-async-operation"}, **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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_assessments_operations.py new file mode 100644 index 000000000000..958b69e49da5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_assessments_operations.py @@ -0,0 +1,202 @@ +# 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.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._regulatory_compliance_assessments_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RegulatoryComplianceAssessmentsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`regulatory_compliance_assessments` 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: SecurityCenterConfiguration = 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, + regulatory_compliance_standard_name: str, + regulatory_compliance_control_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.RegulatoryComplianceAssessment"]: + """Details and state of assessments mapped to selected regulatory compliance control. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :param regulatory_compliance_control_name: Name of the regulatory compliance control object. + Required. + :type regulatory_compliance_control_name: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either RegulatoryComplianceAssessment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.RegulatoryComplianceAssessment] + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceAssessmentList] = 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( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + regulatory_compliance_control_name=regulatory_compliance_control_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RegulatoryComplianceAssessmentList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + regulatory_compliance_standard_name: str, + regulatory_compliance_control_name: str, + regulatory_compliance_assessment_name: str, + **kwargs: Any + ) -> _models.RegulatoryComplianceAssessment: + """Supported regulatory compliance details and state for selected assessment. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :param regulatory_compliance_control_name: Name of the regulatory compliance control object. + Required. + :type regulatory_compliance_control_name: str + :param regulatory_compliance_assessment_name: Name of the regulatory compliance assessment + object. Required. + :type regulatory_compliance_assessment_name: str + :return: RegulatoryComplianceAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RegulatoryComplianceAssessment + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceAssessment] = kwargs.pop("cls", None) + + _request = build_get_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + regulatory_compliance_control_name=regulatory_compliance_control_name, + regulatory_compliance_assessment_name=regulatory_compliance_assessment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegulatoryComplianceAssessment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_controls_operations.py new file mode 100644 index 000000000000..48b07e681554 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_controls_operations.py @@ -0,0 +1,186 @@ +# 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.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._regulatory_compliance_controls_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RegulatoryComplianceControlsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`regulatory_compliance_controls` 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: SecurityCenterConfiguration = 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, regulatory_compliance_standard_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.RegulatoryComplianceControl"]: + """All supported regulatory compliance controls details and state for selected standard. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either RegulatoryComplianceControl or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.RegulatoryComplianceControl] + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceControlList] = 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( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RegulatoryComplianceControlList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, regulatory_compliance_standard_name: str, regulatory_compliance_control_name: str, **kwargs: Any + ) -> _models.RegulatoryComplianceControl: + """Selected regulatory compliance control details and state. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :param regulatory_compliance_control_name: Name of the regulatory compliance control object. + Required. + :type regulatory_compliance_control_name: str + :return: RegulatoryComplianceControl or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RegulatoryComplianceControl + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceControl] = kwargs.pop("cls", None) + + _request = build_get_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + regulatory_compliance_control_name=regulatory_compliance_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegulatoryComplianceControl", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_standards_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_standards_operations.py new file mode 100644 index 000000000000..32dcbf709dcf --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_standards_operations.py @@ -0,0 +1,178 @@ +# 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.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._regulatory_compliance_standards_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RegulatoryComplianceStandardsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`regulatory_compliance_standards` 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: SecurityCenterConfiguration = 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, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.RegulatoryComplianceStandard"]: + """Supported regulatory compliance standards details and state. + + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either RegulatoryComplianceStandard or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.RegulatoryComplianceStandard] + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceStandardList] = 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( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RegulatoryComplianceStandardList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, regulatory_compliance_standard_name: str, **kwargs: Any + ) -> _models.RegulatoryComplianceStandard: + """Supported regulatory compliance details state for selected standard. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :return: RegulatoryComplianceStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RegulatoryComplianceStandard + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceStandard] = kwargs.pop("cls", None) + + _request = build_get_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegulatoryComplianceStandard", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_score_control_definitions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_score_control_definitions_operations.py new file mode 100644 index 000000000000..13a6f340d7b0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_score_control_definitions_operations.py @@ -0,0 +1,186 @@ +# 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.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.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._secure_score_control_definitions_operations import ( + build_list_by_subscription_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecureScoreControlDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`secure_score_control_definitions` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.SecureScoreControlDefinitionItem"]: + """List the available security controls, their assessments, and the max score. + + :return: An iterator like instance of either SecureScoreControlDefinitionItem or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoreControlDefinitionItem] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreControlDefinitionList] = 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( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoreControlDefinitionList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.SecureScoreControlDefinitionItem"]: + """For a specified subscription, list the available security controls, their assessments, and the + max score. + + :return: An iterator like instance of either SecureScoreControlDefinitionItem or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoreControlDefinitionItem] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreControlDefinitionList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoreControlDefinitionList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_score_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_score_controls_operations.py new file mode 100644 index 000000000000..169db688e4c9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_score_controls_operations.py @@ -0,0 +1,197 @@ +# 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, Union + +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.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._secure_score_controls_operations import build_list_by_secure_score_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecureScoreControlsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`secure_score_controls` 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: SecurityCenterConfiguration = 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_by_secure_score( + self, secure_score_name: str, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.SecureScoreControlDetails"]: + """Get all security controls for a specific initiative within a scope. + + :param secure_score_name: The initiative name. For the ASC Default initiative, use 'ascScore' + as in the sample request below. Required. + :type secure_score_name: str + :param expand: OData expand. Optional. "definition" Default value is None. + :type expand: str or ~azure.mgmt.security.models.ExpandControlsEnum + :return: An iterator like instance of either SecureScoreControlDetails or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoreControlDetails] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreControlList] = 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_by_secure_score_request( + secure_score_name=secure_score_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoreControlList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list( + self, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.SecureScoreControlDetails"]: + """Get all security controls within a scope. + + :param expand: OData expand. Optional. "definition" Default value is None. + :type expand: str or ~azure.mgmt.security.models.ExpandControlsEnum + :return: An iterator like instance of either SecureScoreControlDetails or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoreControlDetails] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreControlList] = 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( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoreControlList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_scores_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_scores_operations.py new file mode 100644 index 000000000000..9a0a65334e0c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_scores_operations.py @@ -0,0 +1,171 @@ +# 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.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._secure_scores_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecureScoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`secure_scores` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.SecureScoreItem"]: + """List secure scores for all your Microsoft Defender for Cloud initiatives within your current + scope. + + :return: An iterator like instance of either SecureScoreItem or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoreItem] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoresList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoresList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, secure_score_name: str, **kwargs: Any) -> _models.SecureScoreItem: + """Get secure score for a specific Microsoft Defender for Cloud initiative within your current + scope. For the ASC Default initiative, use 'ascScore'. + + :param secure_score_name: The initiative name. For the ASC Default initiative, use 'ascScore' + as in the sample request below. Required. + :type secure_score_name: str + :return: SecureScoreItem or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecureScoreItem + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreItem] = kwargs.pop("cls", None) + + _request = build_get_request( + secure_score_name=secure_score_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecureScoreItem", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_connector_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_connector_application_operations.py new file mode 100644 index 000000000000..702b0e323350 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_connector_application_operations.py @@ -0,0 +1,318 @@ +# 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 + +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._security_connector_application_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityConnectorApplicationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`security_connector_application` 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: SecurityCenterConfiguration = 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, security_connector_name: str, application_id: str, **kwargs: Any + ) -> _models.Application: + """Get a specific application for the requested scope by applicationId. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :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", "2022-07-01-preview")) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + application_id=application_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", 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, + security_connector_name: str, + application_id: str, + application: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Creates or update a security Application on the given security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Required. + :type application: ~azure.mgmt.security.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + application_id: str, + application: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Creates or update a security Application on the given security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Required. + :type application: 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: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + application_id: str, + application: Union[_models.Application, IO[bytes]], + **kwargs: Any + ) -> _models.Application: + """Creates or update a security Application on the given security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Is either a Application type or a + IO[bytes] type. Required. + :type application: ~azure.mgmt.security.models.Application or IO[bytes] + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :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", "2022-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application, (IOBase, bytes)): + _content = application + else: + _json = self._serialize.body(application, "Application") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + application_id=application_id, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", 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, security_connector_name: str, application_id: str, **kwargs: Any + ) -> None: + """Delete an Application over a given scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: 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", "2022-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + application_id=application_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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_connector_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_connector_applications_operations.py new file mode 100644 index 000000000000..93431f541dbe --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_connector_applications_operations.py @@ -0,0 +1,125 @@ +# 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.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.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._security_connector_applications_operations import build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityConnectorApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`security_connector_applications` 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: SecurityCenterConfiguration = 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, security_connector_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Application"]: + """Get a list of all relevant applications over a security connector level scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + cls: ClsType[_models.ApplicationsList] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_connectors_operations.py new file mode 100644 index 000000000000..ddc4a2512565 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_connectors_operations.py @@ -0,0 +1,567 @@ +# 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 + +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._security_connectors_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityConnectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`security_connectors` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.SecurityConnector"]: + """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in + the response to get the next page of security connectors for the specified subscription. + + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityConnector] + :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", "2024-08-01-preview")) + cls: ClsType[_models.SecurityConnectorsList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SecurityConnector"]: + """Lists all the security connectors in the specified resource group. Use the 'nextLink' property + in the response to get the next page of security connectors for the specified resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityConnector] + :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", "2024-08-01-preview")) + cls: ClsType[_models.SecurityConnectorsList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.SecurityConnector: + """Retrieves details of a specific security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :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", "2024-08-01-preview")) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", 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, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.models.SecurityConnector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: 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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a SecurityConnector type + or a IO[bytes] type. Required. + :type security_connector: ~azure.mgmt.security.models.SecurityConnector or IO[bytes] + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :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", "2024-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IOBase, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.models.SecurityConnector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: 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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a SecurityConnector type + or a IO[bytes] type. Required. + :type security_connector: ~azure.mgmt.security.models.SecurityConnector or IO[bytes] + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :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", "2024-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IOBase, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", 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, security_connector_name: str, **kwargs: Any) -> None: + """Deletes a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_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", "2024-08-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_contacts_operations.py new file mode 100644 index 000000000000..c3afc05645af --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_contacts_operations.py @@ -0,0 +1,340 @@ +# 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 + +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._security_contacts_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityContactsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`security_contacts` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.SecurityContact"]: + """List all security contact configurations for the subscription. + + :return: An iterator like instance of either SecurityContact or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityContact] + :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", "2023-12-01-preview")) + cls: ClsType[_models.SecurityContactList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityContactList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, security_contact_name: Union[str, _models.SecurityContactName], **kwargs: Any + ) -> _models.SecurityContact: + """Get Default Security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityContact + :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", "2023-12-01-preview")) + cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) + + _request = build_get_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityContact", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + security_contact_name: Union[str, _models.SecurityContactName], + security_contact: _models.SecurityContact, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :param security_contact: Security contact object. Required. + :type security_contact: ~azure.mgmt.security.models.SecurityContact + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + security_contact_name: Union[str, _models.SecurityContactName], + security_contact: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :param security_contact: Security contact object. Required. + :type security_contact: 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: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + security_contact_name: Union[str, _models.SecurityContactName], + security_contact: Union[_models.SecurityContact, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :param security_contact: Security contact object. Is either a SecurityContact type or a + IO[bytes] type. Required. + :type security_contact: ~azure.mgmt.security.models.SecurityContact or IO[bytes] + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityContact + :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", "2023-12-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_contact, (IOBase, bytes)): + _content = security_contact + else: + _json = self._serialize.body(security_contact, "SecurityContact") + + _request = build_create_request( + security_contact_name=security_contact_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityContact", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, security_contact_name: Union[str, _models.SecurityContactName], **kwargs: Any) -> None: + """Delete security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :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", "2023-12-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + security_contact_name=security_contact_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_operators_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_operators_operations.py new file mode 100644 index 000000000000..b74b2ceba345 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_operators_operations.py @@ -0,0 +1,268 @@ +# 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._security_operators_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityOperatorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`security_operators` 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: SecurityCenterConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list(self, pricing_name: str, **kwargs: Any) -> _models.SecurityOperatorList: + """Lists Microsoft Defender for Cloud securityOperators in the subscription. + + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :return: SecurityOperatorList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityOperatorList + :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", "2023-01-01-preview")) + cls: ClsType[_models.SecurityOperatorList] = kwargs.pop("cls", None) + + _request = build_list_request( + pricing_name=pricing_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityOperatorList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, pricing_name: str, security_operator_name: str, **kwargs: Any) -> _models.SecurityOperator: + """Get a specific security operator for the requested scope. + + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param security_operator_name: name of the securityOperator. Required. + :type security_operator_name: str + :return: SecurityOperator or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityOperator + :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", "2023-01-01-preview")) + cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) + + _request = build_get_request( + pricing_name=pricing_name, + security_operator_name=security_operator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityOperator", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def create_or_update( + self, pricing_name: str, security_operator_name: str, **kwargs: Any + ) -> _models.SecurityOperator: + """Creates Microsoft Defender for Cloud security operator on the given scope. + + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param security_operator_name: name of the securityOperator. Required. + :type security_operator_name: str + :return: SecurityOperator or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityOperator + :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", "2023-01-01-preview")) + cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + pricing_name=pricing_name, + security_operator_name=security_operator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityOperator", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, pricing_name: str, security_operator_name: str, **kwargs: Any) -> None: + """Delete Microsoft Defender for Cloud securityOperator in the subscription. + + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param security_operator_name: name of the securityOperator. Required. + :type security_operator_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", "2023-01-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + pricing_name=pricing_name, + security_operator_name=security_operator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_solutions_operations.py new file mode 100644 index 000000000000..cd25e4bbe951 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_solutions_operations.py @@ -0,0 +1,178 @@ +# 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.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._security_solutions_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecuritySolutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`security_solutions` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.SecuritySolution"]: + """Gets a list of Security Solutions for the subscription. + + :return: An iterator like instance of either SecuritySolution or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.SecuritySolutionList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecuritySolutionList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, asc_location: str, security_solution_name: str, **kwargs: Any + ) -> _models.SecuritySolution: + """Gets a specific Security Solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param security_solution_name: Name of security solution. Required. + :type security_solution_name: str + :return: SecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecuritySolution + :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", "2020-01-01")) + cls: ClsType[_models.SecuritySolution] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + security_solution_name=security_solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySolution", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_solutions_reference_data_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_solutions_reference_data_operations.py new file mode 100644 index 000000000000..a8ff0a2c3415 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_solutions_reference_data_operations.py @@ -0,0 +1,155 @@ +# 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._security_solutions_reference_data_operations import ( + build_list_by_home_region_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecuritySolutionsReferenceDataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`security_solutions_reference_data` 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: SecurityCenterConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list(self, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: + """Gets a list of all supported Security Solutions for the subscription. + + :return: SecuritySolutionsReferenceDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecuritySolutionsReferenceDataList + :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", "2020-01-01")) + cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_by_home_region(self, asc_location: str, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: + """Gets list of all supported Security Solutions for subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: SecuritySolutionsReferenceDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecuritySolutionsReferenceDataList + :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", "2020-01-01")) + cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) + + _request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_standards_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_standards_operations.py new file mode 100644 index 000000000000..160aeec0896f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_standards_operations.py @@ -0,0 +1,378 @@ +# 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 + +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._security_standards_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityStandardsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`security_standards` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.SecurityStandard"]: + """Get a list of all relevant security standards over a scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :return: An iterator like instance of either SecurityStandard or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityStandard] + :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", "2024-08-01")) + cls: ClsType[_models.SecurityStandardList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityStandardList", 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, scope: str, standard_id: str, **kwargs: Any) -> _models.SecurityStandard: + """Get a specific security standard for the requested scope by standardId. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: str + :return: SecurityStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityStandard + :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", "2024-08-01")) + cls: ClsType[_models.SecurityStandard] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + standard_id=standard_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("SecurityStandard", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + scope: str, + standard_id: str, + standard: _models.SecurityStandard, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityStandard: + """Creates or updates a security standard over a given scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: str + :param standard: Custom security standard over a pre-defined scope. Required. + :type standard: ~azure.mgmt.security.models.SecurityStandard + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityStandard + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + scope: str, + standard_id: str, + standard: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityStandard: + """Creates or updates a security standard over a given scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: str + :param standard: Custom security standard over a pre-defined scope. Required. + :type standard: 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: SecurityStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityStandard + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, scope: str, standard_id: str, standard: Union[_models.SecurityStandard, IO[bytes]], **kwargs: Any + ) -> _models.SecurityStandard: + """Creates or updates a security standard over a given scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: str + :param standard: Custom security standard over a pre-defined scope. Is either a + SecurityStandard type or a IO[bytes] type. Required. + :type standard: ~azure.mgmt.security.models.SecurityStandard or IO[bytes] + :return: SecurityStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityStandard + :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", "2024-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityStandard] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(standard, (IOBase, bytes)): + _content = standard + else: + _json = self._serialize.body(standard, "SecurityStandard") + + _request = build_create_or_update_request( + scope=scope, + standard_id=standard_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("SecurityStandard", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, scope: str, standard_id: str, **kwargs: Any) -> None: + """Delete a security standard over a given scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: 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", "2024-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope=scope, + standard_id=standard_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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sensitivity_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sensitivity_settings_operations.py new file mode 100644 index 000000000000..5bb96346729d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sensitivity_settings_operations.py @@ -0,0 +1,252 @@ +# 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 + +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._sensitivity_settings_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SensitivitySettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`sensitivity_settings` 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: SecurityCenterConfiguration = 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") + + @overload + async def create_or_update( + self, + sensitivity_settings: _models.UpdateSensitivitySettingsRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Create or update data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Required. + :type sensitivity_settings: ~azure.mgmt.security.models.UpdateSensitivitySettingsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, sensitivity_settings: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Create or update data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Required. + :type sensitivity_settings: 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: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO[bytes]], **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Create or update data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Is either a + UpdateSensitivitySettingsRequest type or a IO[bytes] type. Required. + :type sensitivity_settings: ~azure.mgmt.security.models.UpdateSensitivitySettingsRequest or + IO[bytes] + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsResponse + :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", "2023-02-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sensitivity_settings, (IOBase, bytes)): + _content = sensitivity_settings + else: + _json = self._serialize.body(sensitivity_settings, "UpdateSensitivitySettingsRequest") + + _request = build_create_or_update_request( + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, **kwargs: Any) -> _models.GetSensitivitySettingsResponse: + """Gets data sensitivity settings for sensitive data discovery. + + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsResponse + :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", "2023-02-15-preview")) + cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list(self, **kwargs: Any) -> _models.GetSensitivitySettingsListResponse: + """Gets a list with a single sensitivity settings resource. + + :return: GetSensitivitySettingsListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsListResponse + :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", "2023-02-15-preview")) + cls: ClsType[_models.GetSensitivitySettingsListResponse] = kwargs.pop("cls", None) + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_server_vulnerability_assessment_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_server_vulnerability_assessment_operations.py new file mode 100644 index 000000000000..947833f36879 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_server_vulnerability_assessment_operations.py @@ -0,0 +1,374 @@ +# 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, AsyncIterator, Callable, Dict, Literal, Optional, TypeVar, Union, cast + +from azure.core import AsyncPipelineClient +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_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._server_vulnerability_assessment_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_extended_resource_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServerVulnerabilityAssessmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`server_vulnerability_assessment` 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: SecurityCenterConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_extended_resource( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsList: + """Gets a list of server vulnerability assessment onboarding statuses on a given resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The Namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :return: ServerVulnerabilityAssessmentsList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsList + :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", "2020-01-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsList] = kwargs.pop("cls", None) + + _request = build_list_by_extended_resource_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServerVulnerabilityAssessmentsList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Gets a server vulnerability assessment onboarding statuses on a given resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The Namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :return: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessment + :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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + server_vulnerability_assessment=server_vulnerability_assessment, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creating a server vulnerability assessment on a resource, which will onboard a resource for + having a vulnerability assessment on it. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The Namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :return: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessment + :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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + server_vulnerability_assessment=server_vulnerability_assessment, + 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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + server_vulnerability_assessment=server_vulnerability_assessment, + 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 [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removing server vulnerability assessment from a resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The Namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + server_vulnerability_assessment=server_vulnerability_assessment, + 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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_server_vulnerability_assessments_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_server_vulnerability_assessments_settings_operations.py new file mode 100644 index 000000000000..773a817cd7b9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_server_vulnerability_assessments_settings_operations.py @@ -0,0 +1,371 @@ +# 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 + +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._server_vulnerability_assessments_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_subscription_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServerVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`server_vulnerability_assessments_settings` 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: SecurityCenterConfiguration = 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_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.ServerVulnerabilityAssessmentsSetting"]: + """Get a list of all the server vulnerability assessments settings over a subscription level + scope. + + :return: An iterator like instance of either ServerVulnerabilityAssessmentsSetting or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting] + :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", "2023-05-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSettingsList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSettingsList", 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, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Get a server vulnerability assessments setting of the requested kind, that is set on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :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", "2023-05-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + setting_kind=setting_kind, + 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("ServerVulnerabilityAssessmentsSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: _models.ServerVulnerabilityAssessmentsSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Required. + :type server_vulnerability_assessments_setting: + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Required. + :type server_vulnerability_assessments_setting: 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: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: Union[_models.ServerVulnerabilityAssessmentsSetting, IO[bytes]], + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Is either a ServerVulnerabilityAssessmentsSetting type or a IO[bytes] + type. Required. + :type server_vulnerability_assessments_setting: + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting or IO[bytes] + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :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", "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(server_vulnerability_assessments_setting, (IOBase, bytes)): + _content = server_vulnerability_assessments_setting + else: + _json = self._serialize.body( + server_vulnerability_assessments_setting, "ServerVulnerabilityAssessmentsSetting" + ) + + _request = build_create_or_update_request( + setting_kind=setting_kind, + 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("ServerVulnerabilityAssessmentsSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any + ) -> None: + """Delete the server vulnerability assessments setting of the requested kind from the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :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", "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + setting_kind=setting_kind, + 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/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_settings_operations.py new file mode 100644 index 000000000000..abbbef19ed49 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_settings_operations.py @@ -0,0 +1,289 @@ +# 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 + +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._settings_operations import build_get_request, build_list_request, build_update_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`settings` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.Setting"]: + """Settings about different configurations in Microsoft Defender for Cloud. + + :return: An iterator like instance of either Setting or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Setting] + :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", "2022-05-01")) + cls: ClsType[_models.SettingsList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SettingsList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, setting_name: Union[str, _models.SettingNameAutoGenerated], **kwargs: Any) -> _models.Setting: + """Settings of different configurations in Microsoft Defender for Cloud. + + :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", + "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingNameAutoGenerated + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Setting + :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", "2022-05-01")) + cls: ClsType[_models.Setting] = kwargs.pop("cls", None) + + _request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Setting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + setting_name: Union[str, _models.SettingNameAutoGenerated], + setting: _models.Setting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Setting: + """updating settings about different configurations in Microsoft Defender for Cloud. + + :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", + "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingNameAutoGenerated + :param setting: Setting object. Required. + :type setting: ~azure.mgmt.security.models.Setting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + setting_name: Union[str, _models.SettingNameAutoGenerated], + setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Setting: + """updating settings about different configurations in Microsoft Defender for Cloud. + + :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", + "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingNameAutoGenerated + :param setting: Setting object. Required. + :type setting: 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: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + setting_name: Union[str, _models.SettingNameAutoGenerated], + setting: Union[_models.Setting, IO[bytes]], + **kwargs: Any + ) -> _models.Setting: + """updating settings about different configurations in Microsoft Defender for Cloud. + + :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", + "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingNameAutoGenerated + :param setting: Setting object. Is either a Setting type or a IO[bytes] type. Required. + :type setting: ~azure.mgmt.security.models.Setting or IO[bytes] + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Setting + :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", "2022-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Setting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IOBase, bytes)): + _content = setting + else: + _json = self._serialize.body(setting, "Setting") + + _request = build_update_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Setting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_software_inventories_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_software_inventories_operations.py new file mode 100644 index 000000000000..5f0a3446d202 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_software_inventories_operations.py @@ -0,0 +1,271 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) 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.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._software_inventories_operations import ( + build_get_request, + build_list_by_extended_resource_request, + build_list_by_subscription_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SoftwareInventoriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`software_inventories` 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: SecurityCenterConfiguration = 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_by_extended_resource( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Software"]: + """Gets the software inventory of the virtual machine. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of either Software or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Software] + :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", "2021-05-01-preview")) + cls: ClsType[_models.SoftwaresList] = 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_by_extended_resource_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SoftwaresList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.Software"]: + """Gets the software inventory of all virtual machines in the subscriptions. + + :return: An iterator like instance of either Software or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.Software] + :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", "2021-05-01-preview")) + cls: ClsType[_models.SoftwaresList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SoftwaresList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_namespace: str, + resource_type: str, + resource_name: str, + software_name: str, + **kwargs: Any + ) -> _models.Software: + """Gets a single software data of the virtual machine. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :param software_name: Name of the installed software. Required. + :type software_name: str + :return: Software or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Software + :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", "2021-05-01-preview")) + cls: ClsType[_models.Software] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + software_name=software_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Software", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py new file mode 100644 index 000000000000..00df2e64c9a4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py @@ -0,0 +1,506 @@ +# 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 + +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._sql_vulnerability_assessment_baseline_rules_operations import ( + build_add_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SqlVulnerabilityAssessmentBaselineRulesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`sql_vulnerability_assessment_baseline_rules` 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: SecurityCenterConfiguration = 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") + + @overload + async def create_or_update( + self, + rule_id: str, + workspace_id: str, + resource_id: str, + body: Optional[_models.RuleResultsInput] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RuleResults: + """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline results for this rule. Default value is None. + :type body: ~azure.mgmt.security.models.RuleResultsInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RuleResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + rule_id: str, + workspace_id: str, + resource_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RuleResults: + """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline results for this rule. 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: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RuleResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + rule_id: str, + workspace_id: str, + resource_id: str, + body: Optional[Union[_models.RuleResultsInput, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.RuleResults: + """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline results for this rule. Is either a RuleResultsInput type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.security.models.RuleResultsInput or IO[bytes] + :return: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RuleResults + :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", "2023-02-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "RuleResultsInput") + else: + _json = None + + _request = build_create_or_update_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RuleResults: + """Gets the results for a given rule in the Baseline. + + Gets the results for a given rule in the Baseline. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RuleResults + :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", "2023-02-01-preview")) + cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) + + _request = build_get_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> None: + """Deletes a rule from the Baseline of a given database. + + Deletes a rule from the Baseline of a given database. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: 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", "2023-02-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RulesResults: + """Gets the results for all rules in the Baseline. + + Gets the results for all rules in the Baseline. + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RulesResults + :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", "2023-02-01-preview")) + cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RulesResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def add( + self, + workspace_id: str, + resource_id: str, + body: Optional[_models.RulesResultsInput] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RulesResults: + """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline rules. Default value is None. + :type body: ~azure.mgmt.security.models.RulesResultsInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RulesResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def add( + self, + workspace_id: str, + resource_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RulesResults: + """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline rules. 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: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RulesResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def add( + self, + workspace_id: str, + resource_id: str, + body: Optional[Union[_models.RulesResultsInput, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.RulesResults: + """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline rules. Is either a RulesResultsInput type or a IO[bytes] type. + Default value is None. + :type body: ~azure.mgmt.security.models.RulesResultsInput or IO[bytes] + :return: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RulesResults + :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", "2023-02-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "RulesResultsInput") + else: + _json = None + + _request = build_add_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RulesResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py new file mode 100644 index 000000000000..e921cc34e6fa --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py @@ -0,0 +1,175 @@ +# 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._sql_vulnerability_assessment_scan_results_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SqlVulnerabilityAssessmentScanResultsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`sql_vulnerability_assessment_scan_results` 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: SecurityCenterConfiguration = 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, scan_id: str, scan_result_id: str, workspace_id: str, resource_id: str, **kwargs: Any + ) -> _models.ScanResult: + """Gets the scan results of a single rule in a scan record. + + Gets the scan results of a single rule in a scan record. + + :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. + Required. + :type scan_id: str + :param scan_result_id: The rule Id of the results. Required. + :type scan_result_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: ScanResult or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ScanResult + :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", "2023-02-01-preview")) + cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) + + _request = build_get_request( + scan_id=scan_id, + scan_result_id=scan_result_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScanResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.ScanResults: + """Gets a list of scan results for a single scan record. + + Gets a list of scan results for a single scan record. + + :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. + Required. + :type scan_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: ScanResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ScanResults + :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", "2023-02-01-preview")) + cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) + + _request = build_list_request( + scan_id=scan_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScanResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_scans_operations.py new file mode 100644 index 000000000000..496d0a33ddf0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_scans_operations.py @@ -0,0 +1,166 @@ +# 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._sql_vulnerability_assessment_scans_operations import build_get_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`sql_vulnerability_assessment_scans` 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: SecurityCenterConfiguration = 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, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: + """Gets the scan details of a single scan record. + + Gets the scan details of a single scan record. + + :param scan_id: The scan Id. Type 'latest' to get the scan record for the latest scan. + Required. + :type scan_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: Scan or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Scan + :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", "2023-02-01-preview")) + cls: ClsType[_models.Scan] = kwargs.pop("cls", None) + + _request = build_get_request( + scan_id=scan_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Scan", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scans: + """Gets a list of scan records. + + Gets a list of scan records. + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: Scans or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Scans + :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", "2023-02-01-preview")) + cls: ClsType[_models.Scans] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Scans", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_standard_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_standard_assignments_operations.py new file mode 100644 index 000000000000..2933d23d2a71 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_standard_assignments_operations.py @@ -0,0 +1,386 @@ +# 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 + +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._standard_assignments_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StandardAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`standard_assignments` 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: SecurityCenterConfiguration = 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_id: str, standard_assignment_name: str, **kwargs: Any) -> _models.StandardAssignment: + """Retrieves a standard assignment. + + This operation retrieves a single standard assignment, given its name and the scope it was + created at. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_name: str + :return: StandardAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.StandardAssignment + :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", "2024-08-01")) + cls: ClsType[_models.StandardAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + standard_assignment_name=standard_assignment_name, + 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("StandardAssignment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_id: str, + standard_assignment_name: str, + standard_assignment: _models.StandardAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StandardAssignment: + """Creates or updates a standard assignment. + + This operation creates or updates a standard assignment with the given scope and name. standard + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_name: str + :param standard_assignment: Custom standard assignment over a pre-defined scope. Required. + :type standard_assignment: ~azure.mgmt.security.models.StandardAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StandardAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.StandardAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_id: str, + standard_assignment_name: str, + standard_assignment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StandardAssignment: + """Creates or updates a standard assignment. + + This operation creates or updates a standard assignment with the given scope and name. standard + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_name: str + :param standard_assignment: Custom standard assignment over a pre-defined scope. Required. + :type standard_assignment: 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: StandardAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.StandardAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_id: str, + standard_assignment_name: str, + standard_assignment: Union[_models.StandardAssignment, IO[bytes]], + **kwargs: Any + ) -> _models.StandardAssignment: + """Creates or updates a standard assignment. + + This operation creates or updates a standard assignment with the given scope and name. standard + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_name: str + :param standard_assignment: Custom standard assignment over a pre-defined scope. Is either a + StandardAssignment type or a IO[bytes] type. Required. + :type standard_assignment: ~azure.mgmt.security.models.StandardAssignment or IO[bytes] + :return: StandardAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.StandardAssignment + :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", "2024-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StandardAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(standard_assignment, (IOBase, bytes)): + _content = standard_assignment + else: + _json = self._serialize.body(standard_assignment, "StandardAssignment") + + _request = build_create_request( + resource_id=resource_id, + standard_assignment_name=standard_assignment_name, + 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("StandardAssignment", 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_id: str, standard_assignment_name: str, **kwargs: Any) -> None: + """Deletes a standard assignment. + + This operation deletes a standard assignment, given its name and the scope it was created in. + The scope of a standard assignment is the part of its ID preceding + '/providers/Microsoft.Security/standardAssignments/{standardAssignmentName}'. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_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", "2024-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_id=resource_id, + standard_assignment_name=standard_assignment_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.StandardAssignment"]: + """Get a list of all relevant standard assignments over a scope. + + :param scope: The scope of the standard assignment. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :return: An iterator like instance of either StandardAssignment or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.StandardAssignment] + :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", "2024-08-01")) + cls: ClsType[_models.StandardAssignmentsList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StandardAssignmentsList", 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) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sub_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sub_assessments_operations.py new file mode 100644 index 000000000000..afa82ffff453 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sub_assessments_operations.py @@ -0,0 +1,256 @@ +# 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.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._sub_assessments_operations import build_get_request, build_list_all_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SubAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`sub_assessments` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.SecuritySubAssessment"]: + """Get security sub-assessments on all your scanned resources inside a subscription scope. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either SecuritySubAssessment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecuritySubAssessment] + :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", "2019-01-01-preview")) + cls: ClsType[_models.SecuritySubAssessmentList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecuritySubAssessmentList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, scope: str, assessment_name: str, **kwargs: Any) -> AsyncItemPaged["_models.SecuritySubAssessment"]: + """Get security sub-assessments on all your scanned resources inside a scope. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :return: An iterator like instance of either SecuritySubAssessment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecuritySubAssessment] + :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", "2019-01-01-preview")) + cls: ClsType[_models.SecuritySubAssessmentList] = 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( + scope=scope, + assessment_name=assessment_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecuritySubAssessmentList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, scope: str, assessment_name: str, sub_assessment_name: str, **kwargs: Any + ) -> _models.SecuritySubAssessment: + """Get a security sub-assessment on your scanned resource. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param sub_assessment_name: The Sub-Assessment Key - Unique key for the sub-assessment type. + Required. + :type sub_assessment_name: str + :return: SecuritySubAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecuritySubAssessment + :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", "2019-01-01-preview")) + cls: ClsType[_models.SecuritySubAssessment] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + assessment_name=assessment_name, + sub_assessment_name=sub_assessment_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySubAssessment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_tasks_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_tasks_operations.py new file mode 100644 index 000000000000..c8db382bb11e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_tasks_operations.py @@ -0,0 +1,521 @@ +# 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, Union + +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._tasks_operations import ( + build_get_resource_group_level_task_request, + build_get_subscription_level_task_request, + build_list_by_home_region_request, + build_list_by_resource_group_request, + build_list_request, + build_update_resource_group_level_task_state_request, + build_update_subscription_level_task_state_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`tasks` 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: SecurityCenterConfiguration = 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, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.SecurityTask"]: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either SecurityTask or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityTask] + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTaskList] = 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( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityTaskList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region( + self, asc_location: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.SecurityTask"]: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either SecurityTask or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityTask] + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTaskList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityTaskList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_subscription_level_task( + self, asc_location: str, task_name: str, **kwargs: Any + ) -> _models.SecurityTask: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param task_name: Name of the task object, will be a GUID. Required. + :type task_name: str + :return: SecurityTask or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityTask + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) + + _request = build_get_subscription_level_task_request( + asc_location=asc_location, + task_name=task_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityTask", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def update_subscription_level_task_state( + self, + asc_location: str, + task_name: str, + task_update_action_type: Union[str, _models.TaskUpdateActionType], + **kwargs: Any + ) -> None: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param task_name: Name of the task object, will be a GUID. Required. + :type task_name: str + :param task_update_action_type: Type of the action to do on the task. Known values are: + "Activate", "Dismiss", "Start", "Resolve", and "Close". Required. + :type task_update_action_type: str or ~azure.mgmt.security.models.TaskUpdateActionType + :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", "2015-06-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_task_state_request( + asc_location=asc_location, + task_name=task_name, + task_update_action_type=task_update_action_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, asc_location: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.SecurityTask"]: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either SecurityTask or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityTask] + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTaskList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityTaskList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_resource_group_level_task( + self, resource_group_name: str, asc_location: str, task_name: str, **kwargs: Any + ) -> _models.SecurityTask: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param task_name: Name of the task object, will be a GUID. Required. + :type task_name: str + :return: SecurityTask or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityTask + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) + + _request = build_get_resource_group_level_task_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + task_name=task_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityTask", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def update_resource_group_level_task_state( + self, + resource_group_name: str, + asc_location: str, + task_name: str, + task_update_action_type: Union[str, _models.TaskUpdateActionType], + **kwargs: Any + ) -> None: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param task_name: Name of the task object, will be a GUID. Required. + :type task_name: str + :param task_update_action_type: Type of the action to do on the task. Known values are: + "Activate", "Dismiss", "Start", "Resolve", and "Close". Required. + :type task_update_action_type: str or ~azure.mgmt.security.models.TaskUpdateActionType + :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", "2015-06-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_task_state_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + task_name=task_name, + task_update_action_type=task_update_action_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_topology_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_topology_operations.py new file mode 100644 index 000000000000..926886fdc27d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_topology_operations.py @@ -0,0 +1,245 @@ +# 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.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._topology_operations import build_get_request, build_list_by_home_region_request, build_list_request +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TopologyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`topology` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.TopologyResource"]: + """Gets a list that allows to build a topology view of a subscription. + + :return: An iterator like instance of either TopologyResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.TopologyResource] + :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", "2020-01-01")) + cls: ClsType[_models.TopologyList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TopologyList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region(self, asc_location: str, **kwargs: Any) -> AsyncItemPaged["_models.TopologyResource"]: + """Gets a list that allows to build a topology view of a subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either TopologyResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.TopologyResource] + :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", "2020-01-01")) + cls: ClsType[_models.TopologyList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TopologyList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, asc_location: str, topology_resource_name: str, **kwargs: Any + ) -> _models.TopologyResource: + """Gets a specific topology component. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param topology_resource_name: Name of a topology resources collection. Required. + :type topology_resource_name: str + :return: TopologyResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.TopologyResource + :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", "2020-01-01")) + cls: ClsType[_models.TopologyResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + topology_resource_name=topology_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TopologyResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_workspace_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_workspace_settings_operations.py new file mode 100644 index 000000000000..0d4a67bdd196 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_workspace_settings_operations.py @@ -0,0 +1,453 @@ +# 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 + +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._workspace_settings_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import SecurityCenterConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.aio.SecurityCenter`'s + :attr:`workspace_settings` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> AsyncItemPaged["_models.WorkspaceSetting"]: + """Settings about where we should store your security data and logs. If the result is empty, it + means that no custom-workspace configuration was set. + + :return: An iterator like instance of either WorkspaceSetting or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.WorkspaceSetting] + :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", "2017-08-01-preview")) + cls: ClsType[_models.WorkspaceSettingList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WorkspaceSettingList", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, workspace_setting_name: str, **kwargs: Any) -> _models.WorkspaceSetting: + """Settings about where we should store your security data and logs. If the result is empty, it + means that no custom-workspace configuration was set. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :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", "2017-08-01-preview")) + cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkspaceSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + workspace_setting_name: str, + workspace_setting: _models.WorkspaceSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceSetting: + """creating settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Required. + :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + workspace_setting_name: str, + workspace_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceSetting: + """creating settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Required. + :type workspace_setting: 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: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, workspace_setting_name: str, workspace_setting: Union[_models.WorkspaceSetting, IO[bytes]], **kwargs: Any + ) -> _models.WorkspaceSetting: + """creating settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Is either a WorkspaceSetting type or a + IO[bytes] type. Required. + :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting or IO[bytes] + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_setting, (IOBase, bytes)): + _content = workspace_setting + else: + _json = self._serialize.body(workspace_setting, "WorkspaceSetting") + + _request = build_create_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkspaceSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + workspace_setting_name: str, + workspace_setting: _models.WorkspaceSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceSetting: + """Settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Required. + :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + workspace_setting_name: str, + workspace_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceSetting: + """Settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Required. + :type workspace_setting: 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: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, workspace_setting_name: str, workspace_setting: Union[_models.WorkspaceSetting, IO[bytes]], **kwargs: Any + ) -> _models.WorkspaceSetting: + """Settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Is either a WorkspaceSetting type or a + IO[bytes] type. Required. + :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting or IO[bytes] + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_setting, (IOBase, bytes)): + _content = workspace_setting + else: + _json = self._serialize.body(workspace_setting, "WorkspaceSetting") + + _request = build_update_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkspaceSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, workspace_setting_name: str, **kwargs: Any) -> None: + """Deletes the custom workspace settings for this subscription. new VMs will report to the default + workspace. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_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", "2017-08-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/models.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/models.py deleted file mode 100644 index 030994ed6062..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/models.py +++ /dev/null @@ -1,33 +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. -# -------------------------------------------------------------------------- -from .v2015_06_01_preview.models import * -from .v2017_08_01.models import * -from .v2017_08_01_preview.models import * -from .v2019_01_01.models import * -from .v2019_01_01_preview.models import * -from .v2019_08_01.models import * -from .v2020_01_01.models import * -from .v2020_01_01_preview.models import * -from .v2021_05_01_preview.models import * -from .v2021_06_01.models import * -from .v2021_07_01_preview.models import * -from .v2021_10_01_preview.models import * -from .v2022_01_01.models import * -from .v2022_01_01_preview.models import * -from .v2022_05_01.models import * -from .v2022_07_01_preview.models import * -from .v2022_11_20_preview.models import * -from .v2022_12_01_preview.models import * -from .v2023_01_01_preview.models import * -from .v2023_02_01_preview.models import * -from .v2023_02_15_preview.models import * -from .v2023_05_01.models import * -from .v2023_05_01_preview.models import * -from .v2023_10_01_preview.models import * -from .v2023_11_15.models import * -from .v2024_01_01.models import * -from .v2024_04_01.models import * diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/models/__init__.py new file mode 100644 index 000000000000..75f264d7ef57 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/models/__init__.py @@ -0,0 +1,1197 @@ +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AadConnectivityState, + AadExternalSecuritySolution, + AadSolutionProperties, + AccessTokenAuthentication, + ActionableRemediation, + ActiveConnectionsNotInAllowedRange, + AdditionalData, + AdditionalWorkspacesProperties, + AdvancedThreatProtectionSetting, + AgentlessConfiguration, + Alert, + AlertEntity, + AlertList, + AlertPropertiesSupportingEvidence, + AlertSimulatorBundlesRequestProperties, + AlertSimulatorRequestBody, + AlertSimulatorRequestProperties, + AlertSyncSettings, + AlertsSuppressionRule, + AlertsSuppressionRulesList, + AllowedConnectionsList, + AllowedConnectionsResource, + AllowlistCustomAlertRule, + AmqpC2DMessagesNotInAllowedRange, + AmqpC2DRejectedMessagesNotInAllowedRange, + AmqpD2CMessagesNotInAllowedRange, + ApiCollection, + ApiCollectionList, + Application, + ApplicationCondition, + ApplicationsList, + ArcAutoProvisioning, + ArcAutoProvisioningAws, + ArcAutoProvisioningConfiguration, + ArcAutoProvisioningGcp, + AscLocation, + AscLocationList, + AssessmentLinks, + AssessmentStatus, + AssessmentStatusResponse, + AssignedAssessmentItem, + AssignedStandardItem, + AtaExternalSecuritySolution, + AtaSolutionProperties, + AttestationEvidence, + Authentication, + AuthenticationDetailsProperties, + Authorization, + AutoProvisioningSetting, + AutoProvisioningSettingList, + Automation, + AutomationAction, + AutomationActionEventHub, + AutomationActionLogicApp, + AutomationActionWorkspace, + AutomationList, + AutomationRuleSet, + AutomationScope, + AutomationSource, + AutomationTriggeringRule, + AutomationUpdateModel, + AutomationValidationStatus, + AwAssumeRoleAuthenticationDetailsProperties, + AwsCredsAuthenticationDetailsProperties, + AwsEnvironmentData, + AwsOrganizationalData, + AwsOrganizationalDataMaster, + AwsOrganizationalDataMember, + AzureDevOpsOrg, + AzureDevOpsOrgListResponse, + AzureDevOpsOrgProperties, + AzureDevOpsOrganizationConfiguration, + AzureDevOpsProject, + AzureDevOpsProjectConfiguration, + AzureDevOpsProjectListResponse, + AzureDevOpsProjectProperties, + AzureDevOpsRepository, + AzureDevOpsRepositoryListResponse, + AzureDevOpsRepositoryProperties, + AzureDevOpsScopeEnvironmentData, + AzureResourceDetails, + AzureResourceIdentifier, + AzureResourceLink, + AzureServersSetting, + AzureTrackedResourceLocation, + BaseResourceConfiguration, + Baseline, + BaselineAdjustedResult, + BenchmarkReference, + BlobsScanSummary, + BuiltInInfoType, + CVE, + CVSS, + CategoryConfiguration, + CefExternalSecuritySolution, + CefSolutionProperties, + CloudErrorBody, + CloudOffering, + Compliance, + ComplianceList, + ComplianceResult, + ComplianceResultList, + ComplianceSegment, + Components1Uu4J47SchemasSecurityassessmentpropertiesbasePropertiesRiskPropertiesPathsItemsPropertiesEdgesItems, + Condition, + ConnectableResource, + ConnectedResource, + ConnectedWorkspace, + ConnectionFromIpNotAllowed, + ConnectionToIpNotAllowed, + ConnectorSetting, + ConnectorSettingList, + ContainerRegistryVulnerabilityProperties, + CspmMonitorAwsOffering, + CspmMonitorAwsOfferingNativeCloudConnection, + CspmMonitorAzureDevOpsOffering, + CspmMonitorDockerHubOffering, + CspmMonitorGcpOffering, + CspmMonitorGcpOfferingNativeCloudConnection, + CspmMonitorGitLabOffering, + CspmMonitorGithubOffering, + CspmMonitorJFrogOffering, + CustomAlertRule, + CustomAssessmentAutomation, + CustomAssessmentAutomationRequest, + CustomAssessmentAutomationsListResult, + CustomEntityStoreAssignment, + CustomEntityStoreAssignmentRequest, + CustomEntityStoreAssignmentsListResult, + CustomRecommendation, + CustomRecommendationsList, + DataExportSettings, + DefenderCspmAwsOffering, + DefenderCspmAwsOfferingCiem, + DefenderCspmAwsOfferingCiemDiscovery, + DefenderCspmAwsOfferingCiemOidc, + DefenderCspmAwsOfferingDataSensitivityDiscovery, + DefenderCspmAwsOfferingDatabasesDspm, + DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S, + DefenderCspmAwsOfferingMdcContainersImageAssessment, + DefenderCspmAwsOfferingVmScanners, + DefenderCspmDockerHubOffering, + DefenderCspmGcpOffering, + DefenderCspmGcpOfferingCiemDiscovery, + DefenderCspmGcpOfferingDataSensitivityDiscovery, + DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S, + DefenderCspmGcpOfferingMdcContainersImageAssessment, + DefenderCspmGcpOfferingVmScanners, + DefenderCspmJFrogOffering, + DefenderCspmJFrogOfferingMdcContainersImageAssessment, + DefenderFoDatabasesAwsOffering, + DefenderFoDatabasesAwsOfferingArcAutoProvisioning, + DefenderFoDatabasesAwsOfferingDatabasesDspm, + DefenderFoDatabasesAwsOfferingRds, + DefenderForContainersAwsOffering, + DefenderForContainersAwsOfferingCloudWatchToKinesis, + DefenderForContainersAwsOfferingKinesisToS3, + DefenderForContainersAwsOfferingKubernetesDataCollection, + DefenderForContainersAwsOfferingKubernetesService, + DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S, + DefenderForContainersAwsOfferingMdcContainersImageAssessment, + DefenderForContainersAwsOfferingVmScanners, + DefenderForContainersDockerHubOffering, + DefenderForContainersGcpOffering, + DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection, + DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S, + DefenderForContainersGcpOfferingMdcContainersImageAssessment, + DefenderForContainersGcpOfferingNativeCloudConnection, + DefenderForContainersGcpOfferingVmScanners, + DefenderForContainersJFrogOffering, + DefenderForDatabasesGcpOffering, + DefenderForDatabasesGcpOfferingArcAutoProvisioning, + DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning, + DefenderForServersAwsOffering, + DefenderForServersAwsOfferingArcAutoProvisioning, + DefenderForServersAwsOfferingDefenderForServers, + DefenderForServersAwsOfferingMdeAutoProvisioning, + DefenderForServersAwsOfferingSubPlan, + DefenderForServersAwsOfferingVaAutoProvisioning, + DefenderForServersAwsOfferingVaAutoProvisioningConfiguration, + DefenderForServersAwsOfferingVmScanners, + DefenderForServersGcpOffering, + DefenderForServersGcpOfferingArcAutoProvisioning, + DefenderForServersGcpOfferingDefenderForServers, + DefenderForServersGcpOfferingMdeAutoProvisioning, + DefenderForServersGcpOfferingSubPlan, + DefenderForServersGcpOfferingVaAutoProvisioning, + DefenderForServersGcpOfferingVaAutoProvisioningConfiguration, + DefenderForServersGcpOfferingVmScanners, + DefenderForStorageSetting, + DefenderForStorageSettingProperties, + DenylistCustomAlertRule, + DevOpsCapability, + DevOpsConfiguration, + DevOpsConfigurationListResponse, + DevOpsConfigurationProperties, + DeviceSecurityGroup, + DeviceSecurityGroupList, + DirectMethodInvokesNotInAllowedRange, + DiscoveredSecuritySolution, + DiscoveredSecuritySolutionList, + DockerHubEnvironmentData, + ETag, + EdgeIdentifiers, + EnvironmentData, + EnvironmentDetails, + ErrorAdditionalInfo, + ErrorDetail, + ErrorDetailAutoGenerated, + ErrorDetailAutoGenerated2, + ErrorResponse, + ErrorResponseAutoGenerated, + ErrorResponseAutoGenerated2, + ExecuteGovernanceRuleParams, + Extension, + ExternalSecuritySolution, + ExternalSecuritySolutionKind, + ExternalSecuritySolutionList, + ExternalSecuritySolutionProperties, + FailedLocalLoginsNotInAllowedRange, + FileUploadsNotInAllowedRange, + GcpCredentialsDetailsProperties, + GcpOrganizationalData, + GcpOrganizationalDataMember, + GcpOrganizationalDataOrganization, + GcpProjectDetails, + GcpProjectEnvironmentData, + GetSensitivitySettingsListResponse, + GetSensitivitySettingsResponse, + GetSensitivitySettingsResponseProperties, + GetSensitivitySettingsResponsePropertiesMipInformation, + GitHubOwner, + GitHubOwnerConfiguration, + GitHubOwnerListResponse, + GitHubOwnerProperties, + GitHubRepository, + GitHubRepositoryListResponse, + GitHubRepositoryProperties, + GitLabGroup, + GitLabGroupConfiguration, + GitLabGroupListResponse, + GitLabGroupProperties, + GitLabProject, + GitLabProjectListResponse, + GitLabProjectProperties, + GithubScopeEnvironmentData, + GitlabScopeEnvironmentData, + GovernanceAssignment, + GovernanceAssignmentAdditionalData, + GovernanceAssignmentsList, + GovernanceEmailNotification, + GovernanceRule, + GovernanceRuleEmailNotification, + GovernanceRuleList, + GovernanceRuleMetadata, + GovernanceRuleOwnerSource, + HealthDataClassification, + HealthReport, + HealthReportsList, + HttpC2DMessagesNotInAllowedRange, + HttpC2DRejectedMessagesNotInAllowedRange, + HttpD2CMessagesNotInAllowedRange, + HybridComputeSettingsProperties, + Identity, + InfoType, + InformationProtectionKeyword, + InformationProtectionPolicy, + InformationProtectionPolicyList, + InformationType, + InventoryList, + IoTSecurityAggregatedAlert, + IoTSecurityAggregatedAlertList, + IoTSecurityAggregatedAlertPropertiesTopDevicesListItem, + IoTSecurityAggregatedRecommendation, + IoTSecurityAggregatedRecommendationList, + IoTSecurityAlertedDevice, + IoTSecurityDeviceAlert, + IoTSecurityDeviceRecommendation, + IoTSecuritySolutionAnalyticsModel, + IoTSecuritySolutionAnalyticsModelList, + IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem, + IoTSecuritySolutionModel, + IoTSecuritySolutionsList, + IoTSeverityMetrics, + Issue, + JFrogEnvironmentData, + JitNetworkAccessPoliciesList, + JitNetworkAccessPolicy, + JitNetworkAccessPolicyInitiatePort, + JitNetworkAccessPolicyInitiateRequest, + JitNetworkAccessPolicyInitiateVirtualMachine, + JitNetworkAccessPolicyVirtualMachine, + JitNetworkAccessPortRule, + JitNetworkAccessRequest, + JitNetworkAccessRequestPort, + JitNetworkAccessRequestVirtualMachine, + Kind, + Label, + ListCustomAlertRule, + LocalUserNotAllowed, + Location, + LogAnalyticsIdentifier, + MalwareScan, + MalwareScanProperties, + MalwareScanningProperties, + MdeOnboardingData, + MdeOnboardingDataList, + MqttC2DMessagesNotInAllowedRange, + MqttC2DRejectedMessagesNotInAllowedRange, + MqttD2CMessagesNotInAllowedRange, + NodeIdentifier, + NotificationsSource, + NotificationsSourceAlert, + NotificationsSourceAttackPath, + OnPremiseResourceDetails, + OnPremiseSqlResourceDetails, + OnUploadFilters, + OnUploadProperties, + Operation, + OperationDisplay, + OperationListResult, + OperationResultAutoGenerated, + OperationStatus, + OperationStatusAutoGenerated, + OperationStatusResult, + PartialAssessmentProperties, + Path, + Pricing, + PricingList, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionListResult, + PrivateLinkParameters, + PrivateLinkResource, + PrivateLinkResourceAutoGenerated, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + PrivateLinkUpdate, + PrivateLinksList, + ProcessNotAllowed, + ProxyResource, + ProxyServerProperties, + QueryCheck, + QueuePurgesNotInAllowedRange, + RecommendationConfigurationProperties, + RegulatoryComplianceAssessment, + RegulatoryComplianceAssessmentList, + RegulatoryComplianceControl, + RegulatoryComplianceControlList, + RegulatoryComplianceStandard, + RegulatoryComplianceStandardList, + Remediation, + RemediationEta, + Resource, + ResourceAutoGenerated, + ResourceAutoGenerated2, + ResourceAutoGenerated3, + ResourceDetails, + ResourceDetailsAutoGenerated, + ResourceIdentifier, + RuleResults, + RuleResultsInput, + RuleResultsProperties, + RulesResults, + RulesResultsInput, + Scan, + ScanProperties, + ScanResult, + ScanResultProperties, + ScanResults, + ScanSummary, + Scans, + ScopeElement, + SecureScoreControlDefinitionItem, + SecureScoreControlDefinitionList, + SecureScoreControlDefinitionSource, + SecureScoreControlDetails, + SecureScoreControlList, + SecureScoreControlScore, + SecureScoreItem, + SecureScoresList, + SecurityAssessment, + SecurityAssessmentList, + SecurityAssessmentMetadata, + SecurityAssessmentMetadataPartnerData, + SecurityAssessmentMetadataProperties, + SecurityAssessmentMetadataPropertiesResponse, + SecurityAssessmentMetadataPropertiesResponsePublishDates, + SecurityAssessmentMetadataResponse, + SecurityAssessmentMetadataResponseList, + SecurityAssessmentPartnerData, + SecurityAssessmentProperties, + SecurityAssessmentPropertiesBase, + SecurityAssessmentPropertiesBaseRisk, + SecurityAssessmentPropertiesBaseRiskPathsItem, + SecurityAssessmentPropertiesBaseRiskPathsPropertiesItemsItem, + SecurityAssessmentPropertiesResponse, + SecurityAssessmentResponse, + SecurityConnector, + SecurityConnectorsList, + SecurityContact, + SecurityContactList, + SecurityContactPropertiesNotificationsByRole, + SecurityOperator, + SecurityOperatorList, + SecuritySolution, + SecuritySolutionList, + SecuritySolutionsReferenceData, + SecuritySolutionsReferenceDataList, + SecurityStandard, + SecurityStandardList, + SecuritySubAssessment, + SecuritySubAssessmentList, + SecurityTask, + SecurityTaskList, + SecurityTaskParameters, + SensitiveDataDiscoveryProperties, + SensitivityLabel, + ServerVulnerabilityAssessment, + ServerVulnerabilityAssessmentsList, + ServerVulnerabilityAssessmentsSetting, + ServerVulnerabilityAssessmentsSettingsList, + ServerVulnerabilityProperties, + ServicePrincipalProperties, + Setting, + SettingsList, + Software, + SoftwaresList, + SqlServerVulnerabilityProperties, + StandardAssignment, + StandardAssignmentMetadata, + StandardAssignmentPropertiesAttestationData, + StandardAssignmentPropertiesExemptionData, + StandardAssignmentsList, + StandardMetadata, + StatusAutoGenerated, + SubAssessmentStatus, + SuppressionAlertsScope, + SystemData, + Tags, + TagsResource, + TargetBranchConfiguration, + ThresholdCustomAlertRule, + TimeWindowCustomAlertRule, + TopologyList, + TopologyResource, + TopologySingleResource, + TopologySingleResourceChild, + TopologySingleResourceParent, + TrackedResource, + TrackedResourceAutoGenerated, + TwinUpdatesNotInAllowedRange, + UnauthorizedOperationsNotInAllowedRange, + UpdateIotSecuritySolutionData, + UpdateSensitivitySettingsRequest, + UserDefinedResourcesProperties, + VaRule, + VendorReference, + VmScannersAws, + VmScannersBase, + VmScannersBaseConfiguration, + VmScannersGcp, + WorkspaceSetting, + WorkspaceSettingList, +) + +from ._security_center_enums import ( # type: ignore + AadConnectivityStateEnum, + ActionType, + ActionableRemediationState, + AdditionalWorkspaceDataType, + AdditionalWorkspaceType, + AgentlessEnablement, + AlertSeverity, + AlertStatus, + AnnotateDefaultBranchState, + ApplicationConditionOperator, + ApplicationSourceResourceType, + AssessedResourceType, + AssessmentStatusCode, + AssessmentType, + AttestationComplianceState, + AuthenticationProvisioningState, + AuthenticationType, + AutoDiscovery, + AutoProvision, + BlobScanResultsOptions, + BundleType, + Categories, + CloudName, + Code, + ConnectionType, + ControlType, + CreatedByType, + DataSource, + DesiredOnboardingState, + DevOpsProvisioningState, + Effect, + EndOfSupportStatus, + Enforce, + EnvironmentType, + EventSource, + ExemptionCategory, + ExpandControlsEnum, + ExpandEnum, + ExportData, + ExternalSecuritySolutionKindEnum, + GovernanceRuleConditionOperator, + GovernanceRuleOwnerSourceType, + GovernanceRuleSourceResourceType, + GovernanceRuleType, + HybridComputeProvisioningState, + ImplementationEffort, + InformationProtectionPolicyName, + InheritFromParentState, + Inherited, + Intent, + InventoryKind, + InventoryListKind, + IsEnabled, + KindEnum, + MinimalRiskLevel, + MinimalSeverity, + MipIntegrationStatus, + OfferingType, + OnboardingState, + OperationResult, + Operator, + OrganizationMembershipType, + Origin, + PermissionProperty, + PricingTier, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + PropertyType, + ProtocolEnum, + ProvisioningState, + Rank, + RecommendationConfigStatus, + RecommendationSupportedClouds, + RecommendationType, + ReportedSeverity, + ResourceIdentifierType, + ResourceStatus, + ResourcesCoverageStatus, + RiskLevel, + RuleCategory, + RuleSeverity, + RuleState, + RuleStatus, + RuleType, + ScanState, + ScanTriggerType, + ScanningMode, + SecurityContactName, + SecurityContactRole, + SecurityFamily, + SecurityIssue, + SecuritySolutionStatus, + ServerVulnerabilityAssessmentPropertiesProvisioningState, + ServerVulnerabilityAssessmentsAzureSettingSelectedProvider, + ServerVulnerabilityAssessmentsSettingKind, + ServerVulnerabilityAssessmentsSettingKindName, + SettingKind, + SettingName, + SettingNameAutoGenerated, + Severity, + SeverityEnum, + Source, + SourceType, + StandardSupportedCloud, + StandardType, + State, + Status, + StatusName, + StatusReason, + SubAssessmentStatusCode, + SubPlan, + SupportedCloudEnum, + Tactics, + TaskUpdateActionType, + Techniques, + Threats, + Type, + UnmaskedIpLoggingStatus, + UserImpact, + ValueType, +) +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AadConnectivityState", + "AadExternalSecuritySolution", + "AadSolutionProperties", + "AccessTokenAuthentication", + "ActionableRemediation", + "ActiveConnectionsNotInAllowedRange", + "AdditionalData", + "AdditionalWorkspacesProperties", + "AdvancedThreatProtectionSetting", + "AgentlessConfiguration", + "Alert", + "AlertEntity", + "AlertList", + "AlertPropertiesSupportingEvidence", + "AlertSimulatorBundlesRequestProperties", + "AlertSimulatorRequestBody", + "AlertSimulatorRequestProperties", + "AlertSyncSettings", + "AlertsSuppressionRule", + "AlertsSuppressionRulesList", + "AllowedConnectionsList", + "AllowedConnectionsResource", + "AllowlistCustomAlertRule", + "AmqpC2DMessagesNotInAllowedRange", + "AmqpC2DRejectedMessagesNotInAllowedRange", + "AmqpD2CMessagesNotInAllowedRange", + "ApiCollection", + "ApiCollectionList", + "Application", + "ApplicationCondition", + "ApplicationsList", + "ArcAutoProvisioning", + "ArcAutoProvisioningAws", + "ArcAutoProvisioningConfiguration", + "ArcAutoProvisioningGcp", + "AscLocation", + "AscLocationList", + "AssessmentLinks", + "AssessmentStatus", + "AssessmentStatusResponse", + "AssignedAssessmentItem", + "AssignedStandardItem", + "AtaExternalSecuritySolution", + "AtaSolutionProperties", + "AttestationEvidence", + "Authentication", + "AuthenticationDetailsProperties", + "Authorization", + "AutoProvisioningSetting", + "AutoProvisioningSettingList", + "Automation", + "AutomationAction", + "AutomationActionEventHub", + "AutomationActionLogicApp", + "AutomationActionWorkspace", + "AutomationList", + "AutomationRuleSet", + "AutomationScope", + "AutomationSource", + "AutomationTriggeringRule", + "AutomationUpdateModel", + "AutomationValidationStatus", + "AwAssumeRoleAuthenticationDetailsProperties", + "AwsCredsAuthenticationDetailsProperties", + "AwsEnvironmentData", + "AwsOrganizationalData", + "AwsOrganizationalDataMaster", + "AwsOrganizationalDataMember", + "AzureDevOpsOrg", + "AzureDevOpsOrgListResponse", + "AzureDevOpsOrgProperties", + "AzureDevOpsOrganizationConfiguration", + "AzureDevOpsProject", + "AzureDevOpsProjectConfiguration", + "AzureDevOpsProjectListResponse", + "AzureDevOpsProjectProperties", + "AzureDevOpsRepository", + "AzureDevOpsRepositoryListResponse", + "AzureDevOpsRepositoryProperties", + "AzureDevOpsScopeEnvironmentData", + "AzureResourceDetails", + "AzureResourceIdentifier", + "AzureResourceLink", + "AzureServersSetting", + "AzureTrackedResourceLocation", + "BaseResourceConfiguration", + "Baseline", + "BaselineAdjustedResult", + "BenchmarkReference", + "BlobsScanSummary", + "BuiltInInfoType", + "CVE", + "CVSS", + "CategoryConfiguration", + "CefExternalSecuritySolution", + "CefSolutionProperties", + "CloudErrorBody", + "CloudOffering", + "Compliance", + "ComplianceList", + "ComplianceResult", + "ComplianceResultList", + "ComplianceSegment", + "Components1Uu4J47SchemasSecurityassessmentpropertiesbasePropertiesRiskPropertiesPathsItemsPropertiesEdgesItems", + "Condition", + "ConnectableResource", + "ConnectedResource", + "ConnectedWorkspace", + "ConnectionFromIpNotAllowed", + "ConnectionToIpNotAllowed", + "ConnectorSetting", + "ConnectorSettingList", + "ContainerRegistryVulnerabilityProperties", + "CspmMonitorAwsOffering", + "CspmMonitorAwsOfferingNativeCloudConnection", + "CspmMonitorAzureDevOpsOffering", + "CspmMonitorDockerHubOffering", + "CspmMonitorGcpOffering", + "CspmMonitorGcpOfferingNativeCloudConnection", + "CspmMonitorGitLabOffering", + "CspmMonitorGithubOffering", + "CspmMonitorJFrogOffering", + "CustomAlertRule", + "CustomAssessmentAutomation", + "CustomAssessmentAutomationRequest", + "CustomAssessmentAutomationsListResult", + "CustomEntityStoreAssignment", + "CustomEntityStoreAssignmentRequest", + "CustomEntityStoreAssignmentsListResult", + "CustomRecommendation", + "CustomRecommendationsList", + "DataExportSettings", + "DefenderCspmAwsOffering", + "DefenderCspmAwsOfferingCiem", + "DefenderCspmAwsOfferingCiemDiscovery", + "DefenderCspmAwsOfferingCiemOidc", + "DefenderCspmAwsOfferingDataSensitivityDiscovery", + "DefenderCspmAwsOfferingDatabasesDspm", + "DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S", + "DefenderCspmAwsOfferingMdcContainersImageAssessment", + "DefenderCspmAwsOfferingVmScanners", + "DefenderCspmDockerHubOffering", + "DefenderCspmGcpOffering", + "DefenderCspmGcpOfferingCiemDiscovery", + "DefenderCspmGcpOfferingDataSensitivityDiscovery", + "DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S", + "DefenderCspmGcpOfferingMdcContainersImageAssessment", + "DefenderCspmGcpOfferingVmScanners", + "DefenderCspmJFrogOffering", + "DefenderCspmJFrogOfferingMdcContainersImageAssessment", + "DefenderFoDatabasesAwsOffering", + "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", + "DefenderFoDatabasesAwsOfferingDatabasesDspm", + "DefenderFoDatabasesAwsOfferingRds", + "DefenderForContainersAwsOffering", + "DefenderForContainersAwsOfferingCloudWatchToKinesis", + "DefenderForContainersAwsOfferingKinesisToS3", + "DefenderForContainersAwsOfferingKubernetesDataCollection", + "DefenderForContainersAwsOfferingKubernetesService", + "DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S", + "DefenderForContainersAwsOfferingMdcContainersImageAssessment", + "DefenderForContainersAwsOfferingVmScanners", + "DefenderForContainersDockerHubOffering", + "DefenderForContainersGcpOffering", + "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", + "DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S", + "DefenderForContainersGcpOfferingMdcContainersImageAssessment", + "DefenderForContainersGcpOfferingNativeCloudConnection", + "DefenderForContainersGcpOfferingVmScanners", + "DefenderForContainersJFrogOffering", + "DefenderForDatabasesGcpOffering", + "DefenderForDatabasesGcpOfferingArcAutoProvisioning", + "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", + "DefenderForServersAwsOffering", + "DefenderForServersAwsOfferingArcAutoProvisioning", + "DefenderForServersAwsOfferingDefenderForServers", + "DefenderForServersAwsOfferingMdeAutoProvisioning", + "DefenderForServersAwsOfferingSubPlan", + "DefenderForServersAwsOfferingVaAutoProvisioning", + "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", + "DefenderForServersAwsOfferingVmScanners", + "DefenderForServersGcpOffering", + "DefenderForServersGcpOfferingArcAutoProvisioning", + "DefenderForServersGcpOfferingDefenderForServers", + "DefenderForServersGcpOfferingMdeAutoProvisioning", + "DefenderForServersGcpOfferingSubPlan", + "DefenderForServersGcpOfferingVaAutoProvisioning", + "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", + "DefenderForServersGcpOfferingVmScanners", + "DefenderForStorageSetting", + "DefenderForStorageSettingProperties", + "DenylistCustomAlertRule", + "DevOpsCapability", + "DevOpsConfiguration", + "DevOpsConfigurationListResponse", + "DevOpsConfigurationProperties", + "DeviceSecurityGroup", + "DeviceSecurityGroupList", + "DirectMethodInvokesNotInAllowedRange", + "DiscoveredSecuritySolution", + "DiscoveredSecuritySolutionList", + "DockerHubEnvironmentData", + "ETag", + "EdgeIdentifiers", + "EnvironmentData", + "EnvironmentDetails", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorDetailAutoGenerated", + "ErrorDetailAutoGenerated2", + "ErrorResponse", + "ErrorResponseAutoGenerated", + "ErrorResponseAutoGenerated2", + "ExecuteGovernanceRuleParams", + "Extension", + "ExternalSecuritySolution", + "ExternalSecuritySolutionKind", + "ExternalSecuritySolutionList", + "ExternalSecuritySolutionProperties", + "FailedLocalLoginsNotInAllowedRange", + "FileUploadsNotInAllowedRange", + "GcpCredentialsDetailsProperties", + "GcpOrganizationalData", + "GcpOrganizationalDataMember", + "GcpOrganizationalDataOrganization", + "GcpProjectDetails", + "GcpProjectEnvironmentData", + "GetSensitivitySettingsListResponse", + "GetSensitivitySettingsResponse", + "GetSensitivitySettingsResponseProperties", + "GetSensitivitySettingsResponsePropertiesMipInformation", + "GitHubOwner", + "GitHubOwnerConfiguration", + "GitHubOwnerListResponse", + "GitHubOwnerProperties", + "GitHubRepository", + "GitHubRepositoryListResponse", + "GitHubRepositoryProperties", + "GitLabGroup", + "GitLabGroupConfiguration", + "GitLabGroupListResponse", + "GitLabGroupProperties", + "GitLabProject", + "GitLabProjectListResponse", + "GitLabProjectProperties", + "GithubScopeEnvironmentData", + "GitlabScopeEnvironmentData", + "GovernanceAssignment", + "GovernanceAssignmentAdditionalData", + "GovernanceAssignmentsList", + "GovernanceEmailNotification", + "GovernanceRule", + "GovernanceRuleEmailNotification", + "GovernanceRuleList", + "GovernanceRuleMetadata", + "GovernanceRuleOwnerSource", + "HealthDataClassification", + "HealthReport", + "HealthReportsList", + "HttpC2DMessagesNotInAllowedRange", + "HttpC2DRejectedMessagesNotInAllowedRange", + "HttpD2CMessagesNotInAllowedRange", + "HybridComputeSettingsProperties", + "Identity", + "InfoType", + "InformationProtectionKeyword", + "InformationProtectionPolicy", + "InformationProtectionPolicyList", + "InformationType", + "InventoryList", + "IoTSecurityAggregatedAlert", + "IoTSecurityAggregatedAlertList", + "IoTSecurityAggregatedAlertPropertiesTopDevicesListItem", + "IoTSecurityAggregatedRecommendation", + "IoTSecurityAggregatedRecommendationList", + "IoTSecurityAlertedDevice", + "IoTSecurityDeviceAlert", + "IoTSecurityDeviceRecommendation", + "IoTSecuritySolutionAnalyticsModel", + "IoTSecuritySolutionAnalyticsModelList", + "IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem", + "IoTSecuritySolutionModel", + "IoTSecuritySolutionsList", + "IoTSeverityMetrics", + "Issue", + "JFrogEnvironmentData", + "JitNetworkAccessPoliciesList", + "JitNetworkAccessPolicy", + "JitNetworkAccessPolicyInitiatePort", + "JitNetworkAccessPolicyInitiateRequest", + "JitNetworkAccessPolicyInitiateVirtualMachine", + "JitNetworkAccessPolicyVirtualMachine", + "JitNetworkAccessPortRule", + "JitNetworkAccessRequest", + "JitNetworkAccessRequestPort", + "JitNetworkAccessRequestVirtualMachine", + "Kind", + "Label", + "ListCustomAlertRule", + "LocalUserNotAllowed", + "Location", + "LogAnalyticsIdentifier", + "MalwareScan", + "MalwareScanProperties", + "MalwareScanningProperties", + "MdeOnboardingData", + "MdeOnboardingDataList", + "MqttC2DMessagesNotInAllowedRange", + "MqttC2DRejectedMessagesNotInAllowedRange", + "MqttD2CMessagesNotInAllowedRange", + "NodeIdentifier", + "NotificationsSource", + "NotificationsSourceAlert", + "NotificationsSourceAttackPath", + "OnPremiseResourceDetails", + "OnPremiseSqlResourceDetails", + "OnUploadFilters", + "OnUploadProperties", + "Operation", + "OperationDisplay", + "OperationListResult", + "OperationResultAutoGenerated", + "OperationStatus", + "OperationStatusAutoGenerated", + "OperationStatusResult", + "PartialAssessmentProperties", + "Path", + "Pricing", + "PricingList", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkParameters", + "PrivateLinkResource", + "PrivateLinkResourceAutoGenerated", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "PrivateLinkUpdate", + "PrivateLinksList", + "ProcessNotAllowed", + "ProxyResource", + "ProxyServerProperties", + "QueryCheck", + "QueuePurgesNotInAllowedRange", + "RecommendationConfigurationProperties", + "RegulatoryComplianceAssessment", + "RegulatoryComplianceAssessmentList", + "RegulatoryComplianceControl", + "RegulatoryComplianceControlList", + "RegulatoryComplianceStandard", + "RegulatoryComplianceStandardList", + "Remediation", + "RemediationEta", + "Resource", + "ResourceAutoGenerated", + "ResourceAutoGenerated2", + "ResourceAutoGenerated3", + "ResourceDetails", + "ResourceDetailsAutoGenerated", + "ResourceIdentifier", + "RuleResults", + "RuleResultsInput", + "RuleResultsProperties", + "RulesResults", + "RulesResultsInput", + "Scan", + "ScanProperties", + "ScanResult", + "ScanResultProperties", + "ScanResults", + "ScanSummary", + "Scans", + "ScopeElement", + "SecureScoreControlDefinitionItem", + "SecureScoreControlDefinitionList", + "SecureScoreControlDefinitionSource", + "SecureScoreControlDetails", + "SecureScoreControlList", + "SecureScoreControlScore", + "SecureScoreItem", + "SecureScoresList", + "SecurityAssessment", + "SecurityAssessmentList", + "SecurityAssessmentMetadata", + "SecurityAssessmentMetadataPartnerData", + "SecurityAssessmentMetadataProperties", + "SecurityAssessmentMetadataPropertiesResponse", + "SecurityAssessmentMetadataPropertiesResponsePublishDates", + "SecurityAssessmentMetadataResponse", + "SecurityAssessmentMetadataResponseList", + "SecurityAssessmentPartnerData", + "SecurityAssessmentProperties", + "SecurityAssessmentPropertiesBase", + "SecurityAssessmentPropertiesBaseRisk", + "SecurityAssessmentPropertiesBaseRiskPathsItem", + "SecurityAssessmentPropertiesBaseRiskPathsPropertiesItemsItem", + "SecurityAssessmentPropertiesResponse", + "SecurityAssessmentResponse", + "SecurityConnector", + "SecurityConnectorsList", + "SecurityContact", + "SecurityContactList", + "SecurityContactPropertiesNotificationsByRole", + "SecurityOperator", + "SecurityOperatorList", + "SecuritySolution", + "SecuritySolutionList", + "SecuritySolutionsReferenceData", + "SecuritySolutionsReferenceDataList", + "SecurityStandard", + "SecurityStandardList", + "SecuritySubAssessment", + "SecuritySubAssessmentList", + "SecurityTask", + "SecurityTaskList", + "SecurityTaskParameters", + "SensitiveDataDiscoveryProperties", + "SensitivityLabel", + "ServerVulnerabilityAssessment", + "ServerVulnerabilityAssessmentsList", + "ServerVulnerabilityAssessmentsSetting", + "ServerVulnerabilityAssessmentsSettingsList", + "ServerVulnerabilityProperties", + "ServicePrincipalProperties", + "Setting", + "SettingsList", + "Software", + "SoftwaresList", + "SqlServerVulnerabilityProperties", + "StandardAssignment", + "StandardAssignmentMetadata", + "StandardAssignmentPropertiesAttestationData", + "StandardAssignmentPropertiesExemptionData", + "StandardAssignmentsList", + "StandardMetadata", + "StatusAutoGenerated", + "SubAssessmentStatus", + "SuppressionAlertsScope", + "SystemData", + "Tags", + "TagsResource", + "TargetBranchConfiguration", + "ThresholdCustomAlertRule", + "TimeWindowCustomAlertRule", + "TopologyList", + "TopologyResource", + "TopologySingleResource", + "TopologySingleResourceChild", + "TopologySingleResourceParent", + "TrackedResource", + "TrackedResourceAutoGenerated", + "TwinUpdatesNotInAllowedRange", + "UnauthorizedOperationsNotInAllowedRange", + "UpdateIotSecuritySolutionData", + "UpdateSensitivitySettingsRequest", + "UserDefinedResourcesProperties", + "VaRule", + "VendorReference", + "VmScannersAws", + "VmScannersBase", + "VmScannersBaseConfiguration", + "VmScannersGcp", + "WorkspaceSetting", + "WorkspaceSettingList", + "AadConnectivityStateEnum", + "ActionType", + "ActionableRemediationState", + "AdditionalWorkspaceDataType", + "AdditionalWorkspaceType", + "AgentlessEnablement", + "AlertSeverity", + "AlertStatus", + "AnnotateDefaultBranchState", + "ApplicationConditionOperator", + "ApplicationSourceResourceType", + "AssessedResourceType", + "AssessmentStatusCode", + "AssessmentType", + "AttestationComplianceState", + "AuthenticationProvisioningState", + "AuthenticationType", + "AutoDiscovery", + "AutoProvision", + "BlobScanResultsOptions", + "BundleType", + "Categories", + "CloudName", + "Code", + "ConnectionType", + "ControlType", + "CreatedByType", + "DataSource", + "DesiredOnboardingState", + "DevOpsProvisioningState", + "Effect", + "EndOfSupportStatus", + "Enforce", + "EnvironmentType", + "EventSource", + "ExemptionCategory", + "ExpandControlsEnum", + "ExpandEnum", + "ExportData", + "ExternalSecuritySolutionKindEnum", + "GovernanceRuleConditionOperator", + "GovernanceRuleOwnerSourceType", + "GovernanceRuleSourceResourceType", + "GovernanceRuleType", + "HybridComputeProvisioningState", + "ImplementationEffort", + "InformationProtectionPolicyName", + "InheritFromParentState", + "Inherited", + "Intent", + "InventoryKind", + "InventoryListKind", + "IsEnabled", + "KindEnum", + "MinimalRiskLevel", + "MinimalSeverity", + "MipIntegrationStatus", + "OfferingType", + "OnboardingState", + "OperationResult", + "Operator", + "OrganizationMembershipType", + "Origin", + "PermissionProperty", + "PricingTier", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "PropertyType", + "ProtocolEnum", + "ProvisioningState", + "Rank", + "RecommendationConfigStatus", + "RecommendationSupportedClouds", + "RecommendationType", + "ReportedSeverity", + "ResourceIdentifierType", + "ResourceStatus", + "ResourcesCoverageStatus", + "RiskLevel", + "RuleCategory", + "RuleSeverity", + "RuleState", + "RuleStatus", + "RuleType", + "ScanState", + "ScanTriggerType", + "ScanningMode", + "SecurityContactName", + "SecurityContactRole", + "SecurityFamily", + "SecurityIssue", + "SecuritySolutionStatus", + "ServerVulnerabilityAssessmentPropertiesProvisioningState", + "ServerVulnerabilityAssessmentsAzureSettingSelectedProvider", + "ServerVulnerabilityAssessmentsSettingKind", + "ServerVulnerabilityAssessmentsSettingKindName", + "SettingKind", + "SettingName", + "SettingNameAutoGenerated", + "Severity", + "SeverityEnum", + "Source", + "SourceType", + "StandardSupportedCloud", + "StandardType", + "State", + "Status", + "StatusName", + "StatusReason", + "SubAssessmentStatusCode", + "SubPlan", + "SupportedCloudEnum", + "Tactics", + "TaskUpdateActionType", + "Techniques", + "Threats", + "Type", + "UnmaskedIpLoggingStatus", + "UserImpact", + "ValueType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_models_py3.py new file mode 100644 index 000000000000..39db8630741e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_models_py3.py @@ -0,0 +1,21765 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from collections.abc import MutableMapping +import datetime +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union + +from .._utils import serialization as _serialization + +if TYPE_CHECKING: + from .. import models as _models +JSON = MutableMapping[str, Any] + + +class AadConnectivityState(_serialization.Model): + """Describes an Azure resource with kind. + + :ivar connectivity_state: The connectivity state of the external AAD solution. Known values + are: "Discovered", "NotLicensed", and "Connected". + :vartype connectivity_state: str or ~azure.mgmt.security.models.AadConnectivityStateEnum + """ + + _attribute_map = { + "connectivity_state": {"key": "connectivityState", "type": "str"}, + } + + def __init__( + self, *, connectivity_state: Optional[Union[str, "_models.AadConnectivityStateEnum"]] = None, **kwargs: Any + ) -> None: + """ + :keyword connectivity_state: The connectivity state of the external AAD solution. Known values + are: "Discovered", "NotLicensed", and "Connected". + :paramtype connectivity_state: str or ~azure.mgmt.security.models.AadConnectivityStateEnum + """ + super().__init__(**kwargs) + self.connectivity_state = connectivity_state + + +class Location(_serialization.Model): + """Describes an Azure resource with location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location where the resource is stored. + :vartype location: str + """ + + _validation = { + "location": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.location: Optional[str] = None + + +class ExternalSecuritySolutionKind(_serialization.Model): + """Describes an Azure resource with kind. + + :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :vartype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + """ + + _attribute_map = { + "kind": {"key": "kind", "type": "str"}, + } + + def __init__( + self, *, kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, **kwargs: Any + ) -> None: + """ + :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :paramtype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + """ + super().__init__(**kwargs) + self.kind = kind + + +class Resource(_serialization.Model): + """Describes an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class ExternalSecuritySolution(Resource, ExternalSecuritySolutionKind, Location): + """Represents a security solution external to Microsoft Defender for Cloud which sends information + to an OMS workspace and whose data is displayed by Microsoft Defender for Cloud. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :vartype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, *, kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, **kwargs: Any + ) -> None: + """ + :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :paramtype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + """ + super().__init__(kind=kind, **kwargs) + self.location: Optional[str] = None + self.kind = kind + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class AadExternalSecuritySolution(ExternalSecuritySolution): + """Represents an AAD identity protection solution which sends logs to an OMS workspace. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :vartype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: The external security solution properties for AAD solutions. + :vartype properties: ~azure.mgmt.security.models.AadSolutionProperties + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "AadSolutionProperties"}, + } + + def __init__( + self, + *, + kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, + properties: Optional["_models.AadSolutionProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :paramtype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + :keyword properties: The external security solution properties for AAD solutions. + :paramtype properties: ~azure.mgmt.security.models.AadSolutionProperties + """ + super().__init__(kind=kind, **kwargs) + self.properties = properties + + +class ExternalSecuritySolutionProperties(_serialization.Model): + """The solution properties (correspond to the solution kind). + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar device_vendor: + :vartype device_vendor: str + :ivar device_type: + :vartype device_type: str + :ivar workspace: Represents an OMS workspace to which the solution is connected. + :vartype workspace: ~azure.mgmt.security.models.ConnectedWorkspace + """ + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "device_vendor": {"key": "deviceVendor", "type": "str"}, + "device_type": {"key": "deviceType", "type": "str"}, + "workspace": {"key": "workspace", "type": "ConnectedWorkspace"}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, Any]] = None, + device_vendor: Optional[str] = None, + device_type: Optional[str] = None, + workspace: Optional["_models.ConnectedWorkspace"] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword device_vendor: + :paramtype device_vendor: str + :keyword device_type: + :paramtype device_type: str + :keyword workspace: Represents an OMS workspace to which the solution is connected. + :paramtype workspace: ~azure.mgmt.security.models.ConnectedWorkspace + """ + super().__init__(**kwargs) + self.additional_properties = additional_properties + self.device_vendor = device_vendor + self.device_type = device_type + self.workspace = workspace + + +class AadSolutionProperties(ExternalSecuritySolutionProperties, AadConnectivityState): + """The external security solution properties for AAD solutions. + + :ivar connectivity_state: The connectivity state of the external AAD solution. Known values + are: "Discovered", "NotLicensed", and "Connected". + :vartype connectivity_state: str or ~azure.mgmt.security.models.AadConnectivityStateEnum + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar device_vendor: + :vartype device_vendor: str + :ivar device_type: + :vartype device_type: str + :ivar workspace: Represents an OMS workspace to which the solution is connected. + :vartype workspace: ~azure.mgmt.security.models.ConnectedWorkspace + """ + + _attribute_map = { + "connectivity_state": {"key": "connectivityState", "type": "str"}, + "additional_properties": {"key": "", "type": "{object}"}, + "device_vendor": {"key": "deviceVendor", "type": "str"}, + "device_type": {"key": "deviceType", "type": "str"}, + "workspace": {"key": "workspace", "type": "ConnectedWorkspace"}, + } + + def __init__( + self, + *, + connectivity_state: Optional[Union[str, "_models.AadConnectivityStateEnum"]] = None, + additional_properties: Optional[Dict[str, Any]] = None, + device_vendor: Optional[str] = None, + device_type: Optional[str] = None, + workspace: Optional["_models.ConnectedWorkspace"] = None, + **kwargs: Any + ) -> None: + """ + :keyword connectivity_state: The connectivity state of the external AAD solution. Known values + are: "Discovered", "NotLicensed", and "Connected". + :paramtype connectivity_state: str or ~azure.mgmt.security.models.AadConnectivityStateEnum + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword device_vendor: + :paramtype device_vendor: str + :keyword device_type: + :paramtype device_type: str + :keyword workspace: Represents an OMS workspace to which the solution is connected. + :paramtype workspace: ~azure.mgmt.security.models.ConnectedWorkspace + """ + super().__init__( + additional_properties=additional_properties, + device_vendor=device_vendor, + device_type=device_type, + workspace=workspace, + connectivity_state=connectivity_state, + **kwargs + ) + self.connectivity_state = connectivity_state + self.additional_properties = additional_properties + self.device_vendor = device_vendor + self.device_type = device_type + self.workspace = workspace + + +class Authentication(_serialization.Model): + """The environment authentication details. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AccessTokenAuthentication + + All required parameters must be populated in order to send to server. + + :ivar authentication_type: The authentication type. Required. Known values are: "awsCreds", + "awsAssumeRole", and "gcpCredentials". + :vartype authentication_type: str or ~azure.mgmt.security.models.AuthenticationType + """ + + _validation = { + "authentication_type": {"required": True}, + } + + _attribute_map = { + "authentication_type": {"key": "authenticationType", "type": "str"}, + } + + _subtype_map = {"authentication_type": {"AccessToken": "AccessTokenAuthentication"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.authentication_type: Optional[str] = None + + +class AccessTokenAuthentication(Authentication): + """The environment authentication details. + + All required parameters must be populated in order to send to server. + + :ivar authentication_type: The authentication type. Required. Known values are: "awsCreds", + "awsAssumeRole", and "gcpCredentials". + :vartype authentication_type: str or ~azure.mgmt.security.models.AuthenticationType + :ivar username: The user name that will be used while authenticating with the onboarded + environment. + :vartype username: str + :ivar access_token: The access token that will be used while authenticating with the onboarded + environment. + :vartype access_token: str + """ + + _validation = { + "authentication_type": {"required": True}, + } + + _attribute_map = { + "authentication_type": {"key": "authenticationType", "type": "str"}, + "username": {"key": "username", "type": "str"}, + "access_token": {"key": "accessToken", "type": "str"}, + } + + def __init__(self, *, username: Optional[str] = None, access_token: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword username: The user name that will be used while authenticating with the onboarded + environment. + :paramtype username: str + :keyword access_token: The access token that will be used while authenticating with the + onboarded environment. + :paramtype access_token: str + """ + super().__init__(**kwargs) + self.authentication_type: str = "AccessToken" + self.username = username + self.access_token = access_token + + +class ActionableRemediation(_serialization.Model): + """Configuration payload for PR Annotations. + + :ivar state: ActionableRemediation Setting. + None - the setting was never set. + Enabled - ActionableRemediation is enabled. + Disabled - ActionableRemediation is disabled. Known values are: "None", "Disabled", and + "Enabled". + :vartype state: str or ~azure.mgmt.security.models.ActionableRemediationState + :ivar category_configurations: Gets or sets list of categories and severity levels. + :vartype category_configurations: list[~azure.mgmt.security.models.CategoryConfiguration] + :ivar branch_configuration: Repository branch configuration for PR Annotations. + :vartype branch_configuration: ~azure.mgmt.security.models.TargetBranchConfiguration + :ivar inherit_from_parent_state: Update Settings. + + Enabled - Resource should inherit configurations from parent. + Disabled - Resource should not inherit configurations from parent. Known values are: "Disabled" + and "Enabled". + :vartype inherit_from_parent_state: str or ~azure.mgmt.security.models.InheritFromParentState + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "category_configurations": {"key": "categoryConfigurations", "type": "[CategoryConfiguration]"}, + "branch_configuration": {"key": "branchConfiguration", "type": "TargetBranchConfiguration"}, + "inherit_from_parent_state": {"key": "inheritFromParentState", "type": "str"}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.ActionableRemediationState"]] = None, + category_configurations: Optional[List["_models.CategoryConfiguration"]] = None, + branch_configuration: Optional["_models.TargetBranchConfiguration"] = None, + inherit_from_parent_state: Optional[Union[str, "_models.InheritFromParentState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword state: ActionableRemediation Setting. + None - the setting was never set. + Enabled - ActionableRemediation is enabled. + Disabled - ActionableRemediation is disabled. Known values are: "None", "Disabled", and + "Enabled". + :paramtype state: str or ~azure.mgmt.security.models.ActionableRemediationState + :keyword category_configurations: Gets or sets list of categories and severity levels. + :paramtype category_configurations: list[~azure.mgmt.security.models.CategoryConfiguration] + :keyword branch_configuration: Repository branch configuration for PR Annotations. + :paramtype branch_configuration: ~azure.mgmt.security.models.TargetBranchConfiguration + :keyword inherit_from_parent_state: Update Settings. + + Enabled - Resource should inherit configurations from parent. + Disabled - Resource should not inherit configurations from parent. Known values are: "Disabled" + and "Enabled". + :paramtype inherit_from_parent_state: str or ~azure.mgmt.security.models.InheritFromParentState + """ + super().__init__(**kwargs) + self.state = state + self.category_configurations = category_configurations + self.branch_configuration = branch_configuration + self.inherit_from_parent_state = inherit_from_parent_state + + +class CustomAlertRule(_serialization.Model): + """A custom alert rule. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ListCustomAlertRule, ThresholdCustomAlertRule + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + } + + _subtype_map = { + "rule_type": { + "ListCustomAlertRule": "ListCustomAlertRule", + "ThresholdCustomAlertRule": "ThresholdCustomAlertRule", + } + } + + def __init__(self, *, is_enabled: bool, **kwargs: Any) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.display_name: Optional[str] = None + self.description: Optional[str] = None + self.is_enabled = is_enabled + self.rule_type: Optional[str] = None + + +class ThresholdCustomAlertRule(CustomAlertRule): + """A custom alert rule that checks if a value (depends on the custom alert type) is within the + given range. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + TimeWindowCustomAlertRule + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + } + + _subtype_map = {"rule_type": {"TimeWindowCustomAlertRule": "TimeWindowCustomAlertRule"}} + + def __init__(self, *, is_enabled: bool, min_threshold: int, max_threshold: int, **kwargs: Any) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + """ + super().__init__(is_enabled=is_enabled, **kwargs) + self.rule_type: str = "ThresholdCustomAlertRule" + self.min_threshold = min_threshold + self.max_threshold = max_threshold + + +class TimeWindowCustomAlertRule(ThresholdCustomAlertRule): + """A custom alert rule that checks if the number of activities (depends on the custom alert type) + in a time window is within the given range. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ActiveConnectionsNotInAllowedRange, AmqpC2DMessagesNotInAllowedRange, + AmqpC2DRejectedMessagesNotInAllowedRange, AmqpD2CMessagesNotInAllowedRange, + DirectMethodInvokesNotInAllowedRange, FailedLocalLoginsNotInAllowedRange, + FileUploadsNotInAllowedRange, HttpC2DMessagesNotInAllowedRange, + HttpC2DRejectedMessagesNotInAllowedRange, HttpD2CMessagesNotInAllowedRange, + MqttC2DMessagesNotInAllowedRange, MqttC2DRejectedMessagesNotInAllowedRange, + MqttD2CMessagesNotInAllowedRange, QueuePurgesNotInAllowedRange, TwinUpdatesNotInAllowedRange, + UnauthorizedOperationsNotInAllowedRange + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + _subtype_map = { + "rule_type": { + "ActiveConnectionsNotInAllowedRange": "ActiveConnectionsNotInAllowedRange", + "AmqpC2DMessagesNotInAllowedRange": "AmqpC2DMessagesNotInAllowedRange", + "AmqpC2DRejectedMessagesNotInAllowedRange": "AmqpC2DRejectedMessagesNotInAllowedRange", + "AmqpD2CMessagesNotInAllowedRange": "AmqpD2CMessagesNotInAllowedRange", + "DirectMethodInvokesNotInAllowedRange": "DirectMethodInvokesNotInAllowedRange", + "FailedLocalLoginsNotInAllowedRange": "FailedLocalLoginsNotInAllowedRange", + "FileUploadsNotInAllowedRange": "FileUploadsNotInAllowedRange", + "HttpC2DMessagesNotInAllowedRange": "HttpC2DMessagesNotInAllowedRange", + "HttpC2DRejectedMessagesNotInAllowedRange": "HttpC2DRejectedMessagesNotInAllowedRange", + "HttpD2CMessagesNotInAllowedRange": "HttpD2CMessagesNotInAllowedRange", + "MqttC2DMessagesNotInAllowedRange": "MqttC2DMessagesNotInAllowedRange", + "MqttC2DRejectedMessagesNotInAllowedRange": "MqttC2DRejectedMessagesNotInAllowedRange", + "MqttD2CMessagesNotInAllowedRange": "MqttD2CMessagesNotInAllowedRange", + "QueuePurgesNotInAllowedRange": "QueuePurgesNotInAllowedRange", + "TwinUpdatesNotInAllowedRange": "TwinUpdatesNotInAllowedRange", + "UnauthorizedOperationsNotInAllowedRange": "UnauthorizedOperationsNotInAllowedRange", + } + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, **kwargs) + self.rule_type: str = "TimeWindowCustomAlertRule" + self.time_window_size = time_window_size + + +class ActiveConnectionsNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of active connections is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "ActiveConnectionsNotInAllowedRange" + + +class AdditionalData(_serialization.Model): + """Details of the sub-assessment. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContainerRegistryVulnerabilityProperties, ServerVulnerabilityProperties, + SqlServerVulnerabilityProperties + + All required parameters must be populated in order to send to server. + + :ivar assessed_resource_type: Sub-assessment resource type. Required. Known values are: + "SqlServerVulnerability", "ContainerRegistryVulnerability", and "ServerVulnerability". + :vartype assessed_resource_type: str or ~azure.mgmt.security.models.AssessedResourceType + """ + + _validation = { + "assessed_resource_type": {"required": True}, + } + + _attribute_map = { + "assessed_resource_type": {"key": "assessedResourceType", "type": "str"}, + } + + _subtype_map = { + "assessed_resource_type": { + "ContainerRegistryVulnerability": "ContainerRegistryVulnerabilityProperties", + "ServerVulnerabilityAssessment": "ServerVulnerabilityProperties", + "SqlServerVulnerability": "SqlServerVulnerabilityProperties", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.assessed_resource_type: Optional[str] = None + + +class AdditionalWorkspacesProperties(_serialization.Model): + """Properties of the additional workspaces. + + :ivar workspace: Workspace resource id. + :vartype workspace: str + :ivar type: Workspace type. "Sentinel" + :vartype type: str or ~azure.mgmt.security.models.AdditionalWorkspaceType + :ivar data_types: List of data types sent to workspace. + :vartype data_types: list[str or ~azure.mgmt.security.models.AdditionalWorkspaceDataType] + """ + + _attribute_map = { + "workspace": {"key": "workspace", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "data_types": {"key": "dataTypes", "type": "[str]"}, + } + + def __init__( + self, + *, + workspace: Optional[str] = None, + type: Union[str, "_models.AdditionalWorkspaceType"] = "Sentinel", + data_types: Optional[List[Union[str, "_models.AdditionalWorkspaceDataType"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword workspace: Workspace resource id. + :paramtype workspace: str + :keyword type: Workspace type. "Sentinel" + :paramtype type: str or ~azure.mgmt.security.models.AdditionalWorkspaceType + :keyword data_types: List of data types sent to workspace. + :paramtype data_types: list[str or ~azure.mgmt.security.models.AdditionalWorkspaceDataType] + """ + super().__init__(**kwargs) + self.workspace = workspace + self.type = type + self.data_types = data_types + + +class AdvancedThreatProtectionSetting(Resource): + """The Advanced Threat Protection resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar is_enabled: Indicates whether Advanced Threat Protection is enabled. + :vartype is_enabled: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + } + + def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword is_enabled: Indicates whether Advanced Threat Protection is enabled. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.is_enabled = is_enabled + + +class AgentlessConfiguration(_serialization.Model): + """Details about Agentless configuration. + + :ivar agentless_enabled: Agentless Enablement states. Known values are: "Disabled", "Enabled", + and "NotApplicable". + :vartype agentless_enabled: str or ~azure.mgmt.security.models.AgentlessEnablement + :ivar agentless_auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", + and "NotApplicable". + :vartype agentless_auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :ivar scanners: Gets or sets the scanners for the connector. + :vartype scanners: list[str] + :ivar inventory_list_type: Types for inventory list. Known values are: "Inclusion" and + "Exclusion". + :vartype inventory_list_type: str or ~azure.mgmt.security.models.InventoryListKind + :ivar inventory_list: Gets or sets the inventory list for inclusion or exclusion from + Agentless. + Will be ignored if agentless auto-discovery is enabled. + :vartype inventory_list: list[~azure.mgmt.security.models.InventoryList] + """ + + _attribute_map = { + "agentless_enabled": {"key": "agentlessEnabled", "type": "str"}, + "agentless_auto_discovery": {"key": "agentlessAutoDiscovery", "type": "str"}, + "scanners": {"key": "scanners", "type": "[str]"}, + "inventory_list_type": {"key": "inventoryListType", "type": "str"}, + "inventory_list": {"key": "inventoryList", "type": "[InventoryList]"}, + } + + def __init__( + self, + *, + agentless_enabled: Optional[Union[str, "_models.AgentlessEnablement"]] = None, + agentless_auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + scanners: Optional[List[str]] = None, + inventory_list_type: Optional[Union[str, "_models.InventoryListKind"]] = None, + inventory_list: Optional[List["_models.InventoryList"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword agentless_enabled: Agentless Enablement states. Known values are: "Disabled", + "Enabled", and "NotApplicable". + :paramtype agentless_enabled: str or ~azure.mgmt.security.models.AgentlessEnablement + :keyword agentless_auto_discovery: AutoDiscovery states. Known values are: "Disabled", + "Enabled", and "NotApplicable". + :paramtype agentless_auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :keyword scanners: Gets or sets the scanners for the connector. + :paramtype scanners: list[str] + :keyword inventory_list_type: Types for inventory list. Known values are: "Inclusion" and + "Exclusion". + :paramtype inventory_list_type: str or ~azure.mgmt.security.models.InventoryListKind + :keyword inventory_list: Gets or sets the inventory list for inclusion or exclusion from + Agentless. + Will be ignored if agentless auto-discovery is enabled. + :paramtype inventory_list: list[~azure.mgmt.security.models.InventoryList] + """ + super().__init__(**kwargs) + self.agentless_enabled = agentless_enabled + self.agentless_auto_discovery = agentless_auto_discovery + self.scanners = scanners + self.inventory_list_type = inventory_list_type + self.inventory_list = inventory_list + + +class Alert(Resource): + """Security alert. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar version: Schema version. + :vartype version: str + :ivar alert_type: Unique identifier for the detection logic (all alert instances from the same + detection logic will have the same alertType). + :vartype alert_type: str + :ivar system_alert_id: Unique identifier for the alert. + :vartype system_alert_id: str + :ivar product_component_name: The name of Azure Security Center pricing tier which powering + this alert. Learn more: + https://docs.microsoft.com/en-us/azure/security-center/security-center-pricing. + :vartype product_component_name: str + :ivar alert_display_name: The display name of the alert. + :vartype alert_display_name: str + :ivar description: Description of the suspicious activity that was detected. + :vartype description: str + :ivar severity: The risk level of the threat that was detected. Learn more: + https://docs.microsoft.com/en-us/azure/security-center/security-center-alerts-overview#how-are-alerts-classified. + Known values are: "Informational", "Low", "Medium", and "High". + :vartype severity: str or ~azure.mgmt.security.models.AlertSeverity + :ivar intent: The kill chain related intent behind the alert. For list of supported values, and + explanations of Azure Security Center's supported kill chain intents. Known values are: + "Unknown", "PreAttack", "InitialAccess", "Persistence", "PrivilegeEscalation", + "DefenseEvasion", "CredentialAccess", "Discovery", "LateralMovement", "Execution", + "Collection", "Exfiltration", "CommandAndControl", "Impact", "Probing", and "Exploitation". + :vartype intent: str or ~azure.mgmt.security.models.Intent + :ivar start_time_utc: The UTC time of the first event or activity included in the alert in + ISO8601 format. + :vartype start_time_utc: ~datetime.datetime + :ivar end_time_utc: The UTC time of the last event or activity included in the alert in ISO8601 + format. + :vartype end_time_utc: ~datetime.datetime + :ivar resource_identifiers: The resource identifiers that can be used to direct the alert to + the right product exposure group (tenant, workspace, subscription etc.). There can be multiple + identifiers of different type per alert. + :vartype resource_identifiers: list[~azure.mgmt.security.models.ResourceIdentifier] + :ivar remediation_steps: Manual action items to take to remediate the alert. + :vartype remediation_steps: list[str] + :ivar vendor_name: The name of the vendor that raises the alert. + :vartype vendor_name: str + :ivar status: The life cycle status of the alert. Known values are: "Active", "InProgress", + "Resolved", and "Dismissed". + :vartype status: str or ~azure.mgmt.security.models.AlertStatus + :ivar extended_links: Links related to the alert. + :vartype extended_links: list[dict[str, str]] + :ivar alert_uri: A direct link to the alert page in Azure Portal. + :vartype alert_uri: str + :ivar time_generated_utc: The UTC time the alert was generated in ISO8601 format. + :vartype time_generated_utc: ~datetime.datetime + :ivar product_name: The name of the product which published this alert (Microsoft Sentinel, + Microsoft Defender for Identity, Microsoft Defender for Endpoint, Microsoft Defender for + Office, Microsoft Defender for Cloud Apps, and so on). + :vartype product_name: str + :ivar processing_end_time_utc: The UTC processing end time of the alert in ISO8601 format. + :vartype processing_end_time_utc: ~datetime.datetime + :ivar entities: A list of entities related to the alert. + :vartype entities: list[~azure.mgmt.security.models.AlertEntity] + :ivar is_incident: This field determines whether the alert is an incident (a compound grouping + of several alerts) or a single alert. + :vartype is_incident: bool + :ivar correlation_key: Key for corelating related alerts. Alerts with the same correlation key + considered to be related. + :vartype correlation_key: str + :ivar extended_properties: Custom properties for the alert. + :vartype extended_properties: dict[str, str] + :ivar compromised_entity: The display name of the resource most related to this alert. + :vartype compromised_entity: str + :ivar techniques: kill chain related techniques behind the alert. + :vartype techniques: list[str] + :ivar sub_techniques: Kill chain related sub-techniques behind the alert. + :vartype sub_techniques: list[str] + :ivar supporting_evidence: Changing set of properties depending on the supportingEvidence type. + :vartype supporting_evidence: ~azure.mgmt.security.models.AlertPropertiesSupportingEvidence + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "version": {"readonly": True}, + "alert_type": {"readonly": True}, + "system_alert_id": {"readonly": True}, + "product_component_name": {"readonly": True}, + "alert_display_name": {"readonly": True}, + "description": {"readonly": True}, + "severity": {"readonly": True}, + "intent": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "resource_identifiers": {"readonly": True}, + "remediation_steps": {"readonly": True}, + "vendor_name": {"readonly": True}, + "status": {"readonly": True}, + "extended_links": {"readonly": True}, + "alert_uri": {"readonly": True}, + "time_generated_utc": {"readonly": True}, + "product_name": {"readonly": True}, + "processing_end_time_utc": {"readonly": True}, + "entities": {"readonly": True}, + "is_incident": {"readonly": True}, + "correlation_key": {"readonly": True}, + "compromised_entity": {"readonly": True}, + "techniques": {"readonly": True}, + "sub_techniques": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "system_alert_id": {"key": "properties.systemAlertId", "type": "str"}, + "product_component_name": {"key": "properties.productComponentName", "type": "str"}, + "alert_display_name": {"key": "properties.alertDisplayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "intent": {"key": "properties.intent", "type": "str"}, + "start_time_utc": {"key": "properties.startTimeUtc", "type": "iso-8601"}, + "end_time_utc": {"key": "properties.endTimeUtc", "type": "iso-8601"}, + "resource_identifiers": {"key": "properties.resourceIdentifiers", "type": "[ResourceIdentifier]"}, + "remediation_steps": {"key": "properties.remediationSteps", "type": "[str]"}, + "vendor_name": {"key": "properties.vendorName", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "extended_links": {"key": "properties.extendedLinks", "type": "[{str}]"}, + "alert_uri": {"key": "properties.alertUri", "type": "str"}, + "time_generated_utc": {"key": "properties.timeGeneratedUtc", "type": "iso-8601"}, + "product_name": {"key": "properties.productName", "type": "str"}, + "processing_end_time_utc": {"key": "properties.processingEndTimeUtc", "type": "iso-8601"}, + "entities": {"key": "properties.entities", "type": "[AlertEntity]"}, + "is_incident": {"key": "properties.isIncident", "type": "bool"}, + "correlation_key": {"key": "properties.correlationKey", "type": "str"}, + "extended_properties": {"key": "properties.extendedProperties", "type": "{str}"}, + "compromised_entity": {"key": "properties.compromisedEntity", "type": "str"}, + "techniques": {"key": "properties.techniques", "type": "[str]"}, + "sub_techniques": {"key": "properties.subTechniques", "type": "[str]"}, + "supporting_evidence": {"key": "properties.supportingEvidence", "type": "AlertPropertiesSupportingEvidence"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + extended_properties: Optional[Dict[str, str]] = None, + supporting_evidence: Optional["_models.AlertPropertiesSupportingEvidence"] = None, + **kwargs: Any + ) -> None: + """ + :keyword extended_properties: Custom properties for the alert. + :paramtype extended_properties: dict[str, str] + :keyword supporting_evidence: Changing set of properties depending on the supportingEvidence + type. + :paramtype supporting_evidence: ~azure.mgmt.security.models.AlertPropertiesSupportingEvidence + """ + super().__init__(**kwargs) + self.version: Optional[str] = None + self.alert_type: Optional[str] = None + self.system_alert_id: Optional[str] = None + self.product_component_name: Optional[str] = None + self.alert_display_name: Optional[str] = None + self.description: Optional[str] = None + self.severity: Optional[Union[str, "_models.AlertSeverity"]] = None + self.intent: Optional[Union[str, "_models.Intent"]] = None + self.start_time_utc: Optional[datetime.datetime] = None + self.end_time_utc: Optional[datetime.datetime] = None + self.resource_identifiers: Optional[List["_models.ResourceIdentifier"]] = None + self.remediation_steps: Optional[List[str]] = None + self.vendor_name: Optional[str] = None + self.status: Optional[Union[str, "_models.AlertStatus"]] = None + self.extended_links: Optional[List[Dict[str, str]]] = None + self.alert_uri: Optional[str] = None + self.time_generated_utc: Optional[datetime.datetime] = None + self.product_name: Optional[str] = None + self.processing_end_time_utc: Optional[datetime.datetime] = None + self.entities: Optional[List["_models.AlertEntity"]] = None + self.is_incident: Optional[bool] = None + self.correlation_key: Optional[str] = None + self.extended_properties = extended_properties + self.compromised_entity: Optional[str] = None + self.techniques: Optional[List[str]] = None + self.sub_techniques: Optional[List[str]] = None + self.supporting_evidence = supporting_evidence + + +class AlertEntity(_serialization.Model): + """Changing set of properties depending on the entity type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, JSON] + :ivar type: Type of entity. + :vartype type: str + """ + + _validation = { + "type": {"readonly": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs: Any) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, JSON] + """ + super().__init__(**kwargs) + self.additional_properties = additional_properties + self.type: Optional[str] = None + + +class AlertList(_serialization.Model): + """List of security alerts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: describes security alert properties. + :vartype value: list[~azure.mgmt.security.models.Alert] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Alert"]] = None, **kwargs: Any) -> None: + """ + :keyword value: describes security alert properties. + :paramtype value: list[~azure.mgmt.security.models.Alert] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class AlertPropertiesSupportingEvidence(_serialization.Model): + """Changing set of properties depending on the supportingEvidence type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, JSON] + :ivar type: Type of the supportingEvidence. + :vartype type: str + """ + + _validation = { + "type": {"readonly": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs: Any) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, JSON] + """ + super().__init__(**kwargs) + self.additional_properties = additional_properties + self.type: Optional[str] = None + + +class AlertSimulatorRequestProperties(_serialization.Model): + """Describes properties of an alert simulation request. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AlertSimulatorBundlesRequestProperties + + All required parameters must be populated in order to send to server. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar kind: The kind of alert simulation. Required. "Bundles" + :vartype kind: str or ~azure.mgmt.security.models.KindEnum + """ + + _validation = { + "kind": {"required": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "kind": {"key": "kind", "type": "str"}, + } + + _subtype_map = {"kind": {"Bundles": "AlertSimulatorBundlesRequestProperties"}} + + def __init__(self, *, additional_properties: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + """ + super().__init__(**kwargs) + self.additional_properties = additional_properties + self.kind: Optional[str] = None + + +class AlertSimulatorBundlesRequestProperties(AlertSimulatorRequestProperties): + """Simulate alerts according to this bundles. + + All required parameters must be populated in order to send to server. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar kind: The kind of alert simulation. Required. "Bundles" + :vartype kind: str or ~azure.mgmt.security.models.KindEnum + :ivar bundles: Bundles list. + :vartype bundles: list[str or ~azure.mgmt.security.models.BundleType] + """ + + _validation = { + "kind": {"required": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "kind": {"key": "kind", "type": "str"}, + "bundles": {"key": "bundles", "type": "[str]"}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, Any]] = None, + bundles: Optional[List[Union[str, "_models.BundleType"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword bundles: Bundles list. + :paramtype bundles: list[str or ~azure.mgmt.security.models.BundleType] + """ + super().__init__(additional_properties=additional_properties, **kwargs) + self.kind: str = "Bundles" + self.bundles = bundles + + +class AlertSimulatorRequestBody(_serialization.Model): + """Alert Simulator request body. + + :ivar properties: Alert Simulator request body data. + :vartype properties: ~azure.mgmt.security.models.AlertSimulatorRequestProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "AlertSimulatorRequestProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.AlertSimulatorRequestProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Alert Simulator request body data. + :paramtype properties: ~azure.mgmt.security.models.AlertSimulatorRequestProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class AlertsSuppressionRule(Resource): + """Describes the suppression rule. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar alert_type: Type of the alert to automatically suppress. For all alert types, use '*'. + :vartype alert_type: str + :ivar last_modified_utc: The last time this rule was modified. + :vartype last_modified_utc: ~datetime.datetime + :ivar expiration_date_utc: Expiration date of the rule, if value is not provided or provided as + null there will no expiration at all. + :vartype expiration_date_utc: ~datetime.datetime + :ivar reason: The reason for dismissing the alert. + :vartype reason: str + :ivar state: Possible states of the rule. Known values are: "Enabled", "Disabled", and + "Expired". + :vartype state: str or ~azure.mgmt.security.models.RuleState + :ivar comment: Any comment regarding the rule. + :vartype comment: str + :ivar suppression_alerts_scope: The suppression conditions. + :vartype suppression_alerts_scope: ~azure.mgmt.security.models.SuppressionAlertsScope + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_utc": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "last_modified_utc": {"key": "properties.lastModifiedUtc", "type": "iso-8601"}, + "expiration_date_utc": {"key": "properties.expirationDateUtc", "type": "iso-8601"}, + "reason": {"key": "properties.reason", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "comment": {"key": "properties.comment", "type": "str"}, + "suppression_alerts_scope": {"key": "properties.suppressionAlertsScope", "type": "SuppressionAlertsScope"}, + } + + def __init__( + self, + *, + alert_type: Optional[str] = None, + expiration_date_utc: Optional[datetime.datetime] = None, + reason: Optional[str] = None, + state: Optional[Union[str, "_models.RuleState"]] = None, + comment: Optional[str] = None, + suppression_alerts_scope: Optional["_models.SuppressionAlertsScope"] = None, + **kwargs: Any + ) -> None: + """ + :keyword alert_type: Type of the alert to automatically suppress. For all alert types, use '*'. + :paramtype alert_type: str + :keyword expiration_date_utc: Expiration date of the rule, if value is not provided or provided + as null there will no expiration at all. + :paramtype expiration_date_utc: ~datetime.datetime + :keyword reason: The reason for dismissing the alert. + :paramtype reason: str + :keyword state: Possible states of the rule. Known values are: "Enabled", "Disabled", and + "Expired". + :paramtype state: str or ~azure.mgmt.security.models.RuleState + :keyword comment: Any comment regarding the rule. + :paramtype comment: str + :keyword suppression_alerts_scope: The suppression conditions. + :paramtype suppression_alerts_scope: ~azure.mgmt.security.models.SuppressionAlertsScope + """ + super().__init__(**kwargs) + self.alert_type = alert_type + self.last_modified_utc: Optional[datetime.datetime] = None + self.expiration_date_utc = expiration_date_utc + self.reason = reason + self.state = state + self.comment = comment + self.suppression_alerts_scope = suppression_alerts_scope + + +class AlertsSuppressionRulesList(_serialization.Model): + """Suppression rules list for subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: Required. + :vartype value: list[~azure.mgmt.security.models.AlertsSuppressionRule] + :ivar next_link: URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AlertsSuppressionRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.AlertsSuppressionRule"], **kwargs: Any) -> None: + """ + :keyword value: Required. + :paramtype value: list[~azure.mgmt.security.models.AlertsSuppressionRule] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class Setting(Resource): + """The kind of the security setting. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AlertSyncSettings, DataExportSettings + + 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: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", + "AlertSuppressionSetting", and "AlertSyncSettings". + :vartype kind: str or ~azure.mgmt.security.models.SettingKind + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + } + + _subtype_map = {"kind": {"AlertSyncSettings": "AlertSyncSettings", "DataExportSettings": "DataExportSettings"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None + + +class AlertSyncSettings(Setting): + """Represents an alert sync setting. + + 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: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", + "AlertSuppressionSetting", and "AlertSyncSettings". + :vartype kind: str or ~azure.mgmt.security.models.SettingKind + :ivar enabled: Is the alert sync setting enabled. + :vartype enabled: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is the alert sync setting enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.kind: str = "AlertSyncSettings" + self.enabled = enabled + + +class AllowedConnectionsList(_serialization.Model): + """List of all possible traffic between Azure resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.AllowedConnectionsResource] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AllowedConnectionsResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.AllowedConnectionsResource"]] = None + self.next_link: Optional[str] = None + + +class AllowedConnectionsResource(Resource, Location): + """The resource whose properties describes the allowed traffic between Azure resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar calculated_date_time: The UTC time on which the allowed connections resource was + calculated. + :vartype calculated_date_time: ~datetime.datetime + :ivar connectable_resources: List of connectable resources. + :vartype connectable_resources: list[~azure.mgmt.security.models.ConnectableResource] + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "calculated_date_time": {"readonly": True}, + "connectable_resources": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "calculated_date_time": {"key": "properties.calculatedDateTime", "type": "iso-8601"}, + "connectable_resources": {"key": "properties.connectableResources", "type": "[ConnectableResource]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.location: Optional[str] = None + self.calculated_date_time: Optional[datetime.datetime] = None + self.connectable_resources: Optional[List["_models.ConnectableResource"]] = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class ListCustomAlertRule(CustomAlertRule): + """A List custom alert rule. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AllowlistCustomAlertRule, DenylistCustomAlertRule + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and + "String". + :vartype value_type: str or ~azure.mgmt.security.models.ValueType + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "value_type": {"readonly": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "value_type": {"key": "valueType", "type": "str"}, + } + + _subtype_map = { + "rule_type": { + "AllowlistCustomAlertRule": "AllowlistCustomAlertRule", + "DenylistCustomAlertRule": "DenylistCustomAlertRule", + } + } + + def __init__(self, *, is_enabled: bool, **kwargs: Any) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + """ + super().__init__(is_enabled=is_enabled, **kwargs) + self.rule_type: str = "ListCustomAlertRule" + self.value_type: Optional[Union[str, "_models.ValueType"]] = None + + +class AllowlistCustomAlertRule(ListCustomAlertRule): + """A custom alert rule that checks if a value (depends on the custom alert type) is allowed. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ConnectionFromIpNotAllowed, ConnectionToIpNotAllowed, LocalUserNotAllowed, ProcessNotAllowed + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and + "String". + :vartype value_type: str or ~azure.mgmt.security.models.ValueType + :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. + Required. + :vartype allowlist_values: list[str] + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "value_type": {"readonly": True}, + "allowlist_values": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "value_type": {"key": "valueType", "type": "str"}, + "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, + } + + _subtype_map = { + "rule_type": { + "ConnectionFromIpNotAllowed": "ConnectionFromIpNotAllowed", + "ConnectionToIpNotAllowed": "ConnectionToIpNotAllowed", + "LocalUserNotAllowed": "LocalUserNotAllowed", + "ProcessNotAllowed": "ProcessNotAllowed", + } + } + + def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword allowlist_values: The values to allow. The format of the values depends on the rule + type. Required. + :paramtype allowlist_values: list[str] + """ + super().__init__(is_enabled=is_enabled, **kwargs) + self.rule_type: str = "AllowlistCustomAlertRule" + self.allowlist_values = allowlist_values + + +class AmqpC2DMessagesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of cloud to device messages (AMQP protocol) is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "AmqpC2DMessagesNotInAllowedRange" + + +class AmqpC2DRejectedMessagesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of rejected cloud to device messages (AMQP protocol) is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "AmqpC2DRejectedMessagesNotInAllowedRange" + + +class AmqpD2CMessagesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of device to cloud messages (AMQP protocol) is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "AmqpD2CMessagesNotInAllowedRange" + + +class ApiCollection(Resource): + """An API collection as represented by Microsoft Defender for APIs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar provisioning_state: Gets the provisioning state of the API collection. Known values are: + "Succeeded", "Failed", and "Updating". + :vartype provisioning_state: str or ~azure.mgmt.security.models.ProvisioningState + :ivar display_name: The display name of the API collection. + :vartype display_name: str + :ivar discovered_via: The resource Id of the resource from where this API collection was + discovered. + :vartype discovered_via: str + :ivar base_url: The base URI for this API collection. All endpoints of this API collection + extend this base URI. + :vartype base_url: str + :ivar number_of_api_endpoints: The number of API endpoints discovered in this API collection. + :vartype number_of_api_endpoints: int + :ivar number_of_inactive_api_endpoints: The number of API endpoints in this API collection that + have not received any API traffic in the last 30 days. + :vartype number_of_inactive_api_endpoints: int + :ivar number_of_unauthenticated_api_endpoints: The number of API endpoints in this API + collection that are unauthenticated. + :vartype number_of_unauthenticated_api_endpoints: int + :ivar number_of_external_api_endpoints: The number of API endpoints in this API collection for + which API traffic from the internet was observed. + :vartype number_of_external_api_endpoints: int + :ivar number_of_api_endpoints_with_sensitive_data_exposed: The number of API endpoints in this + API collection which are exposing sensitive data in their requests and/or responses. + :vartype number_of_api_endpoints_with_sensitive_data_exposed: int + :ivar sensitivity_label: The highest priority sensitivity label from Microsoft Purview in this + API collection. + :vartype sensitivity_label: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "display_name": {"readonly": True}, + "discovered_via": {"readonly": True}, + "base_url": {"readonly": True}, + "number_of_api_endpoints": {"readonly": True}, + "number_of_inactive_api_endpoints": {"readonly": True}, + "number_of_unauthenticated_api_endpoints": {"readonly": True}, + "number_of_external_api_endpoints": {"readonly": True}, + "number_of_api_endpoints_with_sensitive_data_exposed": {"readonly": True}, + "sensitivity_label": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "discovered_via": {"key": "properties.discoveredVia", "type": "str"}, + "base_url": {"key": "properties.baseUrl", "type": "str"}, + "number_of_api_endpoints": {"key": "properties.numberOfApiEndpoints", "type": "int"}, + "number_of_inactive_api_endpoints": {"key": "properties.numberOfInactiveApiEndpoints", "type": "int"}, + "number_of_unauthenticated_api_endpoints": { + "key": "properties.numberOfUnauthenticatedApiEndpoints", + "type": "int", + }, + "number_of_external_api_endpoints": {"key": "properties.numberOfExternalApiEndpoints", "type": "int"}, + "number_of_api_endpoints_with_sensitive_data_exposed": { + "key": "properties.numberOfApiEndpointsWithSensitiveDataExposed", + "type": "int", + }, + "sensitivity_label": {"key": "properties.sensitivityLabel", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.display_name: Optional[str] = None + self.discovered_via: Optional[str] = None + self.base_url: Optional[str] = None + self.number_of_api_endpoints: Optional[int] = None + self.number_of_inactive_api_endpoints: Optional[int] = None + self.number_of_unauthenticated_api_endpoints: Optional[int] = None + self.number_of_external_api_endpoints: Optional[int] = None + self.number_of_api_endpoints_with_sensitive_data_exposed: Optional[int] = None + self.sensitivity_label: Optional[str] = None + + +class ApiCollectionList(_serialization.Model): + """Page of a list of API collections as represented by Microsoft Defender for APIs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: API collections in this page. + :vartype value: list[~azure.mgmt.security.models.ApiCollection] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApiCollection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.ApiCollection"]] = None + self.next_link: Optional[str] = None + + +class Application(Resource): + """Security Application over a given scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: display name of the application. + :vartype display_name: str + :ivar description: description of the application. + :vartype description: str + :ivar source_resource_type: The application source, what it affects, e.g. Assessments. + "Assessments" + :vartype source_resource_type: str or ~azure.mgmt.security.models.ApplicationSourceResourceType + :ivar condition_sets: The application conditionSets - see examples. + :vartype condition_sets: list[JSON] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "source_resource_type": {"key": "properties.sourceResourceType", "type": "str"}, + "condition_sets": {"key": "properties.conditionSets", "type": "[object]"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + source_resource_type: Optional[Union[str, "_models.ApplicationSourceResourceType"]] = None, + condition_sets: Optional[List[JSON]] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: display name of the application. + :paramtype display_name: str + :keyword description: description of the application. + :paramtype description: str + :keyword source_resource_type: The application source, what it affects, e.g. Assessments. + "Assessments" + :paramtype source_resource_type: str or + ~azure.mgmt.security.models.ApplicationSourceResourceType + :keyword condition_sets: The application conditionSets - see examples. + :paramtype condition_sets: list[JSON] + """ + super().__init__(**kwargs) + self.display_name = display_name + self.description = description + self.source_resource_type = source_resource_type + self.condition_sets = condition_sets + + +class ApplicationCondition(_serialization.Model): + """Application's condition. + + :ivar property: The application Condition's Property, e.g. ID, see examples. + :vartype property: str + :ivar value: The application Condition's Value like IDs that contain some string, see examples. + :vartype value: str + :ivar operator: The application Condition's Operator, for example Contains for id or In for + list of possible IDs, see examples. Known values are: "Contains", "Equals", "In", and "In". + :vartype operator: str or ~azure.mgmt.security.models.ApplicationConditionOperator + """ + + _attribute_map = { + "property": {"key": "property", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + } + + def __init__( + self, + *, + property: Optional[str] = None, # pylint: disable=redefined-builtin + value: Optional[str] = None, + operator: Optional[Union[str, "_models.ApplicationConditionOperator"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword property: The application Condition's Property, e.g. ID, see examples. + :paramtype property: str + :keyword value: The application Condition's Value like IDs that contain some string, see + examples. + :paramtype value: str + :keyword operator: The application Condition's Operator, for example Contains for id or In for + list of possible IDs, see examples. Known values are: "Contains", "Equals", "In", and "In". + :paramtype operator: str or ~azure.mgmt.security.models.ApplicationConditionOperator + """ + super().__init__(**kwargs) + self.property = property + self.value = value + self.operator = operator + + +class ApplicationsList(_serialization.Model): + """Page of a security applications list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of applications in this page. + :vartype value: list[~azure.mgmt.security.models.Application] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Application]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.Application"]] = None + self.next_link: Optional[str] = None + + +class ArcAutoProvisioning(_serialization.Model): + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for servers Arc auto provisioning for a given environment. + :vartype configuration: ~azure.mgmt.security.models.ArcAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "ArcAutoProvisioningConfiguration"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.ArcAutoProvisioningConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: Configuration for servers Arc auto provisioning for a given + environment. + :paramtype configuration: ~azure.mgmt.security.models.ArcAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class ArcAutoProvisioningAws(ArcAutoProvisioning): + """The ARC autoprovisioning configuration for an AWS environment. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for servers Arc auto provisioning for a given environment. + :vartype configuration: ~azure.mgmt.security.models.ArcAutoProvisioningConfiguration + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "ArcAutoProvisioningConfiguration"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.ArcAutoProvisioningConfiguration"] = None, + cloud_role_arn: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: Configuration for servers Arc auto provisioning for a given + environment. + :paramtype configuration: ~azure.mgmt.security.models.ArcAutoProvisioningConfiguration + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(enabled=enabled, configuration=configuration, **kwargs) + self.cloud_role_arn = cloud_role_arn + + +class ArcAutoProvisioningConfiguration(_serialization.Model): + """Configuration for servers Arc auto provisioning for a given environment. + + :ivar proxy: Optional HTTP proxy endpoint to use for the Arc agent. + :vartype proxy: str + :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :vartype private_link_scope: str + """ + + _attribute_map = { + "proxy": {"key": "proxy", "type": "str"}, + "private_link_scope": {"key": "privateLinkScope", "type": "str"}, + } + + def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword proxy: Optional HTTP proxy endpoint to use for the Arc agent. + :paramtype proxy: str + :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :paramtype private_link_scope: str + """ + super().__init__(**kwargs) + self.proxy = proxy + self.private_link_scope = private_link_scope + + +class ArcAutoProvisioningGcp(ArcAutoProvisioning): + """The ARC autoprovisioning configuration for an GCP environment. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for servers Arc auto provisioning for a given environment. + :vartype configuration: ~azure.mgmt.security.models.ArcAutoProvisioningConfiguration + """ + + +class AscLocation(Resource): + """The ASC location of the subscription is in the "name" field. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: An empty set of properties. + :vartype properties: JSON + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, + } + + def __init__(self, *, properties: Optional[JSON] = None, **kwargs: Any) -> None: + """ + :keyword properties: An empty set of properties. + :paramtype properties: JSON + """ + super().__init__(**kwargs) + self.properties = properties + + +class AscLocationList(_serialization.Model): + """List of locations where ASC saves your data. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.AscLocation] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AscLocation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.AscLocation"]] = None + self.next_link: Optional[str] = None + + +class AssessmentLinks(_serialization.Model): + """Links relevant to the assessment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar azure_portal_uri: Link to assessment in Azure Portal. + :vartype azure_portal_uri: str + """ + + _validation = { + "azure_portal_uri": {"readonly": True}, + } + + _attribute_map = { + "azure_portal_uri": {"key": "azurePortalUri", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.azure_portal_uri: Optional[str] = None + + +class AssessmentStatus(_serialization.Model): + """The result of the assessment. + + All required parameters must be populated in order to send to server. + + :ivar code: Programmatic code for the status of the assessment. Required. Known values are: + "Healthy", "Unhealthy", and "NotApplicable". + :vartype code: str or ~azure.mgmt.security.models.AssessmentStatusCode + :ivar cause: Programmatic code for the cause of the assessment status. + :vartype cause: str + :ivar description: Human readable description of the assessment status. + :vartype description: str + """ + + _validation = { + "code": {"required": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "cause": {"key": "cause", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + code: Union[str, "_models.AssessmentStatusCode"], + cause: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Programmatic code for the status of the assessment. Required. Known values are: + "Healthy", "Unhealthy", and "NotApplicable". + :paramtype code: str or ~azure.mgmt.security.models.AssessmentStatusCode + :keyword cause: Programmatic code for the cause of the assessment status. + :paramtype cause: str + :keyword description: Human readable description of the assessment status. + :paramtype description: str + """ + super().__init__(**kwargs) + self.code = code + self.cause = cause + self.description = description + + +class AssessmentStatusResponse(AssessmentStatus): + """The result of the assessment. + + 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 code: Programmatic code for the status of the assessment. Required. Known values are: + "Healthy", "Unhealthy", and "NotApplicable". + :vartype code: str or ~azure.mgmt.security.models.AssessmentStatusCode + :ivar cause: Programmatic code for the cause of the assessment status. + :vartype cause: str + :ivar description: Human readable description of the assessment status. + :vartype description: str + :ivar first_evaluation_date: The time that the assessment was created and first evaluated. + Returned as UTC time in ISO 8601 format. + :vartype first_evaluation_date: ~datetime.datetime + :ivar status_change_date: The time that the status of the assessment last changed. Returned as + UTC time in ISO 8601 format. + :vartype status_change_date: ~datetime.datetime + """ + + _validation = { + "code": {"required": True}, + "first_evaluation_date": {"readonly": True}, + "status_change_date": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "cause": {"key": "cause", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "first_evaluation_date": {"key": "firstEvaluationDate", "type": "iso-8601"}, + "status_change_date": {"key": "statusChangeDate", "type": "iso-8601"}, + } + + def __init__( + self, + *, + code: Union[str, "_models.AssessmentStatusCode"], + cause: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Programmatic code for the status of the assessment. Required. Known values are: + "Healthy", "Unhealthy", and "NotApplicable". + :paramtype code: str or ~azure.mgmt.security.models.AssessmentStatusCode + :keyword cause: Programmatic code for the cause of the assessment status. + :paramtype cause: str + :keyword description: Human readable description of the assessment status. + :paramtype description: str + """ + super().__init__(code=code, cause=cause, description=description, **kwargs) + self.first_evaluation_date: Optional[datetime.datetime] = None + self.status_change_date: Optional[datetime.datetime] = None + + +class AssignedAssessmentItem(_serialization.Model): + """Describe the properties of a security assessment object reference (by key). + + :ivar assessment_key: Unique key to a security assessment object. + :vartype assessment_key: str + """ + + _attribute_map = { + "assessment_key": {"key": "assessmentKey", "type": "str"}, + } + + def __init__(self, *, assessment_key: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword assessment_key: Unique key to a security assessment object. + :paramtype assessment_key: str + """ + super().__init__(**kwargs) + self.assessment_key = assessment_key + + +class AssignedStandardItem(_serialization.Model): + """Describe the properties of a of a standard assignments object reference. + + :ivar id: Full resourceId of the Microsoft.Security/standard object. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Full resourceId of the Microsoft.Security/standard object. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class AtaExternalSecuritySolution(ExternalSecuritySolution): + """Represents an ATA security solution which sends logs to an OMS workspace. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :vartype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: The external security solution properties for ATA solutions. + :vartype properties: ~azure.mgmt.security.models.AtaSolutionProperties + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "AtaSolutionProperties"}, + } + + def __init__( + self, + *, + kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, + properties: Optional["_models.AtaSolutionProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :paramtype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + :keyword properties: The external security solution properties for ATA solutions. + :paramtype properties: ~azure.mgmt.security.models.AtaSolutionProperties + """ + super().__init__(kind=kind, **kwargs) + self.properties = properties + + +class AtaSolutionProperties(ExternalSecuritySolutionProperties): + """The external security solution properties for ATA solutions. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar device_vendor: + :vartype device_vendor: str + :ivar device_type: + :vartype device_type: str + :ivar workspace: Represents an OMS workspace to which the solution is connected. + :vartype workspace: ~azure.mgmt.security.models.ConnectedWorkspace + :ivar last_event_received: + :vartype last_event_received: str + """ + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "device_vendor": {"key": "deviceVendor", "type": "str"}, + "device_type": {"key": "deviceType", "type": "str"}, + "workspace": {"key": "workspace", "type": "ConnectedWorkspace"}, + "last_event_received": {"key": "lastEventReceived", "type": "str"}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, Any]] = None, + device_vendor: Optional[str] = None, + device_type: Optional[str] = None, + workspace: Optional["_models.ConnectedWorkspace"] = None, + last_event_received: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword device_vendor: + :paramtype device_vendor: str + :keyword device_type: + :paramtype device_type: str + :keyword workspace: Represents an OMS workspace to which the solution is connected. + :paramtype workspace: ~azure.mgmt.security.models.ConnectedWorkspace + :keyword last_event_received: + :paramtype last_event_received: str + """ + super().__init__( + additional_properties=additional_properties, + device_vendor=device_vendor, + device_type=device_type, + workspace=workspace, + **kwargs + ) + self.last_event_received = last_event_received + + +class AttestationEvidence(_serialization.Model): + """Describe the properties of a assignment attestation. + + :ivar description: The description of the evidence. + :vartype description: str + :ivar source_url: The source url of the evidence. + :vartype source_url: str + """ + + _attribute_map = { + "description": {"key": "description", "type": "str"}, + "source_url": {"key": "sourceUrl", "type": "str"}, + } + + def __init__(self, *, description: Optional[str] = None, source_url: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword description: The description of the evidence. + :paramtype description: str + :keyword source_url: The source url of the evidence. + :paramtype source_url: str + """ + super().__init__(**kwargs) + self.description = description + self.source_url = source_url + + +class AuthenticationDetailsProperties(_serialization.Model): + """Settings for cloud authentication management. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AwAssumeRoleAuthenticationDetailsProperties, AwsCredsAuthenticationDetailsProperties, + GcpCredentialsDetailsProperties + + 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 authentication_provisioning_state: State of the multi-cloud connector. Known values are: + "Valid", "Invalid", "Expired", and "IncorrectPolicy". + :vartype authentication_provisioning_state: str or + ~azure.mgmt.security.models.AuthenticationProvisioningState + :ivar granted_permissions: The permissions detected in the cloud account. + :vartype granted_permissions: list[str or ~azure.mgmt.security.models.PermissionProperty] + :ivar authentication_type: Connect to your cloud account, for AWS use either account + credentials or role-based authentication. For GCP use account organization credentials. + Required. Known values are: "awsCreds", "awsAssumeRole", and "gcpCredentials". + :vartype authentication_type: str or ~azure.mgmt.security.models.AuthenticationType + """ + + _validation = { + "authentication_provisioning_state": {"readonly": True}, + "granted_permissions": {"readonly": True}, + "authentication_type": {"required": True}, + } + + _attribute_map = { + "authentication_provisioning_state": {"key": "authenticationProvisioningState", "type": "str"}, + "granted_permissions": {"key": "grantedPermissions", "type": "[str]"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + } + + _subtype_map = { + "authentication_type": { + "awsAssumeRole": "AwAssumeRoleAuthenticationDetailsProperties", + "awsCreds": "AwsCredsAuthenticationDetailsProperties", + "gcpCredentials": "GcpCredentialsDetailsProperties", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.authentication_provisioning_state: Optional[Union[str, "_models.AuthenticationProvisioningState"]] = None + self.granted_permissions: Optional[List[Union[str, "_models.PermissionProperty"]]] = None + self.authentication_type: Optional[str] = None + + +class Authorization(_serialization.Model): + """Authorization payload. + + :ivar code: Gets or sets one-time OAuth code to exchange for refresh and access tokens. + + Only used during PUT/PATCH operations. The secret is cleared during GET. + :vartype code: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: Gets or sets one-time OAuth code to exchange for refresh and access tokens. + + Only used during PUT/PATCH operations. The secret is cleared during GET. + :paramtype code: str + """ + super().__init__(**kwargs) + self.code = code + + +class Tags(_serialization.Model): + """A list of key value pairs that describe the resource. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class ETag(_serialization.Model): + """Entity tag is used for comparing two or more entities from the same requested resource. + + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + """ + + _attribute_map = { + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, *, etag: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + """ + super().__init__(**kwargs) + self.etag = etag + + +class Kind(_serialization.Model): + """Describes an Azure resource with kind. + + :ivar kind: Kind of the resource. + :vartype kind: str + """ + + _attribute_map = { + "kind": {"key": "kind", "type": "str"}, + } + + def __init__(self, *, kind: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword kind: Kind of the resource. + :paramtype kind: str + """ + super().__init__(**kwargs) + self.kind = kind + + +class AzureTrackedResourceLocation(_serialization.Model): + """Describes an Azure resource with location. + + :ivar location: Location where the resource is stored. + :vartype location: str + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword location: Location where the resource is stored. + :paramtype location: str + """ + super().__init__(**kwargs) + self.location = location + + +class TrackedResource(Resource, AzureTrackedResourceLocation, Kind, ETag, Tags): + """Describes an Azure tracked resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + :ivar kind: Kind of the resource. + :vartype kind: str + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + kind: Optional[str] = None, + location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + :keyword kind: Kind of the resource. + :paramtype kind: str + :keyword location: Location where the resource is stored. + :paramtype location: str + """ + super().__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) + self.tags = tags + self.etag = etag + self.kind = kind + self.location = location + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class Automation(TrackedResource): + """The security automation resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + :ivar kind: Kind of the resource. + :vartype kind: str + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar description: The security automation description. + :vartype description: str + :ivar is_enabled: Indicates whether the security automation is enabled. + :vartype is_enabled: bool + :ivar scopes: A collection of scopes on which the security automations logic is applied. + Supported scopes are the subscription itself or a resource group under that subscription. The + automation will only apply on defined scopes. + :vartype scopes: list[~azure.mgmt.security.models.AutomationScope] + :ivar sources: A collection of the source event types which evaluate the security automation + set of rules. + :vartype sources: list[~azure.mgmt.security.models.AutomationSource] + :ivar actions: A collection of the actions which are triggered if all the configured rules + evaluations, within at least one rule set, are true. + :vartype actions: list[~azure.mgmt.security.models.AutomationAction] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "scopes": {"key": "properties.scopes", "type": "[AutomationScope]"}, + "sources": {"key": "properties.sources", "type": "[AutomationSource]"}, + "actions": {"key": "properties.actions", "type": "[AutomationAction]"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + kind: Optional[str] = None, + location: Optional[str] = None, + description: Optional[str] = None, + is_enabled: Optional[bool] = None, + scopes: Optional[List["_models.AutomationScope"]] = None, + sources: Optional[List["_models.AutomationSource"]] = None, + actions: Optional[List["_models.AutomationAction"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + :keyword kind: Kind of the resource. + :paramtype kind: str + :keyword location: Location where the resource is stored. + :paramtype location: str + :keyword description: The security automation description. + :paramtype description: str + :keyword is_enabled: Indicates whether the security automation is enabled. + :paramtype is_enabled: bool + :keyword scopes: A collection of scopes on which the security automations logic is applied. + Supported scopes are the subscription itself or a resource group under that subscription. The + automation will only apply on defined scopes. + :paramtype scopes: list[~azure.mgmt.security.models.AutomationScope] + :keyword sources: A collection of the source event types which evaluate the security automation + set of rules. + :paramtype sources: list[~azure.mgmt.security.models.AutomationSource] + :keyword actions: A collection of the actions which are triggered if all the configured rules + evaluations, within at least one rule set, are true. + :paramtype actions: list[~azure.mgmt.security.models.AutomationAction] + """ + super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) + self.description = description + self.is_enabled = is_enabled + self.scopes = scopes + self.sources = sources + self.actions = actions + + +class AutomationAction(_serialization.Model): + """The action that should be triggered. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AutomationActionEventHub, AutomationActionLogicApp, AutomationActionWorkspace + + All required parameters must be populated in order to send to server. + + :ivar action_type: The type of the action that will be triggered by the Automation. Required. + Known values are: "Internal", "LogicApp", "EventHub", and "Workspace". + :vartype action_type: str or ~azure.mgmt.security.models.ActionType + """ + + _validation = { + "action_type": {"required": True}, + } + + _attribute_map = { + "action_type": {"key": "actionType", "type": "str"}, + } + + _subtype_map = { + "action_type": { + "EventHub": "AutomationActionEventHub", + "LogicApp": "AutomationActionLogicApp", + "Workspace": "AutomationActionWorkspace", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.action_type: Optional[str] = None + + +class AutomationActionEventHub(AutomationAction): + """The target Event Hub to which event data will be exported. To learn more about Microsoft + Defender for Cloud continuous export capabilities, visit https://aka.ms/ASCExportLearnMore. + + 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 action_type: The type of the action that will be triggered by the Automation. Required. + Known values are: "Internal", "LogicApp", "EventHub", and "Workspace". + :vartype action_type: str or ~azure.mgmt.security.models.ActionType + :ivar event_hub_resource_id: The target Event Hub Azure Resource ID. + :vartype event_hub_resource_id: str + :ivar sas_policy_name: The target Event Hub SAS policy name. + :vartype sas_policy_name: str + :ivar connection_string: The target Event Hub connection string (it will not be included in any + response). + :vartype connection_string: str + :ivar is_trusted_service_enabled: Indicates whether the trusted service is enabled or not. + :vartype is_trusted_service_enabled: bool + """ + + _validation = { + "action_type": {"required": True}, + "sas_policy_name": {"readonly": True}, + } + + _attribute_map = { + "action_type": {"key": "actionType", "type": "str"}, + "event_hub_resource_id": {"key": "eventHubResourceId", "type": "str"}, + "sas_policy_name": {"key": "sasPolicyName", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "is_trusted_service_enabled": {"key": "isTrustedServiceEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + event_hub_resource_id: Optional[str] = None, + connection_string: Optional[str] = None, + is_trusted_service_enabled: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword event_hub_resource_id: The target Event Hub Azure Resource ID. + :paramtype event_hub_resource_id: str + :keyword connection_string: The target Event Hub connection string (it will not be included in + any response). + :paramtype connection_string: str + :keyword is_trusted_service_enabled: Indicates whether the trusted service is enabled or not. + :paramtype is_trusted_service_enabled: bool + """ + super().__init__(**kwargs) + self.action_type: str = "EventHub" + self.event_hub_resource_id = event_hub_resource_id + self.sas_policy_name: Optional[str] = None + self.connection_string = connection_string + self.is_trusted_service_enabled = is_trusted_service_enabled + + +class AutomationActionLogicApp(AutomationAction): + """The logic app action that should be triggered. To learn more about Microsoft Defender for + Cloud's Workflow Automation capabilities, visit https://aka.ms/ASCWorkflowAutomationLearnMore. + + All required parameters must be populated in order to send to server. + + :ivar action_type: The type of the action that will be triggered by the Automation. Required. + Known values are: "Internal", "LogicApp", "EventHub", and "Workspace". + :vartype action_type: str or ~azure.mgmt.security.models.ActionType + :ivar logic_app_resource_id: The triggered Logic App Azure Resource ID. This can also reside on + other subscriptions, given that you have permissions to trigger the Logic App. + :vartype logic_app_resource_id: str + :ivar uri: The Logic App trigger URI endpoint (it will not be included in any response). + :vartype uri: str + """ + + _validation = { + "action_type": {"required": True}, + } + + _attribute_map = { + "action_type": {"key": "actionType", "type": "str"}, + "logic_app_resource_id": {"key": "logicAppResourceId", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + } + + def __init__( + self, *, logic_app_resource_id: Optional[str] = None, uri: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword logic_app_resource_id: The triggered Logic App Azure Resource ID. This can also reside + on other subscriptions, given that you have permissions to trigger the Logic App. + :paramtype logic_app_resource_id: str + :keyword uri: The Logic App trigger URI endpoint (it will not be included in any response). + :paramtype uri: str + """ + super().__init__(**kwargs) + self.action_type: str = "LogicApp" + self.logic_app_resource_id = logic_app_resource_id + self.uri = uri + + +class AutomationActionWorkspace(AutomationAction): + """The Log Analytics Workspace to which event data will be exported. Security alerts data will + reside in the 'SecurityAlert' table and the assessments data will reside in the + 'SecurityRecommendation' table (under the 'Security'/'SecurityCenterFree' solutions). Note that + in order to view the data in the workspace, the Security Center Log Analytics free/standard + solution needs to be enabled on that workspace. To learn more about Microsoft Defender for + Cloud continuous export capabilities, visit https://aka.ms/ASCExportLearnMore. + + All required parameters must be populated in order to send to server. + + :ivar action_type: The type of the action that will be triggered by the Automation. Required. + Known values are: "Internal", "LogicApp", "EventHub", and "Workspace". + :vartype action_type: str or ~azure.mgmt.security.models.ActionType + :ivar workspace_resource_id: The fully qualified Log Analytics Workspace Azure Resource ID. + :vartype workspace_resource_id: str + """ + + _validation = { + "action_type": {"required": True}, + } + + _attribute_map = { + "action_type": {"key": "actionType", "type": "str"}, + "workspace_resource_id": {"key": "workspaceResourceId", "type": "str"}, + } + + def __init__(self, *, workspace_resource_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword workspace_resource_id: The fully qualified Log Analytics Workspace Azure Resource ID. + :paramtype workspace_resource_id: str + """ + super().__init__(**kwargs) + self.action_type: str = "Workspace" + self.workspace_resource_id = workspace_resource_id + + +class AutomationList(_serialization.Model): + """List of security automations response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of security automations under the given scope. Required. + :vartype value: list[~azure.mgmt.security.models.Automation] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Automation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Automation"], **kwargs: Any) -> None: + """ + :keyword value: The list of security automations under the given scope. Required. + :paramtype value: list[~azure.mgmt.security.models.Automation] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class AutomationRuleSet(_serialization.Model): + """A rule set which evaluates all its rules upon an event interception. Only when all the included + rules in the rule set will be evaluated as 'true', will the event trigger the defined actions. + + :ivar rules: + :vartype rules: list[~azure.mgmt.security.models.AutomationTriggeringRule] + """ + + _attribute_map = { + "rules": {"key": "rules", "type": "[AutomationTriggeringRule]"}, + } + + def __init__(self, *, rules: Optional[List["_models.AutomationTriggeringRule"]] = None, **kwargs: Any) -> None: + """ + :keyword rules: + :paramtype rules: list[~azure.mgmt.security.models.AutomationTriggeringRule] + """ + super().__init__(**kwargs) + self.rules = rules + + +class AutomationScope(_serialization.Model): + """A single automation scope. + + :ivar description: The resources scope description. + :vartype description: str + :ivar scope_path: The resources scope path. Can be the subscription on which the automation is + defined on or a resource group under that subscription (fully qualified Azure resource IDs). + :vartype scope_path: str + """ + + _attribute_map = { + "description": {"key": "description", "type": "str"}, + "scope_path": {"key": "scopePath", "type": "str"}, + } + + def __init__(self, *, description: Optional[str] = None, scope_path: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword description: The resources scope description. + :paramtype description: str + :keyword scope_path: The resources scope path. Can be the subscription on which the automation + is defined on or a resource group under that subscription (fully qualified Azure resource IDs). + :paramtype scope_path: str + """ + super().__init__(**kwargs) + self.description = description + self.scope_path = scope_path + + +class AutomationSource(_serialization.Model): + """The source event types which evaluate the security automation set of rules. For example - + security alerts and security assessments. To learn more about the supported security events + data models schemas - please visit https://aka.ms/ASCAutomationSchemas. + + :ivar event_source: A valid event source type. Known values are: "Assessments", + "AssessmentsSnapshot", "SubAssessments", "SubAssessmentsSnapshot", "Alerts", "SecureScores", + "SecureScoresSnapshot", "SecureScoreControls", "SecureScoreControlsSnapshot", + "RegulatoryComplianceAssessment", "RegulatoryComplianceAssessmentSnapshot", "AttackPaths", and + "AttackPathsSnapshot". + :vartype event_source: str or ~azure.mgmt.security.models.EventSource + :ivar rule_sets: A set of rules which evaluate upon event interception. A logical disjunction + is applied between defined rule sets (logical 'or'). + :vartype rule_sets: list[~azure.mgmt.security.models.AutomationRuleSet] + """ + + _attribute_map = { + "event_source": {"key": "eventSource", "type": "str"}, + "rule_sets": {"key": "ruleSets", "type": "[AutomationRuleSet]"}, + } + + def __init__( + self, + *, + event_source: Optional[Union[str, "_models.EventSource"]] = None, + rule_sets: Optional[List["_models.AutomationRuleSet"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword event_source: A valid event source type. Known values are: "Assessments", + "AssessmentsSnapshot", "SubAssessments", "SubAssessmentsSnapshot", "Alerts", "SecureScores", + "SecureScoresSnapshot", "SecureScoreControls", "SecureScoreControlsSnapshot", + "RegulatoryComplianceAssessment", "RegulatoryComplianceAssessmentSnapshot", "AttackPaths", and + "AttackPathsSnapshot". + :paramtype event_source: str or ~azure.mgmt.security.models.EventSource + :keyword rule_sets: A set of rules which evaluate upon event interception. A logical + disjunction is applied between defined rule sets (logical 'or'). + :paramtype rule_sets: list[~azure.mgmt.security.models.AutomationRuleSet] + """ + super().__init__(**kwargs) + self.event_source = event_source + self.rule_sets = rule_sets + + +class AutomationTriggeringRule(_serialization.Model): + """A rule which is evaluated upon event interception. The rule is configured by comparing a + specific value from the event model to an expected value. This comparison is done by using one + of the supported operators set. + + :ivar property_j_path: The JPath of the entity model property that should be checked. + :vartype property_j_path: str + :ivar property_type: The data type of the compared operands (string, integer, floating point + number or a boolean [true/false]]. Known values are: "String", "Integer", "Number", and + "Boolean". + :vartype property_type: str or ~azure.mgmt.security.models.PropertyType + :ivar expected_value: The expected value. + :vartype expected_value: str + :ivar operator: A valid comparer operator to use. A case-insensitive comparison will be applied + for String PropertyType. Known values are: "Equals", "GreaterThan", "GreaterThanOrEqualTo", + "LesserThan", "LesserThanOrEqualTo", "NotEquals", "Contains", "StartsWith", and "EndsWith". + :vartype operator: str or ~azure.mgmt.security.models.Operator + """ + + _attribute_map = { + "property_j_path": {"key": "propertyJPath", "type": "str"}, + "property_type": {"key": "propertyType", "type": "str"}, + "expected_value": {"key": "expectedValue", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + } + + def __init__( + self, + *, + property_j_path: Optional[str] = None, + property_type: Optional[Union[str, "_models.PropertyType"]] = None, + expected_value: Optional[str] = None, + operator: Optional[Union[str, "_models.Operator"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword property_j_path: The JPath of the entity model property that should be checked. + :paramtype property_j_path: str + :keyword property_type: The data type of the compared operands (string, integer, floating point + number or a boolean [true/false]]. Known values are: "String", "Integer", "Number", and + "Boolean". + :paramtype property_type: str or ~azure.mgmt.security.models.PropertyType + :keyword expected_value: The expected value. + :paramtype expected_value: str + :keyword operator: A valid comparer operator to use. A case-insensitive comparison will be + applied for String PropertyType. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqualTo", "LesserThan", "LesserThanOrEqualTo", "NotEquals", "Contains", + "StartsWith", and "EndsWith". + :paramtype operator: str or ~azure.mgmt.security.models.Operator + """ + super().__init__(**kwargs) + self.property_j_path = property_j_path + self.property_type = property_type + self.expected_value = expected_value + self.operator = operator + + +class AutomationUpdateModel(Tags): + """The update model of security automation resource. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar description: The security automation description. + :vartype description: str + :ivar is_enabled: Indicates whether the security automation is enabled. + :vartype is_enabled: bool + :ivar scopes: A collection of scopes on which the security automations logic is applied. + Supported scopes are the subscription itself or a resource group under that subscription. The + automation will only apply on defined scopes. + :vartype scopes: list[~azure.mgmt.security.models.AutomationScope] + :ivar sources: A collection of the source event types which evaluate the security automation + set of rules. + :vartype sources: list[~azure.mgmt.security.models.AutomationSource] + :ivar actions: A collection of the actions which are triggered if all the configured rules + evaluations, within at least one rule set, are true. + :vartype actions: list[~azure.mgmt.security.models.AutomationAction] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "scopes": {"key": "properties.scopes", "type": "[AutomationScope]"}, + "sources": {"key": "properties.sources", "type": "[AutomationSource]"}, + "actions": {"key": "properties.actions", "type": "[AutomationAction]"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + is_enabled: Optional[bool] = None, + scopes: Optional[List["_models.AutomationScope"]] = None, + sources: Optional[List["_models.AutomationSource"]] = None, + actions: Optional[List["_models.AutomationAction"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + :keyword description: The security automation description. + :paramtype description: str + :keyword is_enabled: Indicates whether the security automation is enabled. + :paramtype is_enabled: bool + :keyword scopes: A collection of scopes on which the security automations logic is applied. + Supported scopes are the subscription itself or a resource group under that subscription. The + automation will only apply on defined scopes. + :paramtype scopes: list[~azure.mgmt.security.models.AutomationScope] + :keyword sources: A collection of the source event types which evaluate the security automation + set of rules. + :paramtype sources: list[~azure.mgmt.security.models.AutomationSource] + :keyword actions: A collection of the actions which are triggered if all the configured rules + evaluations, within at least one rule set, are true. + :paramtype actions: list[~azure.mgmt.security.models.AutomationAction] + """ + super().__init__(tags=tags, **kwargs) + self.description = description + self.is_enabled = is_enabled + self.scopes = scopes + self.sources = sources + self.actions = actions + + +class AutomationValidationStatus(_serialization.Model): + """The security automation model state property bag. + + :ivar is_valid: Indicates whether the model is valid or not. + :vartype is_valid: bool + :ivar message: The validation message. + :vartype message: str + """ + + _attribute_map = { + "is_valid": {"key": "isValid", "type": "bool"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword is_valid: Indicates whether the model is valid or not. + :paramtype is_valid: bool + :keyword message: The validation message. + :paramtype message: str + """ + super().__init__(**kwargs) + self.is_valid = is_valid + self.message = message + + +class AutoProvisioningSetting(Resource): + """Auto provisioning setting. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar auto_provision: Describes what kind of security agent provisioning action to take. Known + values are: "On" and "Off". + :vartype auto_provision: str or ~azure.mgmt.security.models.AutoProvision + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "auto_provision": {"key": "properties.autoProvision", "type": "str"}, + } + + def __init__(self, *, auto_provision: Optional[Union[str, "_models.AutoProvision"]] = None, **kwargs: Any) -> None: + """ + :keyword auto_provision: Describes what kind of security agent provisioning action to take. + Known values are: "On" and "Off". + :paramtype auto_provision: str or ~azure.mgmt.security.models.AutoProvision + """ + super().__init__(**kwargs) + self.auto_provision = auto_provision + + +class AutoProvisioningSettingList(_serialization.Model): + """List of all the auto provisioning settings response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of all the auto provisioning settings. + :vartype value: list[~azure.mgmt.security.models.AutoProvisioningSetting] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AutoProvisioningSetting]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.AutoProvisioningSetting"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of all the auto provisioning settings. + :paramtype value: list[~azure.mgmt.security.models.AutoProvisioningSetting] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class AwAssumeRoleAuthenticationDetailsProperties(AuthenticationDetailsProperties): # pylint: disable=name-too-long + """AWS cloud account connector based assume role, the role enables delegating access to your AWS + resources. The role is composed of role Amazon Resource Name (ARN) and external ID. For more + details, refer to :code:`Creating + a Role to Delegate Permissions to an IAM User (write only)`. + + 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 authentication_provisioning_state: State of the multi-cloud connector. Known values are: + "Valid", "Invalid", "Expired", and "IncorrectPolicy". + :vartype authentication_provisioning_state: str or + ~azure.mgmt.security.models.AuthenticationProvisioningState + :ivar granted_permissions: The permissions detected in the cloud account. + :vartype granted_permissions: list[str or ~azure.mgmt.security.models.PermissionProperty] + :ivar authentication_type: Connect to your cloud account, for AWS use either account + credentials or role-based authentication. For GCP use account organization credentials. + Required. Known values are: "awsCreds", "awsAssumeRole", and "gcpCredentials". + :vartype authentication_type: str or ~azure.mgmt.security.models.AuthenticationType + :ivar account_id: The ID of the cloud account. + :vartype account_id: str + :ivar aws_assume_role_arn: Assumed role ID is an identifier that you can use to create + temporary security credentials. Required. + :vartype aws_assume_role_arn: str + :ivar aws_external_id: A unique identifier that is required when you assume a role in another + account. Required. + :vartype aws_external_id: str + """ + + _validation = { + "authentication_provisioning_state": {"readonly": True}, + "granted_permissions": {"readonly": True}, + "authentication_type": {"required": True}, + "account_id": {"readonly": True}, + "aws_assume_role_arn": {"required": True}, + "aws_external_id": {"required": True}, + } + + _attribute_map = { + "authentication_provisioning_state": {"key": "authenticationProvisioningState", "type": "str"}, + "granted_permissions": {"key": "grantedPermissions", "type": "[str]"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "account_id": {"key": "accountId", "type": "str"}, + "aws_assume_role_arn": {"key": "awsAssumeRoleArn", "type": "str"}, + "aws_external_id": {"key": "awsExternalId", "type": "str"}, + } + + def __init__(self, *, aws_assume_role_arn: str, aws_external_id: str, **kwargs: Any) -> None: + """ + :keyword aws_assume_role_arn: Assumed role ID is an identifier that you can use to create + temporary security credentials. Required. + :paramtype aws_assume_role_arn: str + :keyword aws_external_id: A unique identifier that is required when you assume a role in + another account. Required. + :paramtype aws_external_id: str + """ + super().__init__(**kwargs) + self.authentication_type: str = "awsAssumeRole" + self.account_id: Optional[str] = None + self.aws_assume_role_arn = aws_assume_role_arn + self.aws_external_id = aws_external_id + + +class AwsCredsAuthenticationDetailsProperties(AuthenticationDetailsProperties): + """AWS cloud account connector based credentials, the credentials is composed of access key ID and + secret key, for more details, refer to :code:`Creating an IAM + User in Your AWS Account (write only)`. + + 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 authentication_provisioning_state: State of the multi-cloud connector. Known values are: + "Valid", "Invalid", "Expired", and "IncorrectPolicy". + :vartype authentication_provisioning_state: str or + ~azure.mgmt.security.models.AuthenticationProvisioningState + :ivar granted_permissions: The permissions detected in the cloud account. + :vartype granted_permissions: list[str or ~azure.mgmt.security.models.PermissionProperty] + :ivar authentication_type: Connect to your cloud account, for AWS use either account + credentials or role-based authentication. For GCP use account organization credentials. + Required. Known values are: "awsCreds", "awsAssumeRole", and "gcpCredentials". + :vartype authentication_type: str or ~azure.mgmt.security.models.AuthenticationType + :ivar account_id: The ID of the cloud account. + :vartype account_id: str + :ivar aws_access_key_id: Public key element of the AWS credential object (write only). + Required. + :vartype aws_access_key_id: str + :ivar aws_secret_access_key: Secret key element of the AWS credential object (write only). + Required. + :vartype aws_secret_access_key: str + """ + + _validation = { + "authentication_provisioning_state": {"readonly": True}, + "granted_permissions": {"readonly": True}, + "authentication_type": {"required": True}, + "account_id": {"readonly": True}, + "aws_access_key_id": {"required": True}, + "aws_secret_access_key": {"required": True}, + } + + _attribute_map = { + "authentication_provisioning_state": {"key": "authenticationProvisioningState", "type": "str"}, + "granted_permissions": {"key": "grantedPermissions", "type": "[str]"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "account_id": {"key": "accountId", "type": "str"}, + "aws_access_key_id": {"key": "awsAccessKeyId", "type": "str"}, + "aws_secret_access_key": {"key": "awsSecretAccessKey", "type": "str"}, + } + + def __init__(self, *, aws_access_key_id: str, aws_secret_access_key: str, **kwargs: Any) -> None: + """ + :keyword aws_access_key_id: Public key element of the AWS credential object (write only). + Required. + :paramtype aws_access_key_id: str + :keyword aws_secret_access_key: Secret key element of the AWS credential object (write only). + Required. + :paramtype aws_secret_access_key: str + """ + super().__init__(**kwargs) + self.authentication_type: str = "awsCreds" + self.account_id: Optional[str] = None + self.aws_access_key_id = aws_access_key_id + self.aws_secret_access_key = aws_secret_access_key + + +class EnvironmentData(_serialization.Model): + """The security connector environment data. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AwsEnvironmentData, AzureDevOpsScopeEnvironmentData, DockerHubEnvironmentData, + GcpProjectEnvironmentData, GithubScopeEnvironmentData, GitlabScopeEnvironmentData, + JFrogEnvironmentData + + All required parameters must be populated in order to send to server. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", "GitlabScope", + "DockerHubOrganization", and "JFrogArtifactory". + :vartype environment_type: str or ~azure.mgmt.security.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + _subtype_map = { + "environment_type": { + "AwsAccount": "AwsEnvironmentData", + "AzureDevOpsScope": "AzureDevOpsScopeEnvironmentData", + "DockerHubOrganization": "DockerHubEnvironmentData", + "GcpProject": "GcpProjectEnvironmentData", + "GithubScope": "GithubScopeEnvironmentData", + "GitlabScope": "GitlabScopeEnvironmentData", + "JFrogArtifactory": "JFrogEnvironmentData", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.environment_type: Optional[str] = None + + +class AwsEnvironmentData(EnvironmentData): + """The AWS connector environment data. + + 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 environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", "GitlabScope", + "DockerHubOrganization", and "JFrogArtifactory". + :vartype environment_type: str or ~azure.mgmt.security.models.EnvironmentType + :ivar organizational_data: The AWS account's organizational data. + :vartype organizational_data: ~azure.mgmt.security.models.AwsOrganizationalData + :ivar regions: list of regions to scan. + :vartype regions: list[str] + :ivar account_name: The AWS account name. + :vartype account_name: str + :ivar scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :vartype scan_interval: int + """ + + _validation = { + "environment_type": {"required": True}, + "account_name": {"readonly": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + "organizational_data": {"key": "organizationalData", "type": "AwsOrganizationalData"}, + "regions": {"key": "regions", "type": "[str]"}, + "account_name": {"key": "accountName", "type": "str"}, + "scan_interval": {"key": "scanInterval", "type": "int"}, + } + + def __init__( + self, + *, + organizational_data: Optional["_models.AwsOrganizationalData"] = None, + regions: Optional[List[str]] = None, + scan_interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword organizational_data: The AWS account's organizational data. + :paramtype organizational_data: ~azure.mgmt.security.models.AwsOrganizationalData + :keyword regions: list of regions to scan. + :paramtype regions: list[str] + :keyword scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :paramtype scan_interval: int + """ + super().__init__(**kwargs) + self.environment_type: str = "AwsAccount" + self.organizational_data = organizational_data + self.regions = regions + self.account_name: Optional[str] = None + self.scan_interval = scan_interval + + +class AwsOrganizationalData(_serialization.Model): + """The AWS organization data. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AwsOrganizationalDataMember, AwsOrganizationalDataMaster + + All required parameters must be populated in order to send to server. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.models.OrganizationMembershipType + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + } + + _subtype_map = { + "organization_membership_type": { + "Member": "AwsOrganizationalDataMember", + "Organization": "AwsOrganizationalDataMaster", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.organization_membership_type: Optional[str] = None + + +class AwsOrganizationalDataMaster(AwsOrganizationalData): + """The AWS organization data for the master account. + + All required parameters must be populated in order to send to server. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.models.OrganizationMembershipType + :ivar stackset_name: If the multi cloud account is of membership type organization, this will + be the name of the onboarding stackset. + :vartype stackset_name: str + :ivar excluded_account_ids: If the multi cloud account is of membership type organization, list + of accounts excluded from offering. + :vartype excluded_account_ids: list[str] + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "stackset_name": {"key": "stacksetName", "type": "str"}, + "excluded_account_ids": {"key": "excludedAccountIds", "type": "[str]"}, + } + + def __init__( + self, *, stackset_name: Optional[str] = None, excluded_account_ids: Optional[List[str]] = None, **kwargs: Any + ) -> None: + """ + :keyword stackset_name: If the multi cloud account is of membership type organization, this + will be the name of the onboarding stackset. + :paramtype stackset_name: str + :keyword excluded_account_ids: If the multi cloud account is of membership type organization, + list of accounts excluded from offering. + :paramtype excluded_account_ids: list[str] + """ + super().__init__(**kwargs) + self.organization_membership_type: str = "Organization" + self.stackset_name = stackset_name + self.excluded_account_ids = excluded_account_ids + + +class AwsOrganizationalDataMember(AwsOrganizationalData): + """The AWS organization data for the member account. + + All required parameters must be populated in order to send to server. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.models.OrganizationMembershipType + :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, + this will be the ID of the account's parent. + :vartype parent_hierarchy_id: str + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, + } + + def __init__(self, *, parent_hierarchy_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword parent_hierarchy_id: If the multi cloud account is not of membership type + organization, this will be the ID of the account's parent. + :paramtype parent_hierarchy_id: str + """ + super().__init__(**kwargs) + self.organization_membership_type: str = "Member" + self.parent_hierarchy_id = parent_hierarchy_id + + +class ResourceAutoGenerated3(_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. 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 + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class ProxyResource(ResourceAutoGenerated3): + """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. 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 + """ + + +class AzureDevOpsOrg(ProxyResource): + """Azure DevOps Organization 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. 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: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar properties: Azure DevOps Organization properties. + :vartype properties: ~azure.mgmt.security.models.AzureDevOpsOrgProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "AzureDevOpsOrgProperties"}, + } + + def __init__(self, *, properties: Optional["_models.AzureDevOpsOrgProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Azure DevOps Organization properties. + :paramtype properties: ~azure.mgmt.security.models.AzureDevOpsOrgProperties + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.properties = properties + + +class AzureDevOpsOrganizationConfiguration(_serialization.Model): + """AzureDevOps Org Inventory Configuration. + + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :ivar project_configs: AzureDevOps Project Inventory Configuration. + Dictionary of AzureDevOps project name to desired project configuration. + If AutoDiscovery is Enabled, this field should be empty or null. + :vartype project_configs: dict[str, + ~azure.mgmt.security.models.AzureDevOpsProjectConfiguration] + """ + + _attribute_map = { + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "project_configs": {"key": "projectConfigs", "type": "{AzureDevOpsProjectConfiguration}"}, + } + + def __init__( + self, + *, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + project_configs: Optional[Dict[str, "_models.AzureDevOpsProjectConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :keyword project_configs: AzureDevOps Project Inventory Configuration. + Dictionary of AzureDevOps project name to desired project configuration. + If AutoDiscovery is Enabled, this field should be empty or null. + :paramtype project_configs: dict[str, + ~azure.mgmt.security.models.AzureDevOpsProjectConfiguration] + """ + super().__init__(**kwargs) + self.auto_discovery = auto_discovery + self.project_configs = project_configs + + +class AzureDevOpsOrgListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.models.AzureDevOpsOrg] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AzureDevOpsOrg]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.AzureDevOpsOrg"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.models.AzureDevOpsOrg] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AzureDevOpsOrgProperties(_serialization.Model): + """Azure DevOps Organization properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets the resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets the time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or ~azure.mgmt.security.models.DevOpsProvisioningState + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + :ivar actionable_remediation: Configuration payload for PR Annotations. + :vartype actionable_remediation: ~azure.mgmt.security.models.ActionableRemediation + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, + } + + def __init__( + self, + *, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + actionable_remediation: Optional["_models.ActionableRemediation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + :keyword actionable_remediation: Configuration payload for PR Annotations. + :paramtype actionable_remediation: ~azure.mgmt.security.models.ActionableRemediation + """ + super().__init__(**kwargs) + self.provisioning_status_message: Optional[str] = None + self.provisioning_status_update_time_utc: Optional[datetime.datetime] = None + self.provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None + self.onboarding_state = onboarding_state + self.actionable_remediation = actionable_remediation + + +class AzureDevOpsProject(ProxyResource): + """Azure DevOps Project 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. 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: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar properties: Azure DevOps Project properties. + :vartype properties: ~azure.mgmt.security.models.AzureDevOpsProjectProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "AzureDevOpsProjectProperties"}, + } + + def __init__(self, *, properties: Optional["_models.AzureDevOpsProjectProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Azure DevOps Project properties. + :paramtype properties: ~azure.mgmt.security.models.AzureDevOpsProjectProperties + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.properties = properties + + +class AzureDevOpsProjectConfiguration(_serialization.Model): + """AzureDevOps Project Inventory Configuration. + + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :ivar repository_configs: AzureDevOps Repository Inventory Configuration. + Dictionary of AzureDevOps repository name to desired repository configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :vartype repository_configs: dict[str, ~azure.mgmt.security.models.BaseResourceConfiguration] + """ + + _attribute_map = { + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "repository_configs": {"key": "repositoryConfigs", "type": "{BaseResourceConfiguration}"}, + } + + def __init__( + self, + *, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + repository_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :keyword repository_configs: AzureDevOps Repository Inventory Configuration. + Dictionary of AzureDevOps repository name to desired repository configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :paramtype repository_configs: dict[str, ~azure.mgmt.security.models.BaseResourceConfiguration] + """ + super().__init__(**kwargs) + self.auto_discovery = auto_discovery + self.repository_configs = repository_configs + + +class AzureDevOpsProjectListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.models.AzureDevOpsProject] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AzureDevOpsProject]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AzureDevOpsProject"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.models.AzureDevOpsProject] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AzureDevOpsProjectProperties(_serialization.Model): + """Azure DevOps Project properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets the resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets the time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or ~azure.mgmt.security.models.DevOpsProvisioningState + :ivar parent_org_name: Gets or sets parent Azure DevOps Organization name. + :vartype parent_org_name: str + :ivar project_id: Gets or sets Azure DevOps Project id. + :vartype project_id: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + :ivar actionable_remediation: Configuration payload for PR Annotations. + :vartype actionable_remediation: ~azure.mgmt.security.models.ActionableRemediation + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "project_id": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "parent_org_name": {"key": "parentOrgName", "type": "str"}, + "project_id": {"key": "projectId", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, + } + + def __init__( + self, + *, + parent_org_name: Optional[str] = None, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + actionable_remediation: Optional["_models.ActionableRemediation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword parent_org_name: Gets or sets parent Azure DevOps Organization name. + :paramtype parent_org_name: str + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + :keyword actionable_remediation: Configuration payload for PR Annotations. + :paramtype actionable_remediation: ~azure.mgmt.security.models.ActionableRemediation + """ + super().__init__(**kwargs) + self.provisioning_status_message: Optional[str] = None + self.provisioning_status_update_time_utc: Optional[datetime.datetime] = None + self.provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None + self.parent_org_name = parent_org_name + self.project_id: Optional[str] = None + self.onboarding_state = onboarding_state + self.actionable_remediation = actionable_remediation + + +class AzureDevOpsRepository(ProxyResource): + """Azure DevOps Repository 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. 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: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar properties: Azure DevOps Repository properties. + :vartype properties: ~azure.mgmt.security.models.AzureDevOpsRepositoryProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "AzureDevOpsRepositoryProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.AzureDevOpsRepositoryProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Azure DevOps Repository properties. + :paramtype properties: ~azure.mgmt.security.models.AzureDevOpsRepositoryProperties + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.properties = properties + + +class AzureDevOpsRepositoryListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.models.AzureDevOpsRepository] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AzureDevOpsRepository]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AzureDevOpsRepository"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.models.AzureDevOpsRepository] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AzureDevOpsRepositoryProperties(_serialization.Model): + """Azure DevOps Repository properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets the resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets the time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or ~azure.mgmt.security.models.DevOpsProvisioningState + :ivar parent_org_name: Gets or sets parent Azure DevOps Organization name. + :vartype parent_org_name: str + :ivar parent_project_name: Gets or sets parent Azure DevOps Project name. + :vartype parent_project_name: str + :ivar repo_id: Gets or sets Azure DevOps Repository id. + :vartype repo_id: str + :ivar repo_url: Gets or sets Azure DevOps Repository url. + :vartype repo_url: str + :ivar visibility: Gets or sets Azure DevOps repository visibility, whether it is public or + private etc. + :vartype visibility: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + :ivar actionable_remediation: Configuration payload for PR Annotations. + :vartype actionable_remediation: ~azure.mgmt.security.models.ActionableRemediation + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "repo_id": {"readonly": True}, + "repo_url": {"readonly": True}, + "visibility": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "parent_org_name": {"key": "parentOrgName", "type": "str"}, + "parent_project_name": {"key": "parentProjectName", "type": "str"}, + "repo_id": {"key": "repoId", "type": "str"}, + "repo_url": {"key": "repoUrl", "type": "str"}, + "visibility": {"key": "visibility", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, + } + + def __init__( + self, + *, + parent_org_name: Optional[str] = None, + parent_project_name: Optional[str] = None, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + actionable_remediation: Optional["_models.ActionableRemediation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword parent_org_name: Gets or sets parent Azure DevOps Organization name. + :paramtype parent_org_name: str + :keyword parent_project_name: Gets or sets parent Azure DevOps Project name. + :paramtype parent_project_name: str + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + :keyword actionable_remediation: Configuration payload for PR Annotations. + :paramtype actionable_remediation: ~azure.mgmt.security.models.ActionableRemediation + """ + super().__init__(**kwargs) + self.provisioning_status_message: Optional[str] = None + self.provisioning_status_update_time_utc: Optional[datetime.datetime] = None + self.provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None + self.parent_org_name = parent_org_name + self.parent_project_name = parent_project_name + self.repo_id: Optional[str] = None + self.repo_url: Optional[str] = None + self.visibility: Optional[str] = None + self.onboarding_state = onboarding_state + self.actionable_remediation = actionable_remediation + + +class AzureDevOpsScopeEnvironmentData(EnvironmentData): + """The AzureDevOps scope connector's environment data. + + All required parameters must be populated in order to send to server. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", "GitlabScope", + "DockerHubOrganization", and "JFrogArtifactory". + :vartype environment_type: str or ~azure.mgmt.security.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.environment_type: str = "AzureDevOpsScope" + + +class ResourceDetails(_serialization.Model): + """Details of the resource that was assessed. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureResourceDetails, OnPremiseResourceDetails + + All required parameters must be populated in order to send to server. + + :ivar source: The platform where the assessed resource resides. Required. Known values are: + "Azure", "OnPremise", and "OnPremiseSql". + :vartype source: str or ~azure.mgmt.security.models.Source + """ + + _validation = { + "source": {"required": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "str"}, + } + + _subtype_map = {"source": {"Azure": "AzureResourceDetails", "OnPremise": "OnPremiseResourceDetails"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.source: Optional[str] = None + + +class AzureResourceDetails(ResourceDetails): + """Details of the Azure resource that was assessed. + + 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 source: The platform where the assessed resource resides. Required. Known values are: + "Azure", "OnPremise", and "OnPremiseSql". + :vartype source: str or ~azure.mgmt.security.models.Source + :ivar id: Azure resource Id of the assessed resource. + :vartype id: str + """ + + _validation = { + "source": {"required": True}, + "id": {"readonly": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "str"}, + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.source: str = "Azure" + self.id: Optional[str] = None + + +class ResourceIdentifier(_serialization.Model): + """A resource identifier for an alert which can be used to direct the alert to the right product + exposure group (tenant, workspace, subscription etc.). + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureResourceIdentifier, LogAnalyticsIdentifier + + All required parameters must be populated in order to send to server. + + :ivar type: There can be multiple identifiers of different type per alert, this field specify + the identifier type. Required. Known values are: "AzureResource" and "LogAnalytics". + :vartype type: str or ~azure.mgmt.security.models.ResourceIdentifierType + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + _subtype_map = {"type": {"AzureResource": "AzureResourceIdentifier", "LogAnalytics": "LogAnalyticsIdentifier"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None + + +class AzureResourceIdentifier(ResourceIdentifier): + """Azure resource identifier. + + 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 type: There can be multiple identifiers of different type per alert, this field specify + the identifier type. Required. Known values are: "AzureResource" and "LogAnalytics". + :vartype type: str or ~azure.mgmt.security.models.ResourceIdentifierType + :ivar azure_resource_id: ARM resource identifier for the cloud resource being alerted on. + :vartype azure_resource_id: str + """ + + _validation = { + "type": {"required": True}, + "azure_resource_id": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "azure_resource_id": {"key": "azureResourceId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: str = "AzureResource" + self.azure_resource_id: Optional[str] = None + + +class AzureResourceLink(_serialization.Model): + """Describes an Azure resource with kind. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + + +class ResourceAutoGenerated(_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.security.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 ServerVulnerabilityAssessmentsSetting(ResourceAutoGenerated): + """A base vulnerability assessments setting on servers in the defined scope. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureServersSetting + + 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.security.models.SystemData + :ivar kind: The kind of the server vulnerability assessments setting. Required. + "AzureServersSetting" + :vartype kind: str or ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKind + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"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"}, + "kind": {"key": "kind", "type": "str"}, + } + + _subtype_map = {"kind": {"AzureServersSetting": "AzureServersSetting"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None + + +class AzureServersSetting(ServerVulnerabilityAssessmentsSetting): + """A vulnerability assessments setting on Azure servers in the defined scope. + + 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.security.models.SystemData + :ivar kind: The kind of the server vulnerability assessments setting. Required. + "AzureServersSetting" + :vartype kind: str or ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKind + :ivar selected_provider: The selected vulnerability assessments provider on Azure servers in + the defined scope. "MdeTvm" + :vartype selected_provider: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"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"}, + "kind": {"key": "kind", "type": "str"}, + "selected_provider": {"key": "properties.selectedProvider", "type": "str"}, + } + + def __init__( + self, + *, + selected_provider: Optional[ + Union[str, "_models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider"] + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword selected_provider: The selected vulnerability assessments provider on Azure servers in + the defined scope. "MdeTvm" + :paramtype selected_provider: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider + """ + super().__init__(**kwargs) + self.kind: str = "AzureServersSetting" + self.selected_provider = selected_provider + + +class Baseline(_serialization.Model): + """Baseline details. + + :ivar expected_results: Expected results. + :vartype expected_results: list[list[str]] + :ivar updated_time: Baseline update time (UTC). + :vartype updated_time: ~datetime.datetime + """ + + _attribute_map = { + "expected_results": {"key": "expectedResults", "type": "[[str]]"}, + "updated_time": {"key": "updatedTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + expected_results: Optional[List[List[str]]] = None, + updated_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword expected_results: Expected results. + :paramtype expected_results: list[list[str]] + :keyword updated_time: Baseline update time (UTC). + :paramtype updated_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.expected_results = expected_results + self.updated_time = updated_time + + +class BaselineAdjustedResult(_serialization.Model): + """The rule result adjusted with baseline. + + :ivar baseline: Baseline details. + :vartype baseline: ~azure.mgmt.security.models.Baseline + :ivar status: The rule result status. Known values are: "NonFinding", "Finding", and + "InternalError". + :vartype status: str or ~azure.mgmt.security.models.RuleStatus + :ivar results_not_in_baseline: Results the are not in baseline. + :vartype results_not_in_baseline: list[list[str]] + :ivar results_only_in_baseline: Results the are in baseline. + :vartype results_only_in_baseline: list[list[str]] + """ + + _attribute_map = { + "baseline": {"key": "baseline", "type": "Baseline"}, + "status": {"key": "status", "type": "str"}, + "results_not_in_baseline": {"key": "resultsNotInBaseline", "type": "[[str]]"}, + "results_only_in_baseline": {"key": "resultsOnlyInBaseline", "type": "[[str]]"}, + } + + def __init__( + self, + *, + baseline: Optional["_models.Baseline"] = None, + status: Optional[Union[str, "_models.RuleStatus"]] = None, + results_not_in_baseline: Optional[List[List[str]]] = None, + results_only_in_baseline: Optional[List[List[str]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword baseline: Baseline details. + :paramtype baseline: ~azure.mgmt.security.models.Baseline + :keyword status: The rule result status. Known values are: "NonFinding", "Finding", and + "InternalError". + :paramtype status: str or ~azure.mgmt.security.models.RuleStatus + :keyword results_not_in_baseline: Results the are not in baseline. + :paramtype results_not_in_baseline: list[list[str]] + :keyword results_only_in_baseline: Results the are in baseline. + :paramtype results_only_in_baseline: list[list[str]] + """ + super().__init__(**kwargs) + self.baseline = baseline + self.status = status + self.results_not_in_baseline = results_not_in_baseline + self.results_only_in_baseline = results_only_in_baseline + + +class BaseResourceConfiguration(_serialization.Model): + """Base Resource Inventory configuration changes. + + :ivar desired_onboarding_state: Onboarding states. Known values are: "Disabled" and "Enabled". + :vartype desired_onboarding_state: str or ~azure.mgmt.security.models.DesiredOnboardingState + """ + + _attribute_map = { + "desired_onboarding_state": {"key": "desiredOnboardingState", "type": "str"}, + } + + def __init__( + self, *, desired_onboarding_state: Optional[Union[str, "_models.DesiredOnboardingState"]] = None, **kwargs: Any + ) -> None: + """ + :keyword desired_onboarding_state: Onboarding states. Known values are: "Disabled" and + "Enabled". + :paramtype desired_onboarding_state: str or ~azure.mgmt.security.models.DesiredOnboardingState + """ + super().__init__(**kwargs) + self.desired_onboarding_state = desired_onboarding_state + + +class BenchmarkReference(_serialization.Model): + """The benchmark references. + + :ivar benchmark: The benchmark name. + :vartype benchmark: str + :ivar reference: The benchmark reference. + :vartype reference: str + """ + + _attribute_map = { + "benchmark": {"key": "benchmark", "type": "str"}, + "reference": {"key": "reference", "type": "str"}, + } + + def __init__(self, *, benchmark: Optional[str] = None, reference: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword benchmark: The benchmark name. + :paramtype benchmark: str + :keyword reference: The benchmark reference. + :paramtype reference: str + """ + super().__init__(**kwargs) + self.benchmark = benchmark + self.reference = reference + + +class BlobsScanSummary(_serialization.Model): + """A summary of the scan results of the blobs that were scanned. + + :ivar total_blobs_scanned: The total number of blobs that were scanned. + :vartype total_blobs_scanned: int + :ivar malicious_blobs_count: The number of malicious blobs that were detected during the scan. + :vartype malicious_blobs_count: int + :ivar skipped_blobs_count: The number of blobs that were skipped. + :vartype skipped_blobs_count: int + :ivar failed_blobs_count: The number of failed blob scans. + :vartype failed_blobs_count: int + :ivar scanned_blobs_in_gb: The number of gigabytes of data that were scanned. + :vartype scanned_blobs_in_gb: float + """ + + _attribute_map = { + "total_blobs_scanned": {"key": "totalBlobsScanned", "type": "int"}, + "malicious_blobs_count": {"key": "maliciousBlobsCount", "type": "int"}, + "skipped_blobs_count": {"key": "skippedBlobsCount", "type": "int"}, + "failed_blobs_count": {"key": "failedBlobsCount", "type": "int"}, + "scanned_blobs_in_gb": {"key": "scannedBlobsInGB", "type": "float"}, + } + + def __init__( + self, + *, + total_blobs_scanned: Optional[int] = None, + malicious_blobs_count: Optional[int] = None, + skipped_blobs_count: Optional[int] = None, + failed_blobs_count: Optional[int] = None, + scanned_blobs_in_gb: Optional[float] = None, + **kwargs: Any + ) -> None: + """ + :keyword total_blobs_scanned: The total number of blobs that were scanned. + :paramtype total_blobs_scanned: int + :keyword malicious_blobs_count: The number of malicious blobs that were detected during the + scan. + :paramtype malicious_blobs_count: int + :keyword skipped_blobs_count: The number of blobs that were skipped. + :paramtype skipped_blobs_count: int + :keyword failed_blobs_count: The number of failed blob scans. + :paramtype failed_blobs_count: int + :keyword scanned_blobs_in_gb: The number of gigabytes of data that were scanned. + :paramtype scanned_blobs_in_gb: float + """ + super().__init__(**kwargs) + self.total_blobs_scanned = total_blobs_scanned + self.malicious_blobs_count = malicious_blobs_count + self.skipped_blobs_count = skipped_blobs_count + self.failed_blobs_count = failed_blobs_count + self.scanned_blobs_in_gb = scanned_blobs_in_gb + + +class BuiltInInfoType(_serialization.Model): + """Pre-configured sensitive information type. + + :ivar name: Display name of the info type. + :vartype name: str + :ivar id: Id of the info type. + :vartype id: str + :ivar type: Category of the built-in info type. + :vartype type: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Display name of the info type. + :paramtype name: str + :keyword id: Id of the info type. + :paramtype id: str + :keyword type: Category of the built-in info type. + :paramtype type: str + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.type = type + + +class CategoryConfiguration(_serialization.Model): + """Severity level per category configuration for PR Annotations. + + :ivar minimum_severity_level: Gets or sets minimum severity level for a given category. + :vartype minimum_severity_level: str + :ivar category: Rule categories. + Code - code scanning results. + Artifact scanning results. + Dependencies scanning results. + IaC results. + Secrets scanning results. + Container scanning results. Known values are: "Code", "Artifacts", "Dependencies", "Secrets", + "IaC", and "Containers". + :vartype category: str or ~azure.mgmt.security.models.RuleCategory + """ + + _attribute_map = { + "minimum_severity_level": {"key": "minimumSeverityLevel", "type": "str"}, + "category": {"key": "category", "type": "str"}, + } + + def __init__( + self, + *, + minimum_severity_level: Optional[str] = None, + category: Optional[Union[str, "_models.RuleCategory"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword minimum_severity_level: Gets or sets minimum severity level for a given category. + :paramtype minimum_severity_level: str + :keyword category: Rule categories. + Code - code scanning results. + Artifact scanning results. + Dependencies scanning results. + IaC results. + Secrets scanning results. + Container scanning results. Known values are: "Code", "Artifacts", "Dependencies", "Secrets", + "IaC", and "Containers". + :paramtype category: str or ~azure.mgmt.security.models.RuleCategory + """ + super().__init__(**kwargs) + self.minimum_severity_level = minimum_severity_level + self.category = category + + +class CefExternalSecuritySolution(ExternalSecuritySolution): + """Represents a security solution which sends CEF logs to an OMS workspace. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :vartype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: The external security solution properties for CEF solutions. + :vartype properties: ~azure.mgmt.security.models.CefSolutionProperties + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "CefSolutionProperties"}, + } + + def __init__( + self, + *, + kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, + properties: Optional["_models.CefSolutionProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". + :paramtype kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum + :keyword properties: The external security solution properties for CEF solutions. + :paramtype properties: ~azure.mgmt.security.models.CefSolutionProperties + """ + super().__init__(kind=kind, **kwargs) + self.properties = properties + + +class CefSolutionProperties(ExternalSecuritySolutionProperties): + """The external security solution properties for CEF solutions. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar device_vendor: + :vartype device_vendor: str + :ivar device_type: + :vartype device_type: str + :ivar workspace: Represents an OMS workspace to which the solution is connected. + :vartype workspace: ~azure.mgmt.security.models.ConnectedWorkspace + :ivar hostname: + :vartype hostname: str + :ivar agent: + :vartype agent: str + :ivar last_event_received: + :vartype last_event_received: str + """ + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "device_vendor": {"key": "deviceVendor", "type": "str"}, + "device_type": {"key": "deviceType", "type": "str"}, + "workspace": {"key": "workspace", "type": "ConnectedWorkspace"}, + "hostname": {"key": "hostname", "type": "str"}, + "agent": {"key": "agent", "type": "str"}, + "last_event_received": {"key": "lastEventReceived", "type": "str"}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, Any]] = None, + device_vendor: Optional[str] = None, + device_type: Optional[str] = None, + workspace: Optional["_models.ConnectedWorkspace"] = None, + hostname: Optional[str] = None, + agent: Optional[str] = None, + last_event_received: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword device_vendor: + :paramtype device_vendor: str + :keyword device_type: + :paramtype device_type: str + :keyword workspace: Represents an OMS workspace to which the solution is connected. + :paramtype workspace: ~azure.mgmt.security.models.ConnectedWorkspace + :keyword hostname: + :paramtype hostname: str + :keyword agent: + :paramtype agent: str + :keyword last_event_received: + :paramtype last_event_received: str + """ + super().__init__( + additional_properties=additional_properties, + device_vendor=device_vendor, + device_type=device_type, + workspace=workspace, + **kwargs + ) + self.hostname = hostname + self.agent = agent + self.last_event_received = last_event_received + + +class CloudErrorBody(_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.security.models.CloudErrorBody] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.security.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": "[CloudErrorBody]"}, + "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.CloudErrorBody"]] = None + self.additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = None + + +class CloudOffering(_serialization.Model): + """The security offering details. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CspmMonitorAwsOffering, CspmMonitorAzureDevOpsOffering, CspmMonitorDockerHubOffering, + CspmMonitorGcpOffering, CspmMonitorGitLabOffering, CspmMonitorGithubOffering, + CspmMonitorJFrogOffering, DefenderCspmAwsOffering, DefenderCspmDockerHubOffering, + DefenderCspmGcpOffering, DefenderCspmJFrogOffering, DefenderForContainersAwsOffering, + DefenderForContainersDockerHubOffering, DefenderForContainersGcpOffering, + DefenderForContainersJFrogOffering, DefenderFoDatabasesAwsOffering, + DefenderForDatabasesGcpOffering, DefenderForServersAwsOffering, DefenderForServersGcpOffering + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + _subtype_map = { + "offering_type": { + "CspmMonitorAws": "CspmMonitorAwsOffering", + "CspmMonitorAzureDevOps": "CspmMonitorAzureDevOpsOffering", + "CspmMonitorDockerHub": "CspmMonitorDockerHubOffering", + "CspmMonitorGcp": "CspmMonitorGcpOffering", + "CspmMonitorGitLab": "CspmMonitorGitLabOffering", + "CspmMonitorGithub": "CspmMonitorGithubOffering", + "CspmMonitorJFrog": "CspmMonitorJFrogOffering", + "DefenderCspmAws": "DefenderCspmAwsOffering", + "DefenderCspmDockerHub": "DefenderCspmDockerHubOffering", + "DefenderCspmGcp": "DefenderCspmGcpOffering", + "DefenderCspmJFrog": "DefenderCspmJFrogOffering", + "DefenderForContainersAws": "DefenderForContainersAwsOffering", + "DefenderForContainersDockerHub": "DefenderForContainersDockerHubOffering", + "DefenderForContainersGcp": "DefenderForContainersGcpOffering", + "DefenderForContainersJFrog": "DefenderForContainersJFrogOffering", + "DefenderForDatabasesAws": "DefenderFoDatabasesAwsOffering", + "DefenderForDatabasesGcp": "DefenderForDatabasesGcpOffering", + "DefenderForServersAws": "DefenderForServersAwsOffering", + "DefenderForServersGcp": "DefenderForServersGcpOffering", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: Optional[str] = None + self.description: Optional[str] = None + + +class Compliance(Resource): + """Compliance of a scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar assessment_timestamp_utc_date: The timestamp when the Compliance calculation was + conducted. + :vartype assessment_timestamp_utc_date: ~datetime.datetime + :ivar resource_count: The resource count of the given subscription for which the Compliance + calculation was conducted (needed for Management Group Compliance calculation). + :vartype resource_count: int + :ivar assessment_result: An array of segment, which is the actually the compliance assessment. + :vartype assessment_result: list[~azure.mgmt.security.models.ComplianceSegment] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "assessment_timestamp_utc_date": {"readonly": True}, + "resource_count": {"readonly": True}, + "assessment_result": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "assessment_timestamp_utc_date": {"key": "properties.assessmentTimestampUtcDate", "type": "iso-8601"}, + "resource_count": {"key": "properties.resourceCount", "type": "int"}, + "assessment_result": {"key": "properties.assessmentResult", "type": "[ComplianceSegment]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.assessment_timestamp_utc_date: Optional[datetime.datetime] = None + self.resource_count: Optional[int] = None + self.assessment_result: Optional[List["_models.ComplianceSegment"]] = None + + +class ComplianceList(_serialization.Model): + """List of Compliance objects response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Compliance objects. + :vartype value: list[~azure.mgmt.security.models.Compliance] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Compliance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Compliance"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of Compliance objects. + :paramtype value: list[~azure.mgmt.security.models.Compliance] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class ComplianceResult(Resource): + """a compliance result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar resource_status: The status of the resource regarding a single assessment. Known values + are: "Healthy", "NotApplicable", "OffByPolicy", and "NotHealthy". + :vartype resource_status: str or ~azure.mgmt.security.models.ResourceStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource_status": {"key": "properties.resourceStatus", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.resource_status: Optional[Union[str, "_models.ResourceStatus"]] = None + + +class ComplianceResultList(_serialization.Model): + """List of compliance results response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: List of compliance results. Required. + :vartype value: list[~azure.mgmt.security.models.ComplianceResult] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ComplianceResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.ComplianceResult"], **kwargs: Any) -> None: + """ + :keyword value: List of compliance results. Required. + :paramtype value: list[~azure.mgmt.security.models.ComplianceResult] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class ComplianceSegment(_serialization.Model): + """A segment of a compliance assessment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar segment_type: The segment type, e.g. compliant, non-compliance, insufficient coverage, + N/A, etc. + :vartype segment_type: str + :ivar percentage: The size (%) of the segment. + :vartype percentage: float + """ + + _validation = { + "segment_type": {"readonly": True}, + "percentage": {"readonly": True}, + } + + _attribute_map = { + "segment_type": {"key": "segmentType", "type": "str"}, + "percentage": {"key": "percentage", "type": "float"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.segment_type: Optional[str] = None + self.percentage: Optional[float] = None + + +class Components1Uu4J47SchemasSecurityassessmentpropertiesbasePropertiesRiskPropertiesPathsItemsPropertiesEdgesItems( + _serialization.Model +): # pylint: disable=name-too-long + """Components1Uu4J47SchemasSecurityassessmentpropertiesbasePropertiesRiskPropertiesPathsItemsPropertiesEdgesItems. + + All required parameters must be populated in order to send to server. + + :ivar id: Edge identifier. Required. + :vartype id: str + :ivar target_id: Target node identifier. Required. + :vartype target_id: str + :ivar source_id: Source node identifier. Required. + :vartype source_id: str + """ + + _validation = { + "id": {"required": True}, + "target_id": {"required": True}, + "source_id": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "target_id": {"key": "targetId", "type": "str"}, + "source_id": {"key": "sourceId", "type": "str"}, + } + + def __init__( + self, *, id: str, target_id: str, source_id: str, **kwargs: Any # pylint: disable=redefined-builtin + ) -> None: + """ + :keyword id: Edge identifier. Required. + :paramtype id: str + :keyword target_id: Target node identifier. Required. + :paramtype target_id: str + :keyword source_id: Source node identifier. Required. + :paramtype source_id: str + """ + super().__init__(**kwargs) + self.id = id + self.target_id = target_id + self.source_id = source_id + + +class Condition(_serialization.Model): + """Governance rule's condition. + + :ivar property: The governance rule Condition's Property, e.g. Severity or AssessmentKey, see + examples. + :vartype property: str + :ivar value: The governance rule Condition's Value like severity Low, High or assessments keys, + see examples. + :vartype value: str + :ivar operator: The governance rule Condition's Operator, for example Equals for severity or In + for list of assessments, see examples. Known values are: "Equals", "In", and "In". + :vartype operator: str or ~azure.mgmt.security.models.GovernanceRuleConditionOperator + """ + + _attribute_map = { + "property": {"key": "property", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + } + + def __init__( + self, + *, + property: Optional[str] = None, # pylint: disable=redefined-builtin + value: Optional[str] = None, + operator: Optional[Union[str, "_models.GovernanceRuleConditionOperator"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword property: The governance rule Condition's Property, e.g. Severity or AssessmentKey, + see examples. + :paramtype property: str + :keyword value: The governance rule Condition's Value like severity Low, High or assessments + keys, see examples. + :paramtype value: str + :keyword operator: The governance rule Condition's Operator, for example Equals for severity or + In for list of assessments, see examples. Known values are: "Equals", "In", and "In". + :paramtype operator: str or ~azure.mgmt.security.models.GovernanceRuleConditionOperator + """ + super().__init__(**kwargs) + self.property = property + self.value = value + self.operator = operator + + +class ConnectableResource(_serialization.Model): + """Describes the allowed inbound and outbound traffic of an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The Azure resource id. + :vartype id: str + :ivar inbound_connected_resources: The list of Azure resources that the resource has inbound + allowed connection from. + :vartype inbound_connected_resources: list[~azure.mgmt.security.models.ConnectedResource] + :ivar outbound_connected_resources: The list of Azure resources that the resource has outbound + allowed connection to. + :vartype outbound_connected_resources: list[~azure.mgmt.security.models.ConnectedResource] + """ + + _validation = { + "id": {"readonly": True}, + "inbound_connected_resources": {"readonly": True}, + "outbound_connected_resources": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "inbound_connected_resources": {"key": "inboundConnectedResources", "type": "[ConnectedResource]"}, + "outbound_connected_resources": {"key": "outboundConnectedResources", "type": "[ConnectedResource]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.inbound_connected_resources: Optional[List["_models.ConnectedResource"]] = None + self.outbound_connected_resources: Optional[List["_models.ConnectedResource"]] = None + + +class ConnectedResource(_serialization.Model): + """Describes properties of a connected resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar connected_resource_id: The Azure resource id of the connected resource. + :vartype connected_resource_id: str + :ivar tcp_ports: The allowed tcp ports. + :vartype tcp_ports: str + :ivar udp_ports: The allowed udp ports. + :vartype udp_ports: str + """ + + _validation = { + "connected_resource_id": {"readonly": True}, + "tcp_ports": {"readonly": True}, + "udp_ports": {"readonly": True}, + } + + _attribute_map = { + "connected_resource_id": {"key": "connectedResourceId", "type": "str"}, + "tcp_ports": {"key": "tcpPorts", "type": "str"}, + "udp_ports": {"key": "udpPorts", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.connected_resource_id: Optional[str] = None + self.tcp_ports: Optional[str] = None + self.udp_ports: Optional[str] = None + + +class ConnectedWorkspace(_serialization.Model): + """Represents an OMS workspace to which the solution is connected. + + :ivar id: Azure resource ID of the connected OMS workspace. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Azure resource ID of the connected OMS workspace. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class ConnectionFromIpNotAllowed(AllowlistCustomAlertRule): + """Inbound connection from an ip that isn't allowed. Allow list consists of ipv4 or ipv6 range in + CIDR notation. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and + "String". + :vartype value_type: str or ~azure.mgmt.security.models.ValueType + :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. + Required. + :vartype allowlist_values: list[str] + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "value_type": {"readonly": True}, + "allowlist_values": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "value_type": {"key": "valueType", "type": "str"}, + "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, + } + + def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword allowlist_values: The values to allow. The format of the values depends on the rule + type. Required. + :paramtype allowlist_values: list[str] + """ + super().__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) + self.rule_type: str = "ConnectionFromIpNotAllowed" + + +class ConnectionToIpNotAllowed(AllowlistCustomAlertRule): + """Outbound connection to an ip that isn't allowed. Allow list consists of ipv4 or ipv6 range in + CIDR notation. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and + "String". + :vartype value_type: str or ~azure.mgmt.security.models.ValueType + :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. + Required. + :vartype allowlist_values: list[str] + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "value_type": {"readonly": True}, + "allowlist_values": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "value_type": {"key": "valueType", "type": "str"}, + "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, + } + + def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword allowlist_values: The values to allow. The format of the values depends on the rule + type. Required. + :paramtype allowlist_values: list[str] + """ + super().__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) + self.rule_type: str = "ConnectionToIpNotAllowed" + + +class ConnectorSetting(Resource): + """The connector setting. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar hybrid_compute_settings: Settings for hybrid compute management. These settings are + relevant only for Arc autoProvision (Hybrid Compute). + :vartype hybrid_compute_settings: ~azure.mgmt.security.models.HybridComputeSettingsProperties + :ivar authentication_details: Settings for authentication management, these settings are + relevant only for the cloud connector. + :vartype authentication_details: ~azure.mgmt.security.models.AuthenticationDetailsProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "hybrid_compute_settings": { + "key": "properties.hybridComputeSettings", + "type": "HybridComputeSettingsProperties", + }, + "authentication_details": { + "key": "properties.authenticationDetails", + "type": "AuthenticationDetailsProperties", + }, + } + + def __init__( + self, + *, + hybrid_compute_settings: Optional["_models.HybridComputeSettingsProperties"] = None, + authentication_details: Optional["_models.AuthenticationDetailsProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword hybrid_compute_settings: Settings for hybrid compute management. These settings are + relevant only for Arc autoProvision (Hybrid Compute). + :paramtype hybrid_compute_settings: ~azure.mgmt.security.models.HybridComputeSettingsProperties + :keyword authentication_details: Settings for authentication management, these settings are + relevant only for the cloud connector. + :paramtype authentication_details: ~azure.mgmt.security.models.AuthenticationDetailsProperties + """ + super().__init__(**kwargs) + self.hybrid_compute_settings = hybrid_compute_settings + self.authentication_details = authentication_details + + +class ConnectorSettingList(_serialization.Model): + """For a subscription, list of all cloud account connectors and their settings. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of all the cloud account connector settings. + :vartype value: list[~azure.mgmt.security.models.ConnectorSetting] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ConnectorSetting]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ConnectorSetting"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of all the cloud account connector settings. + :paramtype value: list[~azure.mgmt.security.models.ConnectorSetting] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class ContainerRegistryVulnerabilityProperties(AdditionalData): + """Additional context fields for container registry Vulnerability assessment. + + 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 assessed_resource_type: Sub-assessment resource type. Required. Known values are: + "SqlServerVulnerability", "ContainerRegistryVulnerability", and "ServerVulnerability". + :vartype assessed_resource_type: str or ~azure.mgmt.security.models.AssessedResourceType + :ivar type: Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information + Gathered, Vulnerability. + :vartype type: str + :ivar cvss: Dictionary from cvss version to cvss details object. + :vartype cvss: dict[str, ~azure.mgmt.security.models.CVSS] + :ivar patchable: Indicates whether a patch is available or not. + :vartype patchable: bool + :ivar cve: List of CVEs. + :vartype cve: list[~azure.mgmt.security.models.CVE] + :ivar published_time: Published time. + :vartype published_time: ~datetime.datetime + :ivar vendor_references: + :vartype vendor_references: list[~azure.mgmt.security.models.VendorReference] + :ivar repository_name: Name of the repository which the vulnerable image belongs to. + :vartype repository_name: str + :ivar image_digest: Digest of the vulnerable image. + :vartype image_digest: str + """ + + _validation = { + "assessed_resource_type": {"required": True}, + "type": {"readonly": True}, + "cvss": {"readonly": True}, + "patchable": {"readonly": True}, + "cve": {"readonly": True}, + "published_time": {"readonly": True}, + "vendor_references": {"readonly": True}, + "repository_name": {"readonly": True}, + "image_digest": {"readonly": True}, + } + + _attribute_map = { + "assessed_resource_type": {"key": "assessedResourceType", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cvss": {"key": "cvss", "type": "{CVSS}"}, + "patchable": {"key": "patchable", "type": "bool"}, + "cve": {"key": "cve", "type": "[CVE]"}, + "published_time": {"key": "publishedTime", "type": "iso-8601"}, + "vendor_references": {"key": "vendorReferences", "type": "[VendorReference]"}, + "repository_name": {"key": "repositoryName", "type": "str"}, + "image_digest": {"key": "imageDigest", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.assessed_resource_type: str = "ContainerRegistryVulnerability" + self.type: Optional[str] = None + self.cvss: Optional[Dict[str, "_models.CVSS"]] = None + self.patchable: Optional[bool] = None + self.cve: Optional[List["_models.CVE"]] = None + self.published_time: Optional[datetime.datetime] = None + self.vendor_references: Optional[List["_models.VendorReference"]] = None + self.repository_name: Optional[str] = None + self.image_digest: Optional[str] = None + + +class CspmMonitorAwsOffering(CloudOffering): + """The CSPM monitoring for AWS offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar native_cloud_connection: The native cloud connection configuration. + :vartype native_cloud_connection: + ~azure.mgmt.security.models.CspmMonitorAwsOfferingNativeCloudConnection + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "native_cloud_connection": { + "key": "nativeCloudConnection", + "type": "CspmMonitorAwsOfferingNativeCloudConnection", + }, + } + + def __init__( + self, + *, + native_cloud_connection: Optional["_models.CspmMonitorAwsOfferingNativeCloudConnection"] = None, + **kwargs: Any + ) -> None: + """ + :keyword native_cloud_connection: The native cloud connection configuration. + :paramtype native_cloud_connection: + ~azure.mgmt.security.models.CspmMonitorAwsOfferingNativeCloudConnection + """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorAws" + self.native_cloud_connection = native_cloud_connection + + +class CspmMonitorAwsOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long + """The native cloud connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class CspmMonitorAzureDevOpsOffering(CloudOffering): + """The CSPM monitoring for AzureDevOps offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorAzureDevOps" + + +class CspmMonitorDockerHubOffering(CloudOffering): + """The CSPM (Cloud security posture management) monitoring for Docker Hub offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorDockerHub" + + +class CspmMonitorGcpOffering(CloudOffering): + """The CSPM monitoring for GCP offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar native_cloud_connection: The native cloud connection configuration. + :vartype native_cloud_connection: + ~azure.mgmt.security.models.CspmMonitorGcpOfferingNativeCloudConnection + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "native_cloud_connection": { + "key": "nativeCloudConnection", + "type": "CspmMonitorGcpOfferingNativeCloudConnection", + }, + } + + def __init__( + self, + *, + native_cloud_connection: Optional["_models.CspmMonitorGcpOfferingNativeCloudConnection"] = None, + **kwargs: Any + ) -> None: + """ + :keyword native_cloud_connection: The native cloud connection configuration. + :paramtype native_cloud_connection: + ~azure.mgmt.security.models.CspmMonitorGcpOfferingNativeCloudConnection + """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorGcp" + self.native_cloud_connection = native_cloud_connection + + +class CspmMonitorGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long + """The native cloud connection configuration. + + :ivar workload_identity_provider_id: The GCP workload identity provider id for the offering. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this + offering. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword workload_identity_provider_id: The GCP workload identity provider id for the offering. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + offering. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class CspmMonitorGithubOffering(CloudOffering): + """The CSPM monitoring for github offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorGithub" + + +class CspmMonitorGitLabOffering(CloudOffering): + """The CSPM (Cloud security posture management) monitoring for gitlab offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorGitLab" + + +class CspmMonitorJFrogOffering(CloudOffering): + """The CSPM (Cloud security posture management) monitoring for JFrog Artifactory offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorJFrog" + + +class CustomAssessmentAutomation(Resource): + """Custom Assessment Automation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar compressed_query: GZip encoded KQL query representing the assessment automation results + required. + :vartype compressed_query: str + :ivar supported_cloud: Relevant cloud for the custom assessment automation. Known values are: + "AWS" and "GCP". + :vartype supported_cloud: str or ~azure.mgmt.security.models.SupportedCloudEnum + :ivar severity: The severity to relate to the assessments generated by this assessment + automation. Known values are: "High", "Medium", and "Low". + :vartype severity: str or ~azure.mgmt.security.models.SeverityEnum + :ivar display_name: The display name of the assessments generated by this assessment + automation. + :vartype display_name: str + :ivar description: The description to relate to the assessments generated by this assessment + automation. + :vartype description: str + :ivar remediation_description: The remediation description to relate to the assessments + generated by this assessment automation. + :vartype remediation_description: str + :ivar assessment_key: The assessment metadata key used when an assessment is generated for this + assessment automation. + :vartype assessment_key: str + """ + + _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"}, + "compressed_query": {"key": "properties.compressedQuery", "type": "str"}, + "supported_cloud": {"key": "properties.supportedCloud", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, + "assessment_key": {"key": "properties.assessmentKey", "type": "str"}, + } + + def __init__( + self, + *, + compressed_query: Optional[str] = None, + supported_cloud: Union[str, "_models.SupportedCloudEnum"] = "AWS", + severity: Union[str, "_models.SeverityEnum"] = "Low", + display_name: Optional[str] = None, + description: Optional[str] = None, + remediation_description: Optional[str] = None, + assessment_key: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword compressed_query: GZip encoded KQL query representing the assessment automation + results required. + :paramtype compressed_query: str + :keyword supported_cloud: Relevant cloud for the custom assessment automation. Known values + are: "AWS" and "GCP". + :paramtype supported_cloud: str or ~azure.mgmt.security.models.SupportedCloudEnum + :keyword severity: The severity to relate to the assessments generated by this assessment + automation. Known values are: "High", "Medium", and "Low". + :paramtype severity: str or ~azure.mgmt.security.models.SeverityEnum + :keyword display_name: The display name of the assessments generated by this assessment + automation. + :paramtype display_name: str + :keyword description: The description to relate to the assessments generated by this assessment + automation. + :paramtype description: str + :keyword remediation_description: The remediation description to relate to the assessments + generated by this assessment automation. + :paramtype remediation_description: str + :keyword assessment_key: The assessment metadata key used when an assessment is generated for + this assessment automation. + :paramtype assessment_key: str + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.compressed_query = compressed_query + self.supported_cloud = supported_cloud + self.severity = severity + self.display_name = display_name + self.description = description + self.remediation_description = remediation_description + self.assessment_key = assessment_key + + +class CustomAssessmentAutomationRequest(Resource): + """Custom Assessment Automation request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar compressed_query: Base 64 encoded KQL query representing the assessment automation + results required. + :vartype compressed_query: str + :ivar supported_cloud: Relevant cloud for the custom assessment automation. Known values are: + "AWS" and "GCP". + :vartype supported_cloud: str or ~azure.mgmt.security.models.SupportedCloudEnum + :ivar severity: The severity to relate to the assessments generated by this assessment + automation. Known values are: "High", "Medium", and "Low". + :vartype severity: str or ~azure.mgmt.security.models.SeverityEnum + :ivar display_name: The display name of the assessments generated by this assessment + automation. + :vartype display_name: str + :ivar description: The description to relate to the assessments generated by this assessment + automation. + :vartype description: str + :ivar remediation_description: The remediation description to relate to the assessments + generated by this assessment automation. + :vartype remediation_description: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "compressed_query": {"key": "properties.compressedQuery", "type": "str"}, + "supported_cloud": {"key": "properties.supportedCloud", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, + } + + def __init__( + self, + *, + compressed_query: Optional[str] = None, + supported_cloud: Union[str, "_models.SupportedCloudEnum"] = "AWS", + severity: Union[str, "_models.SeverityEnum"] = "Low", + display_name: Optional[str] = None, + description: Optional[str] = None, + remediation_description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword compressed_query: Base 64 encoded KQL query representing the assessment automation + results required. + :paramtype compressed_query: str + :keyword supported_cloud: Relevant cloud for the custom assessment automation. Known values + are: "AWS" and "GCP". + :paramtype supported_cloud: str or ~azure.mgmt.security.models.SupportedCloudEnum + :keyword severity: The severity to relate to the assessments generated by this assessment + automation. Known values are: "High", "Medium", and "Low". + :paramtype severity: str or ~azure.mgmt.security.models.SeverityEnum + :keyword display_name: The display name of the assessments generated by this assessment + automation. + :paramtype display_name: str + :keyword description: The description to relate to the assessments generated by this assessment + automation. + :paramtype description: str + :keyword remediation_description: The remediation description to relate to the assessments + generated by this assessment automation. + :paramtype remediation_description: str + """ + super().__init__(**kwargs) + self.compressed_query = compressed_query + self.supported_cloud = supported_cloud + self.severity = severity + self.display_name = display_name + self.description = description + self.remediation_description = remediation_description + + +class CustomAssessmentAutomationsListResult(_serialization.Model): + """A list of Custom Assessment Automations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of Custom Assessment Automations. + :vartype value: list[~azure.mgmt.security.models.CustomAssessmentAutomation] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[CustomAssessmentAutomation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[List["_models.CustomAssessmentAutomation"]] = None + self.next_link = next_link + + +class CustomEntityStoreAssignment(Resource): + """Custom entity store assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar principal: The principal assigned with entity store. Format of principal is: [AAD + type]=[PrincipalObjectId];[TenantId]. + :vartype principal: str + :ivar entity_store_database_link: The link to entity store database. + :vartype entity_store_database_link: str + """ + + _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"}, + "principal": {"key": "properties.principal", "type": "str"}, + "entity_store_database_link": {"key": "properties.entityStoreDatabaseLink", "type": "str"}, + } + + def __init__( + self, *, principal: Optional[str] = None, entity_store_database_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword principal: The principal assigned with entity store. Format of principal is: [AAD + type]=[PrincipalObjectId];[TenantId]. + :paramtype principal: str + :keyword entity_store_database_link: The link to entity store database. + :paramtype entity_store_database_link: str + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.principal = principal + self.entity_store_database_link = entity_store_database_link + + +class CustomEntityStoreAssignmentRequest(_serialization.Model): + """describes the custom entity store assignment request. + + :ivar principal: The principal assigned with entity store. If not provided, will use caller + principal. Format of principal is: [AAD type]=[PrincipalObjectId];[TenantId]. + :vartype principal: str + """ + + _attribute_map = { + "principal": {"key": "properties.principal", "type": "str"}, + } + + def __init__(self, *, principal: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword principal: The principal assigned with entity store. If not provided, will use caller + principal. Format of principal is: [AAD type]=[PrincipalObjectId];[TenantId]. + :paramtype principal: str + """ + super().__init__(**kwargs) + self.principal = principal + + +class CustomEntityStoreAssignmentsListResult(_serialization.Model): + """A list of custom entity store assignments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of custom entity store assignments. + :vartype value: list[~azure.mgmt.security.models.CustomEntityStoreAssignment] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[CustomEntityStoreAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[List["_models.CustomEntityStoreAssignment"]] = None + self.next_link = next_link + + +class CustomRecommendation(Resource): + """Custom Recommendation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar query: KQL query representing the Recommendation results required. + :vartype query: str + :ivar cloud_providers: List of all standard supported clouds. + :vartype cloud_providers: list[str or + ~azure.mgmt.security.models.RecommendationSupportedClouds] + :ivar severity: The severity to relate to the assessments generated by this Recommendation. + Known values are: "High", "Medium", and "Low". + :vartype severity: str or ~azure.mgmt.security.models.SeverityEnum + :ivar security_issue: The severity to relate to the assessments generated by this + Recommendation. Known values are: "Vulnerability", "ExcessivePermissions", "AnonymousAccess", + "NetworkExposure", "TrafficEncryption", and "BestPractices". + :vartype security_issue: str or ~azure.mgmt.security.models.SecurityIssue + :ivar display_name: The display name of the assessments generated by this Recommendation. + :vartype display_name: str + :ivar description: The description to relate to the assessments generated by this + Recommendation. + :vartype description: str + :ivar remediation_description: The remediation description to relate to the assessments + generated by this Recommendation. + :vartype remediation_description: str + :ivar assessment_key: The assessment metadata key used when an assessment is generated for this + Recommendation. + :vartype assessment_key: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "assessment_key": {"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"}, + "query": {"key": "properties.query", "type": "str"}, + "cloud_providers": {"key": "properties.cloudProviders", "type": "[str]"}, + "severity": {"key": "properties.severity", "type": "str"}, + "security_issue": {"key": "properties.securityIssue", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, + "assessment_key": {"key": "properties.assessmentKey", "type": "str"}, + } + + def __init__( + self, + *, + query: Optional[str] = None, + cloud_providers: Optional[List[Union[str, "_models.RecommendationSupportedClouds"]]] = None, + severity: Union[str, "_models.SeverityEnum"] = "Low", + security_issue: Union[str, "_models.SecurityIssue"] = "BestPractices", + display_name: Optional[str] = None, + description: Optional[str] = None, + remediation_description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword query: KQL query representing the Recommendation results required. + :paramtype query: str + :keyword cloud_providers: List of all standard supported clouds. + :paramtype cloud_providers: list[str or + ~azure.mgmt.security.models.RecommendationSupportedClouds] + :keyword severity: The severity to relate to the assessments generated by this Recommendation. + Known values are: "High", "Medium", and "Low". + :paramtype severity: str or ~azure.mgmt.security.models.SeverityEnum + :keyword security_issue: The severity to relate to the assessments generated by this + Recommendation. Known values are: "Vulnerability", "ExcessivePermissions", "AnonymousAccess", + "NetworkExposure", "TrafficEncryption", and "BestPractices". + :paramtype security_issue: str or ~azure.mgmt.security.models.SecurityIssue + :keyword display_name: The display name of the assessments generated by this Recommendation. + :paramtype display_name: str + :keyword description: The description to relate to the assessments generated by this + Recommendation. + :paramtype description: str + :keyword remediation_description: The remediation description to relate to the assessments + generated by this Recommendation. + :paramtype remediation_description: str + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.query = query + self.cloud_providers = cloud_providers + self.severity = severity + self.security_issue = security_issue + self.display_name = display_name + self.description = description + self.remediation_description = remediation_description + self.assessment_key: Optional[str] = None + + +class CustomRecommendationsList(_serialization.Model): + """A list of Custom Recommendations. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: Collection of Custom Recommendations. Required. + :vartype value: list[~azure.mgmt.security.models.CustomRecommendation] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True, "readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[CustomRecommendation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[List["_models.CustomRecommendation"]] = None + self.next_link = next_link + + +class CVE(_serialization.Model): + """CVE details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar title: CVE title. + :vartype title: str + :ivar link: Link url. + :vartype link: str + """ + + _validation = { + "title": {"readonly": True}, + "link": {"readonly": True}, + } + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "link": {"key": "link", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.title: Optional[str] = None + self.link: Optional[str] = None + + +class CVSS(_serialization.Model): + """CVSS details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar base: CVSS base. + :vartype base: float + """ + + _validation = { + "base": {"readonly": True}, + } + + _attribute_map = { + "base": {"key": "base", "type": "float"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.base: Optional[float] = None + + +class DataExportSettings(Setting): + """Represents a data export setting. + + 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: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", + "AlertSuppressionSetting", and "AlertSyncSettings". + :vartype kind: str or ~azure.mgmt.security.models.SettingKind + :ivar enabled: Is the data export setting enabled. + :vartype enabled: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is the data export setting enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.kind: str = "DataExportSettings" + self.enabled = enabled + + +class DefenderCspmAwsOffering(CloudOffering): + """The CSPM P1 for AWS offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar vm_scanners: The Microsoft Defender for CSPM offering VM scanning configuration. + :vartype vm_scanners: ~azure.mgmt.security.models.DefenderCspmAwsOfferingVmScanners + :ivar data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery + configuration. + :vartype data_sensitivity_discovery: + ~azure.mgmt.security.models.DefenderCspmAwsOfferingDataSensitivityDiscovery + :ivar databases_dspm: The databases DSPM configuration. + :vartype databases_dspm: ~azure.mgmt.security.models.DefenderCspmAwsOfferingDatabasesDspm + :ivar ciem: Defenders CSPM Permissions Management offering configurations. + :vartype ciem: ~azure.mgmt.security.models.DefenderCspmAwsOfferingCiem + :ivar mdc_containers_image_assessment: The Microsoft Defender container image assessment + configuration. + :vartype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderCspmAwsOfferingMdcContainersImageAssessment + :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless + discovery K8s configuration. + :vartype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderCspmAwsOfferingVmScanners"}, + "data_sensitivity_discovery": { + "key": "dataSensitivityDiscovery", + "type": "DefenderCspmAwsOfferingDataSensitivityDiscovery", + }, + "databases_dspm": {"key": "databasesDspm", "type": "DefenderCspmAwsOfferingDatabasesDspm"}, + "ciem": {"key": "ciem", "type": "DefenderCspmAwsOfferingCiem"}, + "mdc_containers_image_assessment": { + "key": "mdcContainersImageAssessment", + "type": "DefenderCspmAwsOfferingMdcContainersImageAssessment", + }, + "mdc_containers_agentless_discovery_k8_s": { + "key": "mdcContainersAgentlessDiscoveryK8s", + "type": "DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S", + }, + } + + def __init__( + self, + *, + vm_scanners: Optional["_models.DefenderCspmAwsOfferingVmScanners"] = None, + data_sensitivity_discovery: Optional["_models.DefenderCspmAwsOfferingDataSensitivityDiscovery"] = None, + databases_dspm: Optional["_models.DefenderCspmAwsOfferingDatabasesDspm"] = None, + ciem: Optional["_models.DefenderCspmAwsOfferingCiem"] = None, + mdc_containers_image_assessment: Optional["_models.DefenderCspmAwsOfferingMdcContainersImageAssessment"] = None, + mdc_containers_agentless_discovery_k8_s: Optional[ + "_models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword vm_scanners: The Microsoft Defender for CSPM offering VM scanning configuration. + :paramtype vm_scanners: ~azure.mgmt.security.models.DefenderCspmAwsOfferingVmScanners + :keyword data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery + configuration. + :paramtype data_sensitivity_discovery: + ~azure.mgmt.security.models.DefenderCspmAwsOfferingDataSensitivityDiscovery + :keyword databases_dspm: The databases DSPM configuration. + :paramtype databases_dspm: ~azure.mgmt.security.models.DefenderCspmAwsOfferingDatabasesDspm + :keyword ciem: Defenders CSPM Permissions Management offering configurations. + :paramtype ciem: ~azure.mgmt.security.models.DefenderCspmAwsOfferingCiem + :keyword mdc_containers_image_assessment: The Microsoft Defender container image assessment + configuration. + :paramtype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderCspmAwsOfferingMdcContainersImageAssessment + :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless + discovery K8s configuration. + :paramtype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderCspmAws" + self.vm_scanners = vm_scanners + self.data_sensitivity_discovery = data_sensitivity_discovery + self.databases_dspm = databases_dspm + self.ciem = ciem + self.mdc_containers_image_assessment = mdc_containers_image_assessment + self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s + + +class DefenderCspmAwsOfferingCiem(_serialization.Model): + """Defenders CSPM Permissions Management offering configurations. + + :ivar ciem_discovery: Defender CSPM Permissions Management discovery configuration. + :vartype ciem_discovery: ~azure.mgmt.security.models.DefenderCspmAwsOfferingCiemDiscovery + :ivar ciem_oidc: AWS Defender CSPM Permissions Management OIDC (open id connect) connection + configurations. + :vartype ciem_oidc: ~azure.mgmt.security.models.DefenderCspmAwsOfferingCiemOidc + """ + + _attribute_map = { + "ciem_discovery": {"key": "ciemDiscovery", "type": "DefenderCspmAwsOfferingCiemDiscovery"}, + "ciem_oidc": {"key": "ciemOidc", "type": "DefenderCspmAwsOfferingCiemOidc"}, + } + + def __init__( + self, + *, + ciem_discovery: Optional["_models.DefenderCspmAwsOfferingCiemDiscovery"] = None, + ciem_oidc: Optional["_models.DefenderCspmAwsOfferingCiemOidc"] = None, + **kwargs: Any + ) -> None: + """ + :keyword ciem_discovery: Defender CSPM Permissions Management discovery configuration. + :paramtype ciem_discovery: ~azure.mgmt.security.models.DefenderCspmAwsOfferingCiemDiscovery + :keyword ciem_oidc: AWS Defender CSPM Permissions Management OIDC (open id connect) connection + configurations. + :paramtype ciem_oidc: ~azure.mgmt.security.models.DefenderCspmAwsOfferingCiemOidc + """ + super().__init__(**kwargs) + self.ciem_discovery = ciem_discovery + self.ciem_oidc = ciem_oidc + + +class DefenderCspmAwsOfferingCiemDiscovery(_serialization.Model): + """Defender CSPM Permissions Management discovery configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for Permissions Management discovery. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for Permissions Management discovery. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingCiemOidc(_serialization.Model): + """AWS Defender CSPM Permissions Management OIDC (open id connect) connection configurations. + + :ivar cloud_role_arn: The cloud role ARN in AWS for Permissions Management used for oidc + connection. + :vartype cloud_role_arn: str + :ivar azure_active_directory_app_name: the azure active directory app name used of + authenticating against AWS. + :vartype azure_active_directory_app_name: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + "azure_active_directory_app_name": {"key": "azureActiveDirectoryAppName", "type": "str"}, + } + + def __init__( + self, + *, + cloud_role_arn: Optional[str] = None, + azure_active_directory_app_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for Permissions Management used for oidc + connection. + :paramtype cloud_role_arn: str + :keyword azure_active_directory_app_name: the azure active directory app name used of + authenticating against AWS. + :paramtype azure_active_directory_app_name: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + self.azure_active_directory_app_name = azure_active_directory_app_name + + +class DefenderCspmAwsOfferingDatabasesDspm(_serialization.Model): + """The databases DSPM configuration. + + :ivar enabled: Is databases DSPM protection enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is databases DSPM protection enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingDataSensitivityDiscovery(_serialization.Model): # pylint: disable=name-too-long + """The Microsoft Defender Data Sensitivity discovery configuration. + + :ivar enabled: Is Microsoft Defender Data Sensitivity discovery enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender Data Sensitivity discovery enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S(_serialization.Model): # pylint: disable=name-too-long + """The Microsoft Defender container agentless discovery K8s configuration. + + :ivar enabled: Is Microsoft Defender container agentless discovery K8s enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender container agentless discovery K8s enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingMdcContainersImageAssessment(_serialization.Model): # pylint: disable=name-too-long + """The Microsoft Defender container image assessment configuration. + + :ivar enabled: Is Microsoft Defender container image assessment enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender container image assessment enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class VmScannersBase(_serialization.Model): + """A VM scanning configuration for a security offering of a given environment. + + :ivar enabled: Is VM scanning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for VM scanning. + :vartype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "VmScannersBaseConfiguration"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.VmScannersBaseConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is VM scanning enabled. + :paramtype enabled: bool + :keyword configuration: Configuration for VM scanning. + :paramtype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class VmScannersAws(VmScannersBase): + """A VM scanning configuration for a security offering of a Aws environment. + + :ivar enabled: Is VM scanning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for VM scanning. + :vartype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "VmScannersBaseConfiguration"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.VmScannersBaseConfiguration"] = None, + cloud_role_arn: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is VM scanning enabled. + :paramtype enabled: bool + :keyword configuration: Configuration for VM scanning. + :paramtype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(enabled=enabled, configuration=configuration, **kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingVmScanners(VmScannersAws): + """The Microsoft Defender for CSPM offering VM scanning configuration. + + :ivar enabled: Is VM scanning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for VM scanning. + :vartype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + +class DefenderCspmDockerHubOffering(CloudOffering): + """The Defender for CSPM Docker Hub offering configurations. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderCspmDockerHub" + + +class DefenderCspmGcpOffering(CloudOffering): + """The CSPM P1 for GCP offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar ciem_discovery: GCP Defenders CSPM Permissions Management OIDC (Open ID connect) + connection configurations. + :vartype ciem_discovery: ~azure.mgmt.security.models.DefenderCspmGcpOfferingCiemDiscovery + :ivar vm_scanners: The Microsoft Defender for CSPM VM scanning configuration. + :vartype vm_scanners: ~azure.mgmt.security.models.DefenderCspmGcpOfferingVmScanners + :ivar data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery + configuration. + :vartype data_sensitivity_discovery: + ~azure.mgmt.security.models.DefenderCspmGcpOfferingDataSensitivityDiscovery + :ivar mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :vartype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderCspmGcpOfferingMdcContainersImageAssessment + :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless + discovery configuration. + :vartype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "ciem_discovery": {"key": "ciemDiscovery", "type": "DefenderCspmGcpOfferingCiemDiscovery"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderCspmGcpOfferingVmScanners"}, + "data_sensitivity_discovery": { + "key": "dataSensitivityDiscovery", + "type": "DefenderCspmGcpOfferingDataSensitivityDiscovery", + }, + "mdc_containers_image_assessment": { + "key": "mdcContainersImageAssessment", + "type": "DefenderCspmGcpOfferingMdcContainersImageAssessment", + }, + "mdc_containers_agentless_discovery_k8_s": { + "key": "mdcContainersAgentlessDiscoveryK8s", + "type": "DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S", + }, + } + + def __init__( + self, + *, + ciem_discovery: Optional["_models.DefenderCspmGcpOfferingCiemDiscovery"] = None, + vm_scanners: Optional["_models.DefenderCspmGcpOfferingVmScanners"] = None, + data_sensitivity_discovery: Optional["_models.DefenderCspmGcpOfferingDataSensitivityDiscovery"] = None, + mdc_containers_image_assessment: Optional["_models.DefenderCspmGcpOfferingMdcContainersImageAssessment"] = None, + mdc_containers_agentless_discovery_k8_s: Optional[ + "_models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword ciem_discovery: GCP Defenders CSPM Permissions Management OIDC (Open ID connect) + connection configurations. + :paramtype ciem_discovery: ~azure.mgmt.security.models.DefenderCspmGcpOfferingCiemDiscovery + :keyword vm_scanners: The Microsoft Defender for CSPM VM scanning configuration. + :paramtype vm_scanners: ~azure.mgmt.security.models.DefenderCspmGcpOfferingVmScanners + :keyword data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery + configuration. + :paramtype data_sensitivity_discovery: + ~azure.mgmt.security.models.DefenderCspmGcpOfferingDataSensitivityDiscovery + :keyword mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :paramtype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderCspmGcpOfferingMdcContainersImageAssessment + :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless + discovery configuration. + :paramtype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderCspmGcp" + self.ciem_discovery = ciem_discovery + self.vm_scanners = vm_scanners + self.data_sensitivity_discovery = data_sensitivity_discovery + self.mdc_containers_image_assessment = mdc_containers_image_assessment + self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s + + +class DefenderCspmGcpOfferingCiemDiscovery(_serialization.Model): + """GCP Defenders CSPM Permissions Management OIDC (Open ID connect) connection configurations. + + :ivar workload_identity_provider_id: The GCP workload identity provider id for Permissions + Management offering. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for Permissions + Management offering. + :vartype service_account_email_address: str + :ivar azure_active_directory_app_name: the azure active directory app name used of + authenticating against GCP workload identity federation. + :vartype azure_active_directory_app_name: str + """ + + _attribute_map = { + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "azure_active_directory_app_name": {"key": "azureActiveDirectoryAppName", "type": "str"}, + } + + def __init__( + self, + *, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + azure_active_directory_app_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword workload_identity_provider_id: The GCP workload identity provider id for Permissions + Management offering. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for + Permissions Management offering. + :paramtype service_account_email_address: str + :keyword azure_active_directory_app_name: the azure active directory app name used of + authenticating against GCP workload identity federation. + :paramtype azure_active_directory_app_name: str + """ + super().__init__(**kwargs) + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + self.azure_active_directory_app_name = azure_active_directory_app_name + + +class DefenderCspmGcpOfferingDataSensitivityDiscovery(_serialization.Model): # pylint: disable=name-too-long + """The Microsoft Defender Data Sensitivity discovery configuration. + + :ivar enabled: Is Microsoft Defender Data Sensitivity discovery enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender Data Sensitivity discovery enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S(_serialization.Model): # pylint: disable=name-too-long + """The Microsoft Defender Container agentless discovery configuration. + + :ivar enabled: Is Microsoft Defender container agentless discovery enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender container agentless discovery enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderCspmGcpOfferingMdcContainersImageAssessment(_serialization.Model): # pylint: disable=name-too-long + """The Microsoft Defender Container image assessment configuration. + + :ivar enabled: Is Microsoft Defender container image assessment enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender container image assessment enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class VmScannersGcp(VmScannersBase): + """A VM scanning configuration for a security offering of a GCP environment. + + :ivar enabled: Is VM scanning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for VM scanning. + :vartype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + """ + + +class DefenderCspmGcpOfferingVmScanners(VmScannersGcp): + """The Microsoft Defender for CSPM VM scanning configuration. + + :ivar enabled: Is VM scanning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for VM scanning. + :vartype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + """ + + +class DefenderCspmJFrogOffering(CloudOffering): + """The CSPM P1 for JFrog Artifactory offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :vartype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderCspmJFrogOfferingMdcContainersImageAssessment + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "mdc_containers_image_assessment": { + "key": "mdcContainersImageAssessment", + "type": "DefenderCspmJFrogOfferingMdcContainersImageAssessment", + }, + } + + def __init__( + self, + *, + mdc_containers_image_assessment: Optional[ + "_models.DefenderCspmJFrogOfferingMdcContainersImageAssessment" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :paramtype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderCspmJFrogOfferingMdcContainersImageAssessment + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderCspmJFrog" + self.mdc_containers_image_assessment = mdc_containers_image_assessment + + +class DefenderCspmJFrogOfferingMdcContainersImageAssessment(_serialization.Model): # pylint: disable=name-too-long + """The Microsoft Defender Container image assessment configuration. + + :ivar enabled: Is Microsoft Defender container image assessment enabled. + :vartype enabled: bool + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender container image assessment enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + + +class DefenderFoDatabasesAwsOffering(CloudOffering): + """The Defender for Databases AWS offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning + :ivar rds: The RDS configuration. + :vartype rds: ~azure.mgmt.security.models.DefenderFoDatabasesAwsOfferingRds + :ivar databases_dspm: The databases data security posture management (DSPM) configuration. + :vartype databases_dspm: + ~azure.mgmt.security.models.DefenderFoDatabasesAwsOfferingDatabasesDspm + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", + }, + "rds": {"key": "rds", "type": "DefenderFoDatabasesAwsOfferingRds"}, + "databases_dspm": {"key": "databasesDspm", "type": "DefenderFoDatabasesAwsOfferingDatabasesDspm"}, + } + + def __init__( + self, + *, + arc_auto_provisioning: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning"] = None, + rds: Optional["_models.DefenderFoDatabasesAwsOfferingRds"] = None, + databases_dspm: Optional["_models.DefenderFoDatabasesAwsOfferingDatabasesDspm"] = None, + **kwargs: Any + ) -> None: + """ + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning + :keyword rds: The RDS configuration. + :paramtype rds: ~azure.mgmt.security.models.DefenderFoDatabasesAwsOfferingRds + :keyword databases_dspm: The databases data security posture management (DSPM) configuration. + :paramtype databases_dspm: + ~azure.mgmt.security.models.DefenderFoDatabasesAwsOfferingDatabasesDspm + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForDatabasesAws" + self.arc_auto_provisioning = arc_auto_provisioning + self.rds = rds + self.databases_dspm = databases_dspm + + +class DefenderFoDatabasesAwsOfferingArcAutoProvisioning(ArcAutoProvisioningAws): # pylint: disable=name-too-long + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for servers Arc auto provisioning for a given environment. + :vartype configuration: ~azure.mgmt.security.models.ArcAutoProvisioningConfiguration + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + +class DefenderFoDatabasesAwsOfferingDatabasesDspm(_serialization.Model): # pylint: disable=name-too-long + """The databases data security posture management (DSPM) configuration. + + :ivar enabled: Is databases data security posture management (DSPM) protection enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is databases data security posture management (DSPM) protection enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderFoDatabasesAwsOfferingRds(_serialization.Model): + """The RDS configuration. + + :ivar enabled: Is RDS protection enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is RDS protection enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOffering(CloudOffering): + """The Defender for Containers AWS offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar kubernetes_service: The kubernetes service connection configuration. + :vartype kubernetes_service: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingKubernetesService + :ivar kubernetes_data_collection: The kubernetes data collection connection configuration. + :vartype kubernetes_data_collection: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingKubernetesDataCollection + :ivar cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. + :vartype cloud_watch_to_kinesis: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingCloudWatchToKinesis + :ivar kinesis_to_s3: The kinesis to s3 connection configuration. + :vartype kinesis_to_s3: ~azure.mgmt.security.models.DefenderForContainersAwsOfferingKinesisToS3 + :ivar enable_audit_logs_auto_provisioning: Is audit logs data collection enabled. + :vartype enable_audit_logs_auto_provisioning: bool + :ivar enable_defender_agent_auto_provisioning: Is Microsoft Defender for Cloud Kubernetes agent + auto provisioning enabled. + :vartype enable_defender_agent_auto_provisioning: bool + :ivar enable_policy_agent_auto_provisioning: Is Policy Kubernetes agent auto provisioning + enabled. + :vartype enable_policy_agent_auto_provisioning: bool + :ivar kube_audit_retention_time: The retention time in days of kube audit logs set on the + CloudWatch log group. + :vartype kube_audit_retention_time: int + :ivar data_collection_external_id: The externalId used by the data reader to prevent the + confused deputy attack. + :vartype data_collection_external_id: str + :ivar mdc_containers_image_assessment: The Microsoft Defender container image assessment + configuration. + :vartype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingMdcContainersImageAssessment + :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless + discovery K8s configuration. + :vartype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S + :ivar vm_scanners: The Microsoft Defender for Container K8s VM host scanning configuration. + :vartype vm_scanners: ~azure.mgmt.security.models.DefenderForContainersAwsOfferingVmScanners + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "kubernetes_service": {"key": "kubernetesService", "type": "DefenderForContainersAwsOfferingKubernetesService"}, + "kubernetes_data_collection": { + "key": "kubernetesDataCollection", + "type": "DefenderForContainersAwsOfferingKubernetesDataCollection", + }, + "cloud_watch_to_kinesis": { + "key": "cloudWatchToKinesis", + "type": "DefenderForContainersAwsOfferingCloudWatchToKinesis", + }, + "kinesis_to_s3": {"key": "kinesisToS3", "type": "DefenderForContainersAwsOfferingKinesisToS3"}, + "enable_audit_logs_auto_provisioning": {"key": "enableAuditLogsAutoProvisioning", "type": "bool"}, + "enable_defender_agent_auto_provisioning": {"key": "enableDefenderAgentAutoProvisioning", "type": "bool"}, + "enable_policy_agent_auto_provisioning": {"key": "enablePolicyAgentAutoProvisioning", "type": "bool"}, + "kube_audit_retention_time": {"key": "kubeAuditRetentionTime", "type": "int"}, + "data_collection_external_id": {"key": "dataCollectionExternalId", "type": "str"}, + "mdc_containers_image_assessment": { + "key": "mdcContainersImageAssessment", + "type": "DefenderForContainersAwsOfferingMdcContainersImageAssessment", + }, + "mdc_containers_agentless_discovery_k8_s": { + "key": "mdcContainersAgentlessDiscoveryK8s", + "type": "DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S", + }, + "vm_scanners": {"key": "vmScanners", "type": "DefenderForContainersAwsOfferingVmScanners"}, + } + + def __init__( + self, + *, + kubernetes_service: Optional["_models.DefenderForContainersAwsOfferingKubernetesService"] = None, + kubernetes_data_collection: Optional["_models.DefenderForContainersAwsOfferingKubernetesDataCollection"] = None, + cloud_watch_to_kinesis: Optional["_models.DefenderForContainersAwsOfferingCloudWatchToKinesis"] = None, + kinesis_to_s3: Optional["_models.DefenderForContainersAwsOfferingKinesisToS3"] = None, + enable_audit_logs_auto_provisioning: Optional[bool] = None, + enable_defender_agent_auto_provisioning: Optional[bool] = None, + enable_policy_agent_auto_provisioning: Optional[bool] = None, + kube_audit_retention_time: Optional[int] = None, + data_collection_external_id: Optional[str] = None, + mdc_containers_image_assessment: Optional[ + "_models.DefenderForContainersAwsOfferingMdcContainersImageAssessment" + ] = None, + mdc_containers_agentless_discovery_k8_s: Optional[ + "_models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S" + ] = None, + vm_scanners: Optional["_models.DefenderForContainersAwsOfferingVmScanners"] = None, + **kwargs: Any + ) -> None: + """ + :keyword kubernetes_service: The kubernetes service connection configuration. + :paramtype kubernetes_service: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingKubernetesService + :keyword kubernetes_data_collection: The kubernetes data collection connection configuration. + :paramtype kubernetes_data_collection: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingKubernetesDataCollection + :keyword cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. + :paramtype cloud_watch_to_kinesis: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingCloudWatchToKinesis + :keyword kinesis_to_s3: The kinesis to s3 connection configuration. + :paramtype kinesis_to_s3: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingKinesisToS3 + :keyword enable_audit_logs_auto_provisioning: Is audit logs data collection enabled. + :paramtype enable_audit_logs_auto_provisioning: bool + :keyword enable_defender_agent_auto_provisioning: Is Microsoft Defender for Cloud Kubernetes + agent auto provisioning enabled. + :paramtype enable_defender_agent_auto_provisioning: bool + :keyword enable_policy_agent_auto_provisioning: Is Policy Kubernetes agent auto provisioning + enabled. + :paramtype enable_policy_agent_auto_provisioning: bool + :keyword kube_audit_retention_time: The retention time in days of kube audit logs set on the + CloudWatch log group. + :paramtype kube_audit_retention_time: int + :keyword data_collection_external_id: The externalId used by the data reader to prevent the + confused deputy attack. + :paramtype data_collection_external_id: str + :keyword mdc_containers_image_assessment: The Microsoft Defender container image assessment + configuration. + :paramtype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingMdcContainersImageAssessment + :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless + discovery K8s configuration. + :paramtype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S + :keyword vm_scanners: The Microsoft Defender for Container K8s VM host scanning configuration. + :paramtype vm_scanners: ~azure.mgmt.security.models.DefenderForContainersAwsOfferingVmScanners + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForContainersAws" + self.kubernetes_service = kubernetes_service + self.kubernetes_data_collection = kubernetes_data_collection + self.cloud_watch_to_kinesis = cloud_watch_to_kinesis + self.kinesis_to_s3 = kinesis_to_s3 + self.enable_audit_logs_auto_provisioning = enable_audit_logs_auto_provisioning + self.enable_defender_agent_auto_provisioning = enable_defender_agent_auto_provisioning + self.enable_policy_agent_auto_provisioning = enable_policy_agent_auto_provisioning + self.kube_audit_retention_time = kube_audit_retention_time + self.data_collection_external_id = data_collection_external_id + self.mdc_containers_image_assessment = mdc_containers_image_assessment + self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s + self.vm_scanners = vm_scanners + + +class DefenderForContainersAwsOfferingCloudWatchToKinesis(_serialization.Model): # pylint: disable=name-too-long + """The cloudwatch to kinesis connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into + Kinesis. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into + Kinesis. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingKinesisToS3(_serialization.Model): # pylint: disable=name-too-long + """The kinesis to s3 connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingKubernetesDataCollection(_serialization.Model): # pylint: disable=name-too-long + """The kubernetes data collection connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingKubernetesService(_serialization.Model): # pylint: disable=name-too-long + """The kubernetes service connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning + resources. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning + resources. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S( + _serialization.Model +): # pylint: disable=name-too-long + """The Microsoft Defender container agentless discovery K8s configuration. + + :ivar enabled: Is Microsoft Defender container agentless discovery K8s enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender container agentless discovery K8s enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingMdcContainersImageAssessment( + _serialization.Model +): # pylint: disable=name-too-long + """The Microsoft Defender container image assessment configuration. + + :ivar enabled: Is Microsoft Defender container image assessment enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender container image assessment enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingVmScanners(VmScannersAws): # pylint: disable=name-too-long + """The Microsoft Defender for Container K8s VM host scanning configuration. + + :ivar enabled: Is VM scanning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for VM scanning. + :vartype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + +class DefenderForContainersDockerHubOffering(CloudOffering): + """The Defender for containers Docker Hub offering configurations. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForContainersDockerHub" + + +class DefenderForContainersGcpOffering(CloudOffering): + """The containers GCP offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar native_cloud_connection: The native cloud connection configuration. + :vartype native_cloud_connection: + ~azure.mgmt.security.models.DefenderForContainersGcpOfferingNativeCloudConnection + :ivar data_pipeline_native_cloud_connection: The native cloud connection configuration. + :vartype data_pipeline_native_cloud_connection: + ~azure.mgmt.security.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection + :ivar enable_audit_logs_auto_provisioning: Is audit logs data collection enabled. + :vartype enable_audit_logs_auto_provisioning: bool + :ivar enable_defender_agent_auto_provisioning: Is Microsoft Defender for Cloud Kubernetes agent + auto provisioning enabled. + :vartype enable_defender_agent_auto_provisioning: bool + :ivar enable_policy_agent_auto_provisioning: Is Policy Kubernetes agent auto provisioning + enabled. + :vartype enable_policy_agent_auto_provisioning: bool + :ivar mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :vartype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderForContainersGcpOfferingMdcContainersImageAssessment + :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless + discovery configuration. + :vartype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S + :ivar vm_scanners: The Microsoft Defender for Container K8s VM host scanning configuration. + :vartype vm_scanners: ~azure.mgmt.security.models.DefenderForContainersGcpOfferingVmScanners + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "native_cloud_connection": { + "key": "nativeCloudConnection", + "type": "DefenderForContainersGcpOfferingNativeCloudConnection", + }, + "data_pipeline_native_cloud_connection": { + "key": "dataPipelineNativeCloudConnection", + "type": "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", + }, + "enable_audit_logs_auto_provisioning": {"key": "enableAuditLogsAutoProvisioning", "type": "bool"}, + "enable_defender_agent_auto_provisioning": {"key": "enableDefenderAgentAutoProvisioning", "type": "bool"}, + "enable_policy_agent_auto_provisioning": {"key": "enablePolicyAgentAutoProvisioning", "type": "bool"}, + "mdc_containers_image_assessment": { + "key": "mdcContainersImageAssessment", + "type": "DefenderForContainersGcpOfferingMdcContainersImageAssessment", + }, + "mdc_containers_agentless_discovery_k8_s": { + "key": "mdcContainersAgentlessDiscoveryK8s", + "type": "DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S", + }, + "vm_scanners": {"key": "vmScanners", "type": "DefenderForContainersGcpOfferingVmScanners"}, + } + + def __init__( + self, + *, + native_cloud_connection: Optional["_models.DefenderForContainersGcpOfferingNativeCloudConnection"] = None, + data_pipeline_native_cloud_connection: Optional[ + "_models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection" + ] = None, + enable_audit_logs_auto_provisioning: Optional[bool] = None, + enable_defender_agent_auto_provisioning: Optional[bool] = None, + enable_policy_agent_auto_provisioning: Optional[bool] = None, + mdc_containers_image_assessment: Optional[ + "_models.DefenderForContainersGcpOfferingMdcContainersImageAssessment" + ] = None, + mdc_containers_agentless_discovery_k8_s: Optional[ + "_models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S" + ] = None, + vm_scanners: Optional["_models.DefenderForContainersGcpOfferingVmScanners"] = None, + **kwargs: Any + ) -> None: + """ + :keyword native_cloud_connection: The native cloud connection configuration. + :paramtype native_cloud_connection: + ~azure.mgmt.security.models.DefenderForContainersGcpOfferingNativeCloudConnection + :keyword data_pipeline_native_cloud_connection: The native cloud connection configuration. + :paramtype data_pipeline_native_cloud_connection: + ~azure.mgmt.security.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection + :keyword enable_audit_logs_auto_provisioning: Is audit logs data collection enabled. + :paramtype enable_audit_logs_auto_provisioning: bool + :keyword enable_defender_agent_auto_provisioning: Is Microsoft Defender for Cloud Kubernetes + agent auto provisioning enabled. + :paramtype enable_defender_agent_auto_provisioning: bool + :keyword enable_policy_agent_auto_provisioning: Is Policy Kubernetes agent auto provisioning + enabled. + :paramtype enable_policy_agent_auto_provisioning: bool + :keyword mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :paramtype mdc_containers_image_assessment: + ~azure.mgmt.security.models.DefenderForContainersGcpOfferingMdcContainersImageAssessment + :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless + discovery configuration. + :paramtype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S + :keyword vm_scanners: The Microsoft Defender for Container K8s VM host scanning configuration. + :paramtype vm_scanners: ~azure.mgmt.security.models.DefenderForContainersGcpOfferingVmScanners + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForContainersGcp" + self.native_cloud_connection = native_cloud_connection + self.data_pipeline_native_cloud_connection = data_pipeline_native_cloud_connection + self.enable_audit_logs_auto_provisioning = enable_audit_logs_auto_provisioning + self.enable_defender_agent_auto_provisioning = enable_defender_agent_auto_provisioning + self.enable_policy_agent_auto_provisioning = enable_policy_agent_auto_provisioning + self.mdc_containers_image_assessment = mdc_containers_image_assessment + self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s + self.vm_scanners = vm_scanners + + +class DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection( + _serialization.Model +): # pylint: disable=name-too-long + """The native cloud connection configuration. + + :ivar service_account_email_address: The data collection service account email address in GCP + for this offering. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The data collection GCP workload identity provider id for + this offering. + :vartype workload_identity_provider_id: str + """ + + _attribute_map = { + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_account_email_address: The data collection service account email address in + GCP for this offering. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The data collection GCP workload identity provider id + for this offering. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S( + _serialization.Model +): # pylint: disable=name-too-long + """The Microsoft Defender Container agentless discovery configuration. + + :ivar enabled: Is Microsoft Defender container agentless discovery enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender container agentless discovery enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderForContainersGcpOfferingMdcContainersImageAssessment( + _serialization.Model +): # pylint: disable=name-too-long + """The Microsoft Defender Container image assessment configuration. + + :ivar enabled: Is Microsoft Defender container image assessment enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender container image assessment enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderForContainersGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long + """The native cloud connection configuration. + + :ivar service_account_email_address: The service account email address in GCP for this + offering. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. + :vartype workload_identity_provider_id: str + """ + + _attribute_map = { + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_account_email_address: The service account email address in GCP for this + offering. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The GCP workload identity provider id for this + offering. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class DefenderForContainersGcpOfferingVmScanners(VmScannersGcp): # pylint: disable=name-too-long + """The Microsoft Defender for Container K8s VM host scanning configuration. + + :ivar enabled: Is VM scanning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for VM scanning. + :vartype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + """ + + +class DefenderForContainersJFrogOffering(CloudOffering): + """The Defender for Containers for JFrog Artifactory offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForContainersJFrog" + + +class DefenderForDatabasesGcpOffering(CloudOffering): + """The Defender for Databases GCP offering configurations. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning + :ivar defender_for_databases_arc_auto_provisioning: The native cloud connection configuration. + :vartype defender_for_databases_arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioning", + }, + "defender_for_databases_arc_auto_provisioning": { + "key": "defenderForDatabasesArcAutoProvisioning", + "type": "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", + }, + } + + def __init__( + self, + *, + arc_auto_provisioning: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioning"] = None, + defender_for_databases_arc_auto_provisioning: Optional[ + "_models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning + :keyword defender_for_databases_arc_auto_provisioning: The native cloud connection + configuration. + :paramtype defender_for_databases_arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForDatabasesGcp" + self.arc_auto_provisioning = arc_auto_provisioning + self.defender_for_databases_arc_auto_provisioning = defender_for_databases_arc_auto_provisioning + + +class DefenderForDatabasesGcpOfferingArcAutoProvisioning(ArcAutoProvisioningGcp): # pylint: disable=name-too-long + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for servers Arc auto provisioning for a given environment. + :vartype configuration: ~azure.mgmt.security.models.ArcAutoProvisioningConfiguration + """ + + +class DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning( + _serialization.Model +): # pylint: disable=name-too-long + """The native cloud connection configuration. + + :ivar service_account_email_address: The service account email address in GCP for this + offering. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. + :vartype workload_identity_provider_id: str + """ + + _attribute_map = { + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_account_email_address: The service account email address in GCP for this + offering. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The GCP workload identity provider id for this + offering. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class DefenderForServersAwsOffering(CloudOffering): + """The Defender for Servers AWS offering. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar defender_for_servers: The Defender for servers connection configuration. + :vartype defender_for_servers: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingDefenderForServers + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingArcAutoProvisioning + :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :vartype va_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingVaAutoProvisioning + :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :vartype mde_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingMdeAutoProvisioning + :ivar sub_plan: configuration for the servers offering subPlan. + :vartype sub_plan: ~azure.mgmt.security.models.DefenderForServersAwsOfferingSubPlan + :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :vartype vm_scanners: ~azure.mgmt.security.models.DefenderForServersAwsOfferingVmScanners + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "defender_for_servers": { + "key": "defenderForServers", + "type": "DefenderForServersAwsOfferingDefenderForServers", + }, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderForServersAwsOfferingArcAutoProvisioning", + }, + "va_auto_provisioning": { + "key": "vaAutoProvisioning", + "type": "DefenderForServersAwsOfferingVaAutoProvisioning", + }, + "mde_auto_provisioning": { + "key": "mdeAutoProvisioning", + "type": "DefenderForServersAwsOfferingMdeAutoProvisioning", + }, + "sub_plan": {"key": "subPlan", "type": "DefenderForServersAwsOfferingSubPlan"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersAwsOfferingVmScanners"}, + } + + def __init__( + self, + *, + defender_for_servers: Optional["_models.DefenderForServersAwsOfferingDefenderForServers"] = None, + arc_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioning"] = None, + va_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioning"] = None, + mde_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingMdeAutoProvisioning"] = None, + sub_plan: Optional["_models.DefenderForServersAwsOfferingSubPlan"] = None, + vm_scanners: Optional["_models.DefenderForServersAwsOfferingVmScanners"] = None, + **kwargs: Any + ) -> None: + """ + :keyword defender_for_servers: The Defender for servers connection configuration. + :paramtype defender_for_servers: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingDefenderForServers + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingArcAutoProvisioning + :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :paramtype va_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingVaAutoProvisioning + :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :paramtype mde_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingMdeAutoProvisioning + :keyword sub_plan: configuration for the servers offering subPlan. + :paramtype sub_plan: ~azure.mgmt.security.models.DefenderForServersAwsOfferingSubPlan + :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :paramtype vm_scanners: ~azure.mgmt.security.models.DefenderForServersAwsOfferingVmScanners + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForServersAws" + self.defender_for_servers = defender_for_servers + self.arc_auto_provisioning = arc_auto_provisioning + self.va_auto_provisioning = va_auto_provisioning + self.mde_auto_provisioning = mde_auto_provisioning + self.sub_plan = sub_plan + self.vm_scanners = vm_scanners + + +class DefenderForServersAwsOfferingArcAutoProvisioning(ArcAutoProvisioningAws): # pylint: disable=name-too-long + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for servers Arc auto provisioning for a given environment. + :vartype configuration: ~azure.mgmt.security.models.ArcAutoProvisioningConfiguration + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + +class DefenderForServersAwsOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long + """The Defender for servers connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForServersAwsOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long + """The Microsoft Defender for Endpoint autoprovisioning configuration. + + :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :vartype configuration: JSON + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "object"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :paramtype configuration: JSON + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersAwsOfferingSubPlan(_serialization.Model): + """configuration for the servers offering subPlan. + + :ivar type: The available sub plans. Known values are: "P1" and "P2". + :vartype type: str or ~azure.mgmt.security.models.SubPlan + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The available sub plans. Known values are: "P1" and "P2". + :paramtype type: str or ~azure.mgmt.security.models.SubPlan + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersAwsOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long + """The Vulnerability Assessment autoprovisioning configuration. + + :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. + :vartype configuration: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": { + "key": "configuration", + "type": "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. + :paramtype configuration: + ~azure.mgmt.security.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersAwsOfferingVaAutoProvisioningConfiguration( + _serialization.Model +): # pylint: disable=name-too-long + """configuration for Vulnerability Assessment autoprovisioning. + + :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :vartype type: str or ~azure.mgmt.security.models.Type + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :paramtype type: str or ~azure.mgmt.security.models.Type + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersAwsOfferingVmScanners(VmScannersAws): + """The Microsoft Defender for Server VM scanning configuration. + + :ivar enabled: Is VM scanning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for VM scanning. + :vartype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + +class DefenderForServersGcpOffering(CloudOffering): + """The Defender for Servers GCP offering configurations. + + 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 offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "CspmMonitorGcp", "CspmMonitorGithub", "CspmMonitorAzureDevOps", + "DefenderForServersGcp", "DefenderForContainersGcp", "DefenderForDatabasesGcp", + "DefenderCspmAws", "DefenderCspmGcp", "CspmMonitorGitLab", "CspmMonitorDockerHub", + "DefenderForContainersDockerHub", "DefenderCspmDockerHub", "CspmMonitorJFrog", + "DefenderForContainersJFrog", and "DefenderCspmJFrog". + :vartype offering_type: str or ~azure.mgmt.security.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar defender_for_servers: The Defender for servers connection configuration. + :vartype defender_for_servers: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingDefenderForServers + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingArcAutoProvisioning + :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :vartype va_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingVaAutoProvisioning + :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :vartype mde_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingMdeAutoProvisioning + :ivar sub_plan: configuration for the servers offering subPlan. + :vartype sub_plan: ~azure.mgmt.security.models.DefenderForServersGcpOfferingSubPlan + :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :vartype vm_scanners: ~azure.mgmt.security.models.DefenderForServersGcpOfferingVmScanners + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "defender_for_servers": { + "key": "defenderForServers", + "type": "DefenderForServersGcpOfferingDefenderForServers", + }, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderForServersGcpOfferingArcAutoProvisioning", + }, + "va_auto_provisioning": { + "key": "vaAutoProvisioning", + "type": "DefenderForServersGcpOfferingVaAutoProvisioning", + }, + "mde_auto_provisioning": { + "key": "mdeAutoProvisioning", + "type": "DefenderForServersGcpOfferingMdeAutoProvisioning", + }, + "sub_plan": {"key": "subPlan", "type": "DefenderForServersGcpOfferingSubPlan"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersGcpOfferingVmScanners"}, + } + + def __init__( + self, + *, + defender_for_servers: Optional["_models.DefenderForServersGcpOfferingDefenderForServers"] = None, + arc_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioning"] = None, + va_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioning"] = None, + mde_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingMdeAutoProvisioning"] = None, + sub_plan: Optional["_models.DefenderForServersGcpOfferingSubPlan"] = None, + vm_scanners: Optional["_models.DefenderForServersGcpOfferingVmScanners"] = None, + **kwargs: Any + ) -> None: + """ + :keyword defender_for_servers: The Defender for servers connection configuration. + :paramtype defender_for_servers: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingDefenderForServers + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingArcAutoProvisioning + :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :paramtype va_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingVaAutoProvisioning + :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :paramtype mde_auto_provisioning: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingMdeAutoProvisioning + :keyword sub_plan: configuration for the servers offering subPlan. + :paramtype sub_plan: ~azure.mgmt.security.models.DefenderForServersGcpOfferingSubPlan + :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :paramtype vm_scanners: ~azure.mgmt.security.models.DefenderForServersGcpOfferingVmScanners + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForServersGcp" + self.defender_for_servers = defender_for_servers + self.arc_auto_provisioning = arc_auto_provisioning + self.va_auto_provisioning = va_auto_provisioning + self.mde_auto_provisioning = mde_auto_provisioning + self.sub_plan = sub_plan + self.vm_scanners = vm_scanners + + +class DefenderForServersGcpOfferingArcAutoProvisioning(ArcAutoProvisioningGcp): # pylint: disable=name-too-long + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for servers Arc auto provisioning for a given environment. + :vartype configuration: ~azure.mgmt.security.models.ArcAutoProvisioningConfiguration + """ + + +class DefenderForServersGcpOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long + """The Defender for servers connection configuration. + + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderForServersGcpOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long + """The Microsoft Defender for Endpoint autoprovisioning configuration. + + :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :vartype configuration: JSON + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "object"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :paramtype configuration: JSON + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersGcpOfferingSubPlan(_serialization.Model): + """configuration for the servers offering subPlan. + + :ivar type: The available sub plans. Known values are: "P1" and "P2". + :vartype type: str or ~azure.mgmt.security.models.SubPlan + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The available sub plans. Known values are: "P1" and "P2". + :paramtype type: str or ~azure.mgmt.security.models.SubPlan + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersGcpOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long + """The Vulnerability Assessment autoprovisioning configuration. + + :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. + :vartype configuration: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": { + "key": "configuration", + "type": "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. + :paramtype configuration: + ~azure.mgmt.security.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersGcpOfferingVaAutoProvisioningConfiguration( + _serialization.Model +): # pylint: disable=name-too-long + """configuration for Vulnerability Assessment autoprovisioning. + + :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :vartype type: str or ~azure.mgmt.security.models.Type + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :paramtype type: str or ~azure.mgmt.security.models.Type + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersGcpOfferingVmScanners(VmScannersGcp): + """The Microsoft Defender for Server VM scanning configuration. + + :ivar enabled: Is VM scanning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for VM scanning. + :vartype configuration: ~azure.mgmt.security.models.VmScannersBaseConfiguration + """ + + +class DefenderForStorageSetting(Resource): + """The Defender for Storage resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: Defender for Storage resource properties. + :vartype properties: ~azure.mgmt.security.models.DefenderForStorageSettingProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "DefenderForStorageSettingProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.DefenderForStorageSettingProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Defender for Storage resource properties. + :paramtype properties: ~azure.mgmt.security.models.DefenderForStorageSettingProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class DefenderForStorageSettingProperties(_serialization.Model): + """Defender for Storage resource properties. + + :ivar is_enabled: Indicates whether Defender for Storage is enabled on this storage account. + :vartype is_enabled: bool + :ivar malware_scanning: Properties of Malware Scanning. + :vartype malware_scanning: ~azure.mgmt.security.models.MalwareScanningProperties + :ivar sensitive_data_discovery: Properties of Sensitive Data Discovery. + :vartype sensitive_data_discovery: ~azure.mgmt.security.models.SensitiveDataDiscoveryProperties + :ivar override_subscription_level_settings: Indicates whether the settings defined for this + storage account should override the settings defined for the subscription. + :vartype override_subscription_level_settings: bool + """ + + _attribute_map = { + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "malware_scanning": {"key": "malwareScanning", "type": "MalwareScanningProperties"}, + "sensitive_data_discovery": {"key": "sensitiveDataDiscovery", "type": "SensitiveDataDiscoveryProperties"}, + "override_subscription_level_settings": {"key": "overrideSubscriptionLevelSettings", "type": "bool"}, + } + + def __init__( + self, + *, + is_enabled: Optional[bool] = None, + malware_scanning: Optional["_models.MalwareScanningProperties"] = None, + sensitive_data_discovery: Optional["_models.SensitiveDataDiscoveryProperties"] = None, + override_subscription_level_settings: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Indicates whether Defender for Storage is enabled on this storage account. + :paramtype is_enabled: bool + :keyword malware_scanning: Properties of Malware Scanning. + :paramtype malware_scanning: ~azure.mgmt.security.models.MalwareScanningProperties + :keyword sensitive_data_discovery: Properties of Sensitive Data Discovery. + :paramtype sensitive_data_discovery: + ~azure.mgmt.security.models.SensitiveDataDiscoveryProperties + :keyword override_subscription_level_settings: Indicates whether the settings defined for this + storage account should override the settings defined for the subscription. + :paramtype override_subscription_level_settings: bool + """ + super().__init__(**kwargs) + self.is_enabled = is_enabled + self.malware_scanning = malware_scanning + self.sensitive_data_discovery = sensitive_data_discovery + self.override_subscription_level_settings = override_subscription_level_settings + + +class DenylistCustomAlertRule(ListCustomAlertRule): + """A custom alert rule that checks if a value (depends on the custom alert type) is denied. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and + "String". + :vartype value_type: str or ~azure.mgmt.security.models.ValueType + :ivar denylist_values: The values to deny. The format of the values depends on the rule type. + Required. + :vartype denylist_values: list[str] + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "value_type": {"readonly": True}, + "denylist_values": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "value_type": {"key": "valueType", "type": "str"}, + "denylist_values": {"key": "denylistValues", "type": "[str]"}, + } + + def __init__(self, *, is_enabled: bool, denylist_values: List[str], **kwargs: Any) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword denylist_values: The values to deny. The format of the values depends on the rule + type. Required. + :paramtype denylist_values: list[str] + """ + super().__init__(is_enabled=is_enabled, **kwargs) + self.rule_type: str = "DenylistCustomAlertRule" + self.denylist_values = denylist_values + + +class DeviceSecurityGroup(Resource): + """The device security group resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar threshold_rules: The list of custom alert threshold rules. + :vartype threshold_rules: list[~azure.mgmt.security.models.ThresholdCustomAlertRule] + :ivar time_window_rules: The list of custom alert time-window rules. + :vartype time_window_rules: list[~azure.mgmt.security.models.TimeWindowCustomAlertRule] + :ivar allowlist_rules: The allow-list custom alert rules. + :vartype allowlist_rules: list[~azure.mgmt.security.models.AllowlistCustomAlertRule] + :ivar denylist_rules: The deny-list custom alert rules. + :vartype denylist_rules: list[~azure.mgmt.security.models.DenylistCustomAlertRule] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "threshold_rules": {"key": "properties.thresholdRules", "type": "[ThresholdCustomAlertRule]"}, + "time_window_rules": {"key": "properties.timeWindowRules", "type": "[TimeWindowCustomAlertRule]"}, + "allowlist_rules": {"key": "properties.allowlistRules", "type": "[AllowlistCustomAlertRule]"}, + "denylist_rules": {"key": "properties.denylistRules", "type": "[DenylistCustomAlertRule]"}, + } + + def __init__( + self, + *, + threshold_rules: Optional[List["_models.ThresholdCustomAlertRule"]] = None, + time_window_rules: Optional[List["_models.TimeWindowCustomAlertRule"]] = None, + allowlist_rules: Optional[List["_models.AllowlistCustomAlertRule"]] = None, + denylist_rules: Optional[List["_models.DenylistCustomAlertRule"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword threshold_rules: The list of custom alert threshold rules. + :paramtype threshold_rules: list[~azure.mgmt.security.models.ThresholdCustomAlertRule] + :keyword time_window_rules: The list of custom alert time-window rules. + :paramtype time_window_rules: list[~azure.mgmt.security.models.TimeWindowCustomAlertRule] + :keyword allowlist_rules: The allow-list custom alert rules. + :paramtype allowlist_rules: list[~azure.mgmt.security.models.AllowlistCustomAlertRule] + :keyword denylist_rules: The deny-list custom alert rules. + :paramtype denylist_rules: list[~azure.mgmt.security.models.DenylistCustomAlertRule] + """ + super().__init__(**kwargs) + self.threshold_rules = threshold_rules + self.time_window_rules = time_window_rules + self.allowlist_rules = allowlist_rules + self.denylist_rules = denylist_rules + + +class DeviceSecurityGroupList(_serialization.Model): + """List of device security groups. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of device security group objects. + :vartype value: list[~azure.mgmt.security.models.DeviceSecurityGroup] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[DeviceSecurityGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.DeviceSecurityGroup"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of device security group objects. + :paramtype value: list[~azure.mgmt.security.models.DeviceSecurityGroup] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class DevOpsCapability(_serialization.Model): + """Details about DevOps capability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Gets the name of the DevOps capability. + :vartype name: str + :ivar value: Gets the value of the DevOps capability. + :vartype value: str + """ + + _validation = { + "name": {"readonly": True}, + "value": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.value: Optional[str] = None + + +class DevOpsConfiguration(ProxyResource): + """DevOps Configuration 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. 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: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar properties: DevOps Configuration properties. + :vartype properties: ~azure.mgmt.security.models.DevOpsConfigurationProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "DevOpsConfigurationProperties"}, + } + + def __init__(self, *, properties: Optional["_models.DevOpsConfigurationProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: DevOps Configuration properties. + :paramtype properties: ~azure.mgmt.security.models.DevOpsConfigurationProperties + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.properties = properties + + +class DevOpsConfigurationListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.models.DevOpsConfiguration] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[DevOpsConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.DevOpsConfiguration"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.models.DevOpsConfiguration] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DevOpsConfigurationProperties(_serialization.Model): + """DevOps Configuration properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets the resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets the time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or ~azure.mgmt.security.models.DevOpsProvisioningState + :ivar authorization: Authorization payload. + :vartype authorization: ~azure.mgmt.security.models.Authorization + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :ivar top_level_inventory_list: List of top-level inventory to select when AutoDiscovery is + disabled. + This field is ignored when AutoDiscovery is enabled. + :vartype top_level_inventory_list: list[str] + :ivar capabilities: List of capabilities assigned to the DevOps configuration during the + discovery process. + :vartype capabilities: list[~azure.mgmt.security.models.DevOpsCapability] + :ivar agentless_configuration: Details about Agentless configuration. + :vartype agentless_configuration: ~azure.mgmt.security.models.AgentlessConfiguration + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "capabilities": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "authorization": {"key": "authorization", "type": "Authorization"}, + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "top_level_inventory_list": {"key": "topLevelInventoryList", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[DevOpsCapability]"}, + "agentless_configuration": {"key": "agentlessConfiguration", "type": "AgentlessConfiguration"}, + } + + def __init__( + self, + *, + authorization: Optional["_models.Authorization"] = None, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + top_level_inventory_list: Optional[List[str]] = None, + agentless_configuration: Optional["_models.AgentlessConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword authorization: Authorization payload. + :paramtype authorization: ~azure.mgmt.security.models.Authorization + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :keyword top_level_inventory_list: List of top-level inventory to select when AutoDiscovery is + disabled. + This field is ignored when AutoDiscovery is enabled. + :paramtype top_level_inventory_list: list[str] + :keyword agentless_configuration: Details about Agentless configuration. + :paramtype agentless_configuration: ~azure.mgmt.security.models.AgentlessConfiguration + """ + super().__init__(**kwargs) + self.provisioning_status_message: Optional[str] = None + self.provisioning_status_update_time_utc: Optional[datetime.datetime] = None + self.provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None + self.authorization = authorization + self.auto_discovery = auto_discovery + self.top_level_inventory_list = top_level_inventory_list + self.capabilities: Optional[List["_models.DevOpsCapability"]] = None + self.agentless_configuration = agentless_configuration + + +class DirectMethodInvokesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of direct method invokes is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "DirectMethodInvokesNotInAllowedRange" + + +class DiscoveredSecuritySolution(Resource, Location): + """DiscoveredSecuritySolution. + + 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 location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar security_family: The security family of the discovered solution. Required. Known values + are: "Waf", "Ngfw", "SaasWaf", and "Va". + :vartype security_family: str or ~azure.mgmt.security.models.SecurityFamily + :ivar offer: The security solutions' image offer. Required. + :vartype offer: str + :ivar publisher: The security solutions' image publisher. Required. + :vartype publisher: str + :ivar sku: The security solutions' image sku. Required. + :vartype sku: str + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "security_family": {"required": True}, + "offer": {"required": True}, + "publisher": {"required": True}, + "sku": {"required": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "security_family": {"key": "properties.securityFamily", "type": "str"}, + "offer": {"key": "properties.offer", "type": "str"}, + "publisher": {"key": "properties.publisher", "type": "str"}, + "sku": {"key": "properties.sku", "type": "str"}, + } + + def __init__( + self, + *, + security_family: Union[str, "_models.SecurityFamily"], + offer: str, + publisher: str, + sku: str, + **kwargs: Any + ) -> None: + """ + :keyword security_family: The security family of the discovered solution. Required. Known + values are: "Waf", "Ngfw", "SaasWaf", and "Va". + :paramtype security_family: str or ~azure.mgmt.security.models.SecurityFamily + :keyword offer: The security solutions' image offer. Required. + :paramtype offer: str + :keyword publisher: The security solutions' image publisher. Required. + :paramtype publisher: str + :keyword sku: The security solutions' image sku. Required. + :paramtype sku: str + """ + super().__init__(**kwargs) + self.location: Optional[str] = None + self.security_family = security_family + self.offer = offer + self.publisher = publisher + self.sku = sku + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class DiscoveredSecuritySolutionList(_serialization.Model): + """DiscoveredSecuritySolutionList. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.DiscoveredSecuritySolution] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[DiscoveredSecuritySolution]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.DiscoveredSecuritySolution"]] = None, **kwargs: Any) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.security.models.DiscoveredSecuritySolution] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class DockerHubEnvironmentData(EnvironmentData): + """The Docker Hub connector environment data. + + All required parameters must be populated in order to send to server. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", "GitlabScope", + "DockerHubOrganization", and "JFrogArtifactory". + :vartype environment_type: str or ~azure.mgmt.security.models.EnvironmentType + :ivar authentication: The Docker Hub organization authentication details. + :vartype authentication: ~azure.mgmt.security.models.Authentication + :ivar scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :vartype scan_interval: int + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, + "scan_interval": {"key": "scanInterval", "type": "int"}, + } + + def __init__( + self, + *, + authentication: Optional["_models.Authentication"] = None, + scan_interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword authentication: The Docker Hub organization authentication details. + :paramtype authentication: ~azure.mgmt.security.models.Authentication + :keyword scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :paramtype scan_interval: int + """ + super().__init__(**kwargs) + self.environment_type: str = "DockerHubOrganization" + self.authentication = authentication + self.scan_interval = scan_interval + + +class EdgeIdentifiers(_serialization.Model): + """Represents an edge in the path. + + All required parameters must be populated in order to send to server. + + :ivar source: The source node of the edge. Required. + :vartype source: str + :ivar target: The target node of the edge. Required. + :vartype target: str + :ivar type: The type of the edge. Required. + :vartype type: str + """ + + _validation = { + "source": {"required": True}, + "target": {"required": True}, + "type": {"required": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, source: str, target: str, type: str, **kwargs: Any) -> None: + """ + :keyword source: The source node of the edge. Required. + :paramtype source: str + :keyword target: The target node of the edge. Required. + :paramtype target: str + :keyword type: The type of the edge. Required. + :paramtype type: str + """ + super().__init__(**kwargs) + self.source = source + self.target = target + self.type = type + + +class EnvironmentDetails(_serialization.Model): + """The environment details of the resource. + + :ivar native_resource_id: The native resource id of the resource (in case of Azure - the + resource Id, in case of MC - the native resource id). + :vartype native_resource_id: str + :ivar environment_hierarchy_id: The hierarchy id of the connector (in case of Azure - the + subscription Id, in case of MC - the hierarchyId id). + :vartype environment_hierarchy_id: str + :ivar organizational_hierarchy_id: The organizational hierarchy id of the connector (in case of + Azure - the subscription Id, in case of MC - the organizational hierarchyId id). + :vartype organizational_hierarchy_id: str + :ivar subscription_id: The subscription Id. + :vartype subscription_id: str + :ivar tenant_id: The tenant Id. + :vartype tenant_id: str + """ + + _attribute_map = { + "native_resource_id": {"key": "nativeResourceId", "type": "str"}, + "environment_hierarchy_id": {"key": "environmentHierarchyId", "type": "str"}, + "organizational_hierarchy_id": {"key": "organizationalHierarchyId", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__( + self, + *, + native_resource_id: Optional[str] = None, + environment_hierarchy_id: Optional[str] = None, + organizational_hierarchy_id: Optional[str] = None, + subscription_id: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword native_resource_id: The native resource id of the resource (in case of Azure - the + resource Id, in case of MC - the native resource id). + :paramtype native_resource_id: str + :keyword environment_hierarchy_id: The hierarchy id of the connector (in case of Azure - the + subscription Id, in case of MC - the hierarchyId id). + :paramtype environment_hierarchy_id: str + :keyword organizational_hierarchy_id: The organizational hierarchy id of the connector (in case + of Azure - the subscription Id, in case of MC - the organizational hierarchyId id). + :paramtype organizational_hierarchy_id: str + :keyword subscription_id: The subscription Id. + :paramtype subscription_id: str + :keyword tenant_id: The tenant Id. + :paramtype tenant_id: str + """ + super().__init__(**kwargs) + self.native_resource_id = native_resource_id + self.environment_hierarchy_id = environment_hierarchy_id + self.organizational_hierarchy_id = organizational_hierarchy_id + self.subscription_id = subscription_id + self.tenant_id = tenant_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.security.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.security.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 ErrorDetailAutoGenerated(_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.security.models.ErrorDetailAutoGenerated] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.security.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": "[ErrorDetailAutoGenerated]"}, + "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.ErrorDetailAutoGenerated"]] = None + self.additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = None + + +class ErrorDetailAutoGenerated2(_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.security.models.ErrorDetailAutoGenerated2] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.security.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": "[ErrorDetailAutoGenerated2]"}, + "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.ErrorDetailAutoGenerated2"]] = 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.security.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.security.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseAutoGenerated(_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.security.models.ErrorDetailAutoGenerated + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetailAutoGenerated"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetailAutoGenerated"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.security.models.ErrorDetailAutoGenerated + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseAutoGenerated2(_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.security.models.ErrorDetailAutoGenerated2 + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetailAutoGenerated2"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetailAutoGenerated2"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.security.models.ErrorDetailAutoGenerated2 + """ + super().__init__(**kwargs) + self.error = error + + +class ExecuteGovernanceRuleParams(_serialization.Model): + """Governance rule execution parameters. + + :ivar override: Describe if governance rule should be override. + :vartype override: bool + """ + + _attribute_map = { + "override": {"key": "override", "type": "bool"}, + } + + def __init__(self, *, override: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword override: Describe if governance rule should be override. + :paramtype override: bool + """ + super().__init__(**kwargs) + self.override = override + + +class Extension(_serialization.Model): + """A plan's extension properties. + + 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 name: The extension name. Supported values are: :code:`
`\\ :code:`
`\\ + **AgentlessDiscoveryForKubernetes** - Provides zero footprint, API-based discovery of + Kubernetes clusters, their configurations and deployments. The collected data is used to create + a contextualized security graph for Kubernetes clusters, provide risk hunting capabilities, and + visualize risks and threats to Kubernetes environments and workloads.\\ :code:`
`Available + for CloudPosture plan and Containers plan.\\ :code:`
`\\ :code:`
`\\ + **OnUploadMalwareScanning** - Limits the GB to be scanned per month for each storage account + within the subscription. Once this limit reached on a given storage account, Blobs won't be + scanned during current calendar month.\\ :code:`
`Available for StorageAccounts plan + (DefenderForStorageV2 sub plans).\\ :code:`
`\\ :code:`
`\\ **SensitiveDataDiscovery** - + Sensitive data discovery identifies Blob storage container with sensitive data such as + credentials, credit cards, and more, to help prioritize and investigate security events.\\ + :code:`
`Available for StorageAccounts plan (DefenderForStorageV2 sub plan) and CloudPosture + plan.\\ :code:`
`\\ :code:`
`\\ **ContainerRegistriesVulnerabilityAssessments** - + Provides vulnerability management for images stored in your container registries.\\ + :code:`
`Available for CloudPosture plan and Containers plan.\\ :code:`
`\\ + :code:`
`\\ **MdeDesignatedSubscription** - Direct onboarding is a seamless integration + between Defender for Endpoint and Defender for Cloud that doesn’t require extra software + deployment on your servers. The onboarded resources will be presented under a designated Azure + Subscription you configure\\ :code:`
`Available for VirtualMachines plan (P1 and P2 sub + plans).\\ :code:`
`\\ :code:`
`\\ **AgentlessVmScanning** - Scans your machines for + installed software, vulnerabilities, malware and secret scanning without relying on agents or + impacting machine performance. Learn more here + https://learn.microsoft.com/en-us/azure/defender-for-cloud/concept-agentless-data-collection.\\ + :code:`
`Available for CloudPosture plan, VirtualMachines plan (P2 sub plan) and Containers + plan.\\ :code:`
`\\ :code:`
`\\ **EntraPermissionsManagement** - Permissions Management + provides Cloud Infrastructure Entitlement Management (CIEM) capabilities that helps + organizations to manage and control user access and entitlements in their cloud infrastructure + - important attack vector for cloud environments.\\ :code:`
`Permissions Management analyzes + all permissions and active usage, and suggests recommendations to reduce permissions to enforce + the principle of least privilege. Learn more here + https://learn.microsoft.com/en-us/azure/defender-for-cloud/permissions-management.\\ + :code:`
`Available for CloudPosture plan. :code:`
`\\ :code:`
`\\ + **FileIntegrityMonitoring** - File integrity monitoring (FIM), examines operating system + files.\\ :code:`
`Windows registries, Linux system files, in real time, for changes that + might indicate an attack.\\ :code:`
`Available for VirtualMachines plan (P2 sub plan). + :code:`
`\\ :code:`
`\\ **ContainerSensor** - The sensor is based on IG and provides a + rich threat detection suite for Kubernetes clusters, nodes, and workloads, powered by Microsoft + leading threat intelligence, provides mapping to MITRE ATT&CK framework.\\ + :code:`
`Available for Containers plan. :code:`
`\\ :code:`
`\\ **AIPromptEvidence** - + Exposes the prompts passed between the user and the AI model as alert evidence. This helps + classify and triage the alerts with relevant user context. The prompt snippets will include + only segments of the user prompt or model response that were deemed suspicious and relevant for + security classifications. The prompt evidence will be available through Defender portal as part + of each alert.\\ :code:`
`Available for AI plan. :code:`
`\\ :code:`
`. Required. + :vartype name: str + :ivar is_enabled: Indicates whether the extension is enabled. Required. Known values are: + "True" and "False". + :vartype is_enabled: str or ~azure.mgmt.security.models.IsEnabled + :ivar additional_extension_properties: Property values associated with the extension. + :vartype additional_extension_properties: dict[str, any] + :ivar operation_status: Optional. A status describing the success/failure of the extension's + enablement/disablement operation. + :vartype operation_status: ~azure.mgmt.security.models.OperationStatusAutoGenerated + """ + + _validation = { + "name": {"required": True}, + "is_enabled": {"required": True}, + "operation_status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "str"}, + "additional_extension_properties": {"key": "additionalExtensionProperties", "type": "{object}"}, + "operation_status": {"key": "operationStatus", "type": "OperationStatusAutoGenerated"}, + } + + def __init__( + self, + *, + name: str, + is_enabled: Union[str, "_models.IsEnabled"], + additional_extension_properties: Optional[Dict[str, Any]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The extension name. Supported values are: :code:`
`\\ :code:`
`\\ + **AgentlessDiscoveryForKubernetes** - Provides zero footprint, API-based discovery of + Kubernetes clusters, their configurations and deployments. The collected data is used to create + a contextualized security graph for Kubernetes clusters, provide risk hunting capabilities, and + visualize risks and threats to Kubernetes environments and workloads.\\ :code:`
`Available + for CloudPosture plan and Containers plan.\\ :code:`
`\\ :code:`
`\\ + **OnUploadMalwareScanning** - Limits the GB to be scanned per month for each storage account + within the subscription. Once this limit reached on a given storage account, Blobs won't be + scanned during current calendar month.\\ :code:`
`Available for StorageAccounts plan + (DefenderForStorageV2 sub plans).\\ :code:`
`\\ :code:`
`\\ **SensitiveDataDiscovery** - + Sensitive data discovery identifies Blob storage container with sensitive data such as + credentials, credit cards, and more, to help prioritize and investigate security events.\\ + :code:`
`Available for StorageAccounts plan (DefenderForStorageV2 sub plan) and CloudPosture + plan.\\ :code:`
`\\ :code:`
`\\ **ContainerRegistriesVulnerabilityAssessments** - + Provides vulnerability management for images stored in your container registries.\\ + :code:`
`Available for CloudPosture plan and Containers plan.\\ :code:`
`\\ + :code:`
`\\ **MdeDesignatedSubscription** - Direct onboarding is a seamless integration + between Defender for Endpoint and Defender for Cloud that doesn’t require extra software + deployment on your servers. The onboarded resources will be presented under a designated Azure + Subscription you configure\\ :code:`
`Available for VirtualMachines plan (P1 and P2 sub + plans).\\ :code:`
`\\ :code:`
`\\ **AgentlessVmScanning** - Scans your machines for + installed software, vulnerabilities, malware and secret scanning without relying on agents or + impacting machine performance. Learn more here + https://learn.microsoft.com/en-us/azure/defender-for-cloud/concept-agentless-data-collection.\\ + :code:`
`Available for CloudPosture plan, VirtualMachines plan (P2 sub plan) and Containers + plan.\\ :code:`
`\\ :code:`
`\\ **EntraPermissionsManagement** - Permissions Management + provides Cloud Infrastructure Entitlement Management (CIEM) capabilities that helps + organizations to manage and control user access and entitlements in their cloud infrastructure + - important attack vector for cloud environments.\\ :code:`
`Permissions Management analyzes + all permissions and active usage, and suggests recommendations to reduce permissions to enforce + the principle of least privilege. Learn more here + https://learn.microsoft.com/en-us/azure/defender-for-cloud/permissions-management.\\ + :code:`
`Available for CloudPosture plan. :code:`
`\\ :code:`
`\\ + **FileIntegrityMonitoring** - File integrity monitoring (FIM), examines operating system + files.\\ :code:`
`Windows registries, Linux system files, in real time, for changes that + might indicate an attack.\\ :code:`
`Available for VirtualMachines plan (P2 sub plan). + :code:`
`\\ :code:`
`\\ **ContainerSensor** - The sensor is based on IG and provides a + rich threat detection suite for Kubernetes clusters, nodes, and workloads, powered by Microsoft + leading threat intelligence, provides mapping to MITRE ATT&CK framework.\\ + :code:`
`Available for Containers plan. :code:`
`\\ :code:`
`\\ **AIPromptEvidence** - + Exposes the prompts passed between the user and the AI model as alert evidence. This helps + classify and triage the alerts with relevant user context. The prompt snippets will include + only segments of the user prompt or model response that were deemed suspicious and relevant for + security classifications. The prompt evidence will be available through Defender portal as part + of each alert.\\ :code:`
`Available for AI plan. :code:`
`\\ :code:`
`. Required. + :paramtype name: str + :keyword is_enabled: Indicates whether the extension is enabled. Required. Known values are: + "True" and "False". + :paramtype is_enabled: str or ~azure.mgmt.security.models.IsEnabled + :keyword additional_extension_properties: Property values associated with the extension. + :paramtype additional_extension_properties: dict[str, any] + """ + super().__init__(**kwargs) + self.name = name + self.is_enabled = is_enabled + self.additional_extension_properties = additional_extension_properties + self.operation_status: Optional["_models.OperationStatusAutoGenerated"] = None + + +class ExternalSecuritySolutionList(_serialization.Model): + """ExternalSecuritySolutionList. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.ExternalSecuritySolution] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ExternalSecuritySolution]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ExternalSecuritySolution"]] = None, **kwargs: Any) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.security.models.ExternalSecuritySolution] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class FailedLocalLoginsNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of failed local logins is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "FailedLocalLoginsNotInAllowedRange" + + +class FileUploadsNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of file uploads is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "FileUploadsNotInAllowedRange" + + +class GcpCredentialsDetailsProperties(AuthenticationDetailsProperties): + """GCP cloud account connector based service to service credentials, the credentials are composed + of the organization ID and a JSON API key (write only). + + 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 authentication_provisioning_state: State of the multi-cloud connector. Known values are: + "Valid", "Invalid", "Expired", and "IncorrectPolicy". + :vartype authentication_provisioning_state: str or + ~azure.mgmt.security.models.AuthenticationProvisioningState + :ivar granted_permissions: The permissions detected in the cloud account. + :vartype granted_permissions: list[str or ~azure.mgmt.security.models.PermissionProperty] + :ivar authentication_type: Connect to your cloud account, for AWS use either account + credentials or role-based authentication. For GCP use account organization credentials. + Required. Known values are: "awsCreds", "awsAssumeRole", and "gcpCredentials". + :vartype authentication_type: str or ~azure.mgmt.security.models.AuthenticationType + :ivar organization_id: The organization ID of the GCP cloud account. Required. + :vartype organization_id: str + :ivar type: Type field of the API key (write only). Required. + :vartype type: str + :ivar project_id: Project ID field of the API key (write only). Required. + :vartype project_id: str + :ivar private_key_id: Private key ID field of the API key (write only). Required. + :vartype private_key_id: str + :ivar private_key: Private key field of the API key (write only). Required. + :vartype private_key: str + :ivar client_email: Client email field of the API key (write only). Required. + :vartype client_email: str + :ivar client_id: Client ID field of the API key (write only). Required. + :vartype client_id: str + :ivar auth_uri: Auth URI field of the API key (write only). Required. + :vartype auth_uri: str + :ivar token_uri: Token URI field of the API key (write only). Required. + :vartype token_uri: str + :ivar auth_provider_x509_cert_url: Auth provider x509 certificate URL field of the API key + (write only). Required. + :vartype auth_provider_x509_cert_url: str + :ivar client_x509_cert_url: Client x509 certificate URL field of the API key (write only). + Required. + :vartype client_x509_cert_url: str + """ + + _validation = { + "authentication_provisioning_state": {"readonly": True}, + "granted_permissions": {"readonly": True}, + "authentication_type": {"required": True}, + "organization_id": {"required": True}, + "type": {"required": True}, + "project_id": {"required": True}, + "private_key_id": {"required": True}, + "private_key": {"required": True}, + "client_email": {"required": True}, + "client_id": {"required": True}, + "auth_uri": {"required": True}, + "token_uri": {"required": True}, + "auth_provider_x509_cert_url": {"required": True}, + "client_x509_cert_url": {"required": True}, + } + + _attribute_map = { + "authentication_provisioning_state": {"key": "authenticationProvisioningState", "type": "str"}, + "granted_permissions": {"key": "grantedPermissions", "type": "[str]"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "organization_id": {"key": "organizationId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "project_id": {"key": "projectId", "type": "str"}, + "private_key_id": {"key": "privateKeyId", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "client_email": {"key": "clientEmail", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + "auth_uri": {"key": "authUri", "type": "str"}, + "token_uri": {"key": "tokenUri", "type": "str"}, + "auth_provider_x509_cert_url": {"key": "authProviderX509CertUrl", "type": "str"}, + "client_x509_cert_url": {"key": "clientX509CertUrl", "type": "str"}, + } + + def __init__( + self, + *, + organization_id: str, + type: str, + project_id: str, + private_key_id: str, + private_key: str, + client_email: str, + client_id: str, + auth_uri: str, + token_uri: str, + auth_provider_x509_cert_url: str, + client_x509_cert_url: str, + **kwargs: Any + ) -> None: + """ + :keyword organization_id: The organization ID of the GCP cloud account. Required. + :paramtype organization_id: str + :keyword type: Type field of the API key (write only). Required. + :paramtype type: str + :keyword project_id: Project ID field of the API key (write only). Required. + :paramtype project_id: str + :keyword private_key_id: Private key ID field of the API key (write only). Required. + :paramtype private_key_id: str + :keyword private_key: Private key field of the API key (write only). Required. + :paramtype private_key: str + :keyword client_email: Client email field of the API key (write only). Required. + :paramtype client_email: str + :keyword client_id: Client ID field of the API key (write only). Required. + :paramtype client_id: str + :keyword auth_uri: Auth URI field of the API key (write only). Required. + :paramtype auth_uri: str + :keyword token_uri: Token URI field of the API key (write only). Required. + :paramtype token_uri: str + :keyword auth_provider_x509_cert_url: Auth provider x509 certificate URL field of the API key + (write only). Required. + :paramtype auth_provider_x509_cert_url: str + :keyword client_x509_cert_url: Client x509 certificate URL field of the API key (write only). + Required. + :paramtype client_x509_cert_url: str + """ + super().__init__(**kwargs) + self.authentication_type: str = "gcpCredentials" + self.organization_id = organization_id + self.type = type + self.project_id = project_id + self.private_key_id = private_key_id + self.private_key = private_key + self.client_email = client_email + self.client_id = client_id + self.auth_uri = auth_uri + self.token_uri = token_uri + self.auth_provider_x509_cert_url = auth_provider_x509_cert_url + self.client_x509_cert_url = client_x509_cert_url + + +class GcpOrganizationalData(_serialization.Model): + """The gcpOrganization data. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + GcpOrganizationalDataMember, GcpOrganizationalDataOrganization + + All required parameters must be populated in order to send to server. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.models.OrganizationMembershipType + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + } + + _subtype_map = { + "organization_membership_type": { + "Member": "GcpOrganizationalDataMember", + "Organization": "GcpOrganizationalDataOrganization", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.organization_membership_type: Optional[str] = None + + +class GcpOrganizationalDataMember(GcpOrganizationalData): + """The gcpOrganization data for the member account. + + All required parameters must be populated in order to send to server. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.models.OrganizationMembershipType + :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, + this will be the ID of the project's parent. + :vartype parent_hierarchy_id: str + :ivar management_project_number: The GCP management project number from organizational + onboarding. + :vartype management_project_number: str + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, + "management_project_number": {"key": "managementProjectNumber", "type": "str"}, + } + + def __init__( + self, + *, + parent_hierarchy_id: Optional[str] = None, + management_project_number: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword parent_hierarchy_id: If the multi cloud account is not of membership type + organization, this will be the ID of the project's parent. + :paramtype parent_hierarchy_id: str + :keyword management_project_number: The GCP management project number from organizational + onboarding. + :paramtype management_project_number: str + """ + super().__init__(**kwargs) + self.organization_membership_type: str = "Member" + self.parent_hierarchy_id = parent_hierarchy_id + self.management_project_number = management_project_number + + +class GcpOrganizationalDataOrganization(GcpOrganizationalData): + """The gcpOrganization data for the parent account. + + 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 organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.models.OrganizationMembershipType + :ivar excluded_project_numbers: If the multi cloud account is of membership type organization, + list of accounts excluded from offering. + :vartype excluded_project_numbers: list[str] + :ivar service_account_email_address: The service account email address which represents the + organization level permissions container. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The GCP workload identity provider id which represents the + permissions required to auto provision security connectors. + :vartype workload_identity_provider_id: str + :ivar organization_name: GCP organization name. + :vartype organization_name: str + """ + + _validation = { + "organization_membership_type": {"required": True}, + "organization_name": {"readonly": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "excluded_project_numbers": {"key": "excludedProjectNumbers", "type": "[str]"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "organization_name": {"key": "organizationName", "type": "str"}, + } + + def __init__( + self, + *, + excluded_project_numbers: Optional[List[str]] = None, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword excluded_project_numbers: If the multi cloud account is of membership type + organization, list of accounts excluded from offering. + :paramtype excluded_project_numbers: list[str] + :keyword service_account_email_address: The service account email address which represents the + organization level permissions container. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The GCP workload identity provider id which represents + the permissions required to auto provision security connectors. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.organization_membership_type: str = "Organization" + self.excluded_project_numbers = excluded_project_numbers + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + self.organization_name: Optional[str] = None + + +class GcpProjectDetails(_serialization.Model): + """The details about the project represented by the security connector. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar project_number: The unique GCP Project number. + :vartype project_number: str + :ivar project_id: The GCP Project id. + :vartype project_id: str + :ivar workload_identity_pool_id: The GCP workload identity federation pool id. + :vartype workload_identity_pool_id: str + :ivar project_name: GCP project name. + :vartype project_name: str + """ + + _validation = { + "workload_identity_pool_id": {"readonly": True}, + "project_name": {"readonly": True}, + } + + _attribute_map = { + "project_number": {"key": "projectNumber", "type": "str"}, + "project_id": {"key": "projectId", "type": "str"}, + "workload_identity_pool_id": {"key": "workloadIdentityPoolId", "type": "str"}, + "project_name": {"key": "projectName", "type": "str"}, + } + + def __init__( + self, *, project_number: Optional[str] = None, project_id: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword project_number: The unique GCP Project number. + :paramtype project_number: str + :keyword project_id: The GCP Project id. + :paramtype project_id: str + """ + super().__init__(**kwargs) + self.project_number = project_number + self.project_id = project_id + self.workload_identity_pool_id: Optional[str] = None + self.project_name: Optional[str] = None + + +class GcpProjectEnvironmentData(EnvironmentData): + """The GCP project connector environment data. + + All required parameters must be populated in order to send to server. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", "GitlabScope", + "DockerHubOrganization", and "JFrogArtifactory". + :vartype environment_type: str or ~azure.mgmt.security.models.EnvironmentType + :ivar organizational_data: The Gcp project's organizational data. + :vartype organizational_data: ~azure.mgmt.security.models.GcpOrganizationalData + :ivar project_details: The Gcp project's details. + :vartype project_details: ~azure.mgmt.security.models.GcpProjectDetails + :ivar scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :vartype scan_interval: int + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + "organizational_data": {"key": "organizationalData", "type": "GcpOrganizationalData"}, + "project_details": {"key": "projectDetails", "type": "GcpProjectDetails"}, + "scan_interval": {"key": "scanInterval", "type": "int"}, + } + + def __init__( + self, + *, + organizational_data: Optional["_models.GcpOrganizationalData"] = None, + project_details: Optional["_models.GcpProjectDetails"] = None, + scan_interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword organizational_data: The Gcp project's organizational data. + :paramtype organizational_data: ~azure.mgmt.security.models.GcpOrganizationalData + :keyword project_details: The Gcp project's details. + :paramtype project_details: ~azure.mgmt.security.models.GcpProjectDetails + :keyword scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :paramtype scan_interval: int + """ + super().__init__(**kwargs) + self.environment_type: str = "GcpProject" + self.organizational_data = organizational_data + self.project_details = project_details + self.scan_interval = scan_interval + + +class GetSensitivitySettingsListResponse(_serialization.Model): + """A list with a single sensitivity settings resource. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.GetSensitivitySettingsResponse] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GetSensitivitySettingsResponse]"}, + } + + def __init__( + self, *, value: Optional[List["_models.GetSensitivitySettingsResponse"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.security.models.GetSensitivitySettingsResponse] + """ + super().__init__(**kwargs) + self.value = value + + +class GetSensitivitySettingsResponse(_serialization.Model): + """Data sensitivity settings for sensitive data discovery. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the sensitivity settings. + :vartype id: str + :ivar type: The type of the sensitivity settings. + :vartype type: str + :ivar name: The name of the sensitivity settings. + :vartype name: str + :ivar properties: The sensitivity settings properties. + :vartype properties: ~azure.mgmt.security.models.GetSensitivitySettingsResponseProperties + """ + + _validation = { + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "GetSensitivitySettingsResponseProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.GetSensitivitySettingsResponseProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: The sensitivity settings properties. + :paramtype properties: ~azure.mgmt.security.models.GetSensitivitySettingsResponseProperties + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None + self.properties = properties + + +class GetSensitivitySettingsResponseProperties(_serialization.Model): + """The sensitivity settings properties. + + :ivar sensitive_info_types_ids: List of selected sensitive info types' IDs. + :vartype sensitive_info_types_ids: list[str] + :ivar sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any + label at or above this order will be considered sensitive. If set to -1, sensitivity by labels + is turned off. + :vartype sensitivity_threshold_label_order: float + :ivar sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label at + or above this rank will be considered sensitive. + :vartype sensitivity_threshold_label_id: str + :ivar mip_information: Microsoft information protection built-in and custom information types, + labels, and integration status. + :vartype mip_information: + ~azure.mgmt.security.models.GetSensitivitySettingsResponsePropertiesMipInformation + """ + + _attribute_map = { + "sensitive_info_types_ids": {"key": "sensitiveInfoTypesIds", "type": "[str]"}, + "sensitivity_threshold_label_order": {"key": "sensitivityThresholdLabelOrder", "type": "float"}, + "sensitivity_threshold_label_id": {"key": "sensitivityThresholdLabelId", "type": "str"}, + "mip_information": {"key": "mipInformation", "type": "GetSensitivitySettingsResponsePropertiesMipInformation"}, + } + + def __init__( + self, + *, + sensitive_info_types_ids: Optional[List[str]] = None, + sensitivity_threshold_label_order: Optional[float] = None, + sensitivity_threshold_label_id: Optional[str] = None, + mip_information: Optional["_models.GetSensitivitySettingsResponsePropertiesMipInformation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword sensitive_info_types_ids: List of selected sensitive info types' IDs. + :paramtype sensitive_info_types_ids: list[str] + :keyword sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any + label at or above this order will be considered sensitive. If set to -1, sensitivity by labels + is turned off. + :paramtype sensitivity_threshold_label_order: float + :keyword sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label + at or above this rank will be considered sensitive. + :paramtype sensitivity_threshold_label_id: str + :keyword mip_information: Microsoft information protection built-in and custom information + types, labels, and integration status. + :paramtype mip_information: + ~azure.mgmt.security.models.GetSensitivitySettingsResponsePropertiesMipInformation + """ + super().__init__(**kwargs) + self.sensitive_info_types_ids = sensitive_info_types_ids + self.sensitivity_threshold_label_order = sensitivity_threshold_label_order + self.sensitivity_threshold_label_id = sensitivity_threshold_label_id + self.mip_information = mip_information + + +class GetSensitivitySettingsResponsePropertiesMipInformation(_serialization.Model): # pylint: disable=name-too-long + """Microsoft information protection built-in and custom information types, labels, and integration + status. + + :ivar mip_integration_status: Microsoft information protection integration status. Known values + are: "Ok", "noConsent", "noAutoLabelingRules", and "noMipLabels". + :vartype mip_integration_status: str or ~azure.mgmt.security.models.MipIntegrationStatus + :ivar labels: List of Microsoft information protection sensitivity labels. + :vartype labels: list[~azure.mgmt.security.models.Label] + :ivar custom_info_types: List of custom user-defined information types. + :vartype custom_info_types: list[~azure.mgmt.security.models.InfoType] + :ivar built_in_info_types: List of pre-configured sensitive information types. + :vartype built_in_info_types: list[~azure.mgmt.security.models.BuiltInInfoType] + """ + + _attribute_map = { + "mip_integration_status": {"key": "mipIntegrationStatus", "type": "str"}, + "labels": {"key": "labels", "type": "[Label]"}, + "custom_info_types": {"key": "customInfoTypes", "type": "[InfoType]"}, + "built_in_info_types": {"key": "builtInInfoTypes", "type": "[BuiltInInfoType]"}, + } + + def __init__( + self, + *, + mip_integration_status: Optional[Union[str, "_models.MipIntegrationStatus"]] = None, + labels: Optional[List["_models.Label"]] = None, + custom_info_types: Optional[List["_models.InfoType"]] = None, + built_in_info_types: Optional[List["_models.BuiltInInfoType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword mip_integration_status: Microsoft information protection integration status. Known + values are: "Ok", "noConsent", "noAutoLabelingRules", and "noMipLabels". + :paramtype mip_integration_status: str or ~azure.mgmt.security.models.MipIntegrationStatus + :keyword labels: List of Microsoft information protection sensitivity labels. + :paramtype labels: list[~azure.mgmt.security.models.Label] + :keyword custom_info_types: List of custom user-defined information types. + :paramtype custom_info_types: list[~azure.mgmt.security.models.InfoType] + :keyword built_in_info_types: List of pre-configured sensitive information types. + :paramtype built_in_info_types: list[~azure.mgmt.security.models.BuiltInInfoType] + """ + super().__init__(**kwargs) + self.mip_integration_status = mip_integration_status + self.labels = labels + self.custom_info_types = custom_info_types + self.built_in_info_types = built_in_info_types + + +class GitHubOwner(ProxyResource): + """GitHub Owner 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. 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: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar properties: GitHub Owner properties. + :vartype properties: ~azure.mgmt.security.models.GitHubOwnerProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "GitHubOwnerProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GitHubOwnerProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: GitHub Owner properties. + :paramtype properties: ~azure.mgmt.security.models.GitHubOwnerProperties + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.properties = properties + + +class GitHubOwnerConfiguration(_serialization.Model): + """GitHub Owner Inventory Configuration. + + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :ivar repository_configs: GitHub Repository Inventory Configuration. + Dictionary of GitHub repository name to desired repository configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :vartype repository_configs: dict[str, ~azure.mgmt.security.models.BaseResourceConfiguration] + """ + + _attribute_map = { + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "repository_configs": {"key": "repositoryConfigs", "type": "{BaseResourceConfiguration}"}, + } + + def __init__( + self, + *, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + repository_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :keyword repository_configs: GitHub Repository Inventory Configuration. + Dictionary of GitHub repository name to desired repository configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :paramtype repository_configs: dict[str, ~azure.mgmt.security.models.BaseResourceConfiguration] + """ + super().__init__(**kwargs) + self.auto_discovery = auto_discovery + self.repository_configs = repository_configs + + +class GitHubOwnerListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.models.GitHubOwner] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GitHubOwner]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.GitHubOwner"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.models.GitHubOwner] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitHubOwnerProperties(_serialization.Model): + """GitHub Owner properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets the resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets the time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or ~azure.mgmt.security.models.DevOpsProvisioningState + :ivar owner_url: Gets or sets GitHub Owner url. + :vartype owner_url: str + :ivar git_hub_internal_id: Gets or sets internal GitHub id. + :vartype git_hub_internal_id: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "owner_url": {"readonly": True}, + "git_hub_internal_id": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "owner_url": {"key": "ownerUrl", "type": "str"}, + "git_hub_internal_id": {"key": "gitHubInternalId", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + } + + def __init__( + self, *, onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, **kwargs: Any + ) -> None: + """ + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + """ + super().__init__(**kwargs) + self.provisioning_status_message: Optional[str] = None + self.provisioning_status_update_time_utc: Optional[datetime.datetime] = None + self.provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None + self.owner_url: Optional[str] = None + self.git_hub_internal_id: Optional[str] = None + self.onboarding_state = onboarding_state + + +class GitHubRepository(ProxyResource): + """GitHub Repository 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. 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: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar properties: GitHub Repository properties. + :vartype properties: ~azure.mgmt.security.models.GitHubRepositoryProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "GitHubRepositoryProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GitHubRepositoryProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: GitHub Repository properties. + :paramtype properties: ~azure.mgmt.security.models.GitHubRepositoryProperties + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.properties = properties + + +class GitHubRepositoryListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.models.GitHubRepository] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GitHubRepository]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.GitHubRepository"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.models.GitHubRepository] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitHubRepositoryProperties(_serialization.Model): + """GitHub Repository properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets the resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets the time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or ~azure.mgmt.security.models.DevOpsProvisioningState + :ivar repo_id: Gets or sets GitHub Repository id. + + This is a numeric id defined by Github. + Eg: "123456". + :vartype repo_id: str + :ivar repo_name: Gets or sets GitHub Repository name. + Eg: "new-repo-1". + :vartype repo_name: str + :ivar repo_full_name: Gets or sets GitHub Full Name. + Repository name, prefixed with Owner name. + Eg: "my-org/new-repo-1". + :vartype repo_full_name: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + :ivar repo_url: Gets or sets GitHub Repository url. + :vartype repo_url: str + :ivar parent_owner_name: Gets or sets parent GitHub Owner name. + :vartype parent_owner_name: str + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "repo_id": {"readonly": True}, + "repo_name": {"readonly": True}, + "repo_full_name": {"readonly": True}, + "repo_url": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "repo_id": {"key": "repoId", "type": "str"}, + "repo_name": {"key": "repoName", "type": "str"}, + "repo_full_name": {"key": "repoFullName", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + "repo_url": {"key": "repoUrl", "type": "str"}, + "parent_owner_name": {"key": "parentOwnerName", "type": "str"}, + } + + def __init__( + self, + *, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + parent_owner_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + :keyword parent_owner_name: Gets or sets parent GitHub Owner name. + :paramtype parent_owner_name: str + """ + super().__init__(**kwargs) + self.provisioning_status_message: Optional[str] = None + self.provisioning_status_update_time_utc: Optional[datetime.datetime] = None + self.provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None + self.repo_id: Optional[str] = None + self.repo_name: Optional[str] = None + self.repo_full_name: Optional[str] = None + self.onboarding_state = onboarding_state + self.repo_url: Optional[str] = None + self.parent_owner_name = parent_owner_name + + +class GithubScopeEnvironmentData(EnvironmentData): + """The github scope connector's environment data. + + All required parameters must be populated in order to send to server. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", "GitlabScope", + "DockerHubOrganization", and "JFrogArtifactory". + :vartype environment_type: str or ~azure.mgmt.security.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.environment_type: str = "GithubScope" + + +class GitLabGroup(ProxyResource): + """GitLab Group 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. 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: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar properties: GitLab Group properties. + :vartype properties: ~azure.mgmt.security.models.GitLabGroupProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "GitLabGroupProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GitLabGroupProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: GitLab Group properties. + :paramtype properties: ~azure.mgmt.security.models.GitLabGroupProperties + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.properties = properties + + +class GitLabGroupConfiguration(_serialization.Model): + """GitLab Group Inventory Configuration. + + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :ivar project_configs: GitLab Project Inventory Configuration. + Dictionary of GitLab fully-qualified project name to desired project configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :vartype project_configs: dict[str, ~azure.mgmt.security.models.BaseResourceConfiguration] + """ + + _attribute_map = { + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "project_configs": {"key": "projectConfigs", "type": "{BaseResourceConfiguration}"}, + } + + def __init__( + self, + *, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + project_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.models.AutoDiscovery + :keyword project_configs: GitLab Project Inventory Configuration. + Dictionary of GitLab fully-qualified project name to desired project configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :paramtype project_configs: dict[str, ~azure.mgmt.security.models.BaseResourceConfiguration] + """ + super().__init__(**kwargs) + self.auto_discovery = auto_discovery + self.project_configs = project_configs + + +class GitLabGroupListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.models.GitLabGroup] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GitLabGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.GitLabGroup"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.models.GitLabGroup] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitLabGroupProperties(_serialization.Model): + """GitLab Group properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets the resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets the time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or ~azure.mgmt.security.models.DevOpsProvisioningState + :ivar fully_qualified_name: Gets or sets the fully-qualified name of the Group object. + + This contains the entire namespace hierarchy where namespaces are separated by the '$' + character. + :vartype fully_qualified_name: str + :ivar fully_qualified_friendly_name: Gets or sets the human readable fully-qualified name of + the Group object. + + This contains the entire namespace hierarchy as seen on GitLab UI where namespaces are + separated by the '/' character. + :vartype fully_qualified_friendly_name: str + :ivar url: Gets or sets the url of the GitLab Group. + :vartype url: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "fully_qualified_name": {"readonly": True}, + "fully_qualified_friendly_name": {"readonly": True}, + "url": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fully_qualified_name": {"key": "fullyQualifiedName", "type": "str"}, + "fully_qualified_friendly_name": {"key": "fullyQualifiedFriendlyName", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + } + + def __init__( + self, *, onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, **kwargs: Any + ) -> None: + """ + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + """ + super().__init__(**kwargs) + self.provisioning_status_message: Optional[str] = None + self.provisioning_status_update_time_utc: Optional[datetime.datetime] = None + self.provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None + self.fully_qualified_name: Optional[str] = None + self.fully_qualified_friendly_name: Optional[str] = None + self.url: Optional[str] = None + self.onboarding_state = onboarding_state + + +class GitLabProject(ProxyResource): + """GitLab Project 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. 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: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar properties: GitLab Project properties. + :vartype properties: ~azure.mgmt.security.models.GitLabProjectProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "GitLabProjectProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GitLabProjectProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: GitLab Project properties. + :paramtype properties: ~azure.mgmt.security.models.GitLabProjectProperties + """ + super().__init__(**kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.properties = properties + + +class GitLabProjectListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.models.GitLabProject] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GitLabProject]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.GitLabProject"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.models.GitLabProject] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitLabProjectProperties(_serialization.Model): + """GitLab Project properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets the resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets the time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or ~azure.mgmt.security.models.DevOpsProvisioningState + :ivar fully_qualified_name: Gets or sets the fully-qualified name of the project object. + + This contains the entire hierarchy where entities are separated by the '$' character. + :vartype fully_qualified_name: str + :ivar fully_qualified_friendly_name: Gets or sets the human readable fully-qualified name of + the Project object. + + This contains the entire namespace hierarchy as seen on GitLab UI where entities are separated + by the '/' character. + :vartype fully_qualified_friendly_name: str + :ivar fully_qualified_parent_group_name: Gets or sets the fully-qualified name of the project's + parent group object. + + This contains the entire hierarchy where namespaces are separated by the '$' character. + :vartype fully_qualified_parent_group_name: str + :ivar url: Gets or sets the url of the GitLab Project. + :vartype url: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "fully_qualified_name": {"readonly": True}, + "fully_qualified_friendly_name": {"readonly": True}, + "fully_qualified_parent_group_name": {"readonly": True}, + "url": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fully_qualified_name": {"key": "fullyQualifiedName", "type": "str"}, + "fully_qualified_friendly_name": {"key": "fullyQualifiedFriendlyName", "type": "str"}, + "fully_qualified_parent_group_name": {"key": "fullyQualifiedParentGroupName", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + } + + def __init__( + self, *, onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, **kwargs: Any + ) -> None: + """ + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or ~azure.mgmt.security.models.OnboardingState + """ + super().__init__(**kwargs) + self.provisioning_status_message: Optional[str] = None + self.provisioning_status_update_time_utc: Optional[datetime.datetime] = None + self.provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None + self.fully_qualified_name: Optional[str] = None + self.fully_qualified_friendly_name: Optional[str] = None + self.fully_qualified_parent_group_name: Optional[str] = None + self.url: Optional[str] = None + self.onboarding_state = onboarding_state + + +class GitlabScopeEnvironmentData(EnvironmentData): + """The GitLab scope connector's environment data. + + All required parameters must be populated in order to send to server. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", "GitlabScope", + "DockerHubOrganization", and "JFrogArtifactory". + :vartype environment_type: str or ~azure.mgmt.security.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.environment_type: str = "GitlabScope" + + +class GovernanceAssignment(Resource): + """Governance assignment over a given scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar owner: The Owner for the governance assignment - e.g. user@contoso.com - see example. + :vartype owner: str + :ivar remediation_due_date: The remediation due-date - after this date Secure Score will be + affected (in case of active grace-period). + :vartype remediation_due_date: ~datetime.datetime + :ivar remediation_eta: The ETA (estimated time of arrival) for remediation (optional), see + example. + :vartype remediation_eta: ~azure.mgmt.security.models.RemediationEta + :ivar is_grace_period: Defines whether there is a grace period on the governance assignment. + :vartype is_grace_period: bool + :ivar governance_email_notification: The email notifications settings for the governance rule, + states whether to disable notifications for mangers and owners. + :vartype governance_email_notification: ~azure.mgmt.security.models.GovernanceEmailNotification + :ivar additional_data: The additional data for the governance assignment - e.g. links to ticket + (optional), see example. + :vartype additional_data: ~azure.mgmt.security.models.GovernanceAssignmentAdditionalData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "owner": {"key": "properties.owner", "type": "str"}, + "remediation_due_date": {"key": "properties.remediationDueDate", "type": "iso-8601"}, + "remediation_eta": {"key": "properties.remediationEta", "type": "RemediationEta"}, + "is_grace_period": {"key": "properties.isGracePeriod", "type": "bool"}, + "governance_email_notification": { + "key": "properties.governanceEmailNotification", + "type": "GovernanceEmailNotification", + }, + "additional_data": {"key": "properties.additionalData", "type": "GovernanceAssignmentAdditionalData"}, + } + + def __init__( + self, + *, + owner: Optional[str] = None, + remediation_due_date: Optional[datetime.datetime] = None, + remediation_eta: Optional["_models.RemediationEta"] = None, + is_grace_period: Optional[bool] = None, + governance_email_notification: Optional["_models.GovernanceEmailNotification"] = None, + additional_data: Optional["_models.GovernanceAssignmentAdditionalData"] = None, + **kwargs: Any + ) -> None: + """ + :keyword owner: The Owner for the governance assignment - e.g. user@contoso.com - see example. + :paramtype owner: str + :keyword remediation_due_date: The remediation due-date - after this date Secure Score will be + affected (in case of active grace-period). + :paramtype remediation_due_date: ~datetime.datetime + :keyword remediation_eta: The ETA (estimated time of arrival) for remediation (optional), see + example. + :paramtype remediation_eta: ~azure.mgmt.security.models.RemediationEta + :keyword is_grace_period: Defines whether there is a grace period on the governance assignment. + :paramtype is_grace_period: bool + :keyword governance_email_notification: The email notifications settings for the governance + rule, states whether to disable notifications for mangers and owners. + :paramtype governance_email_notification: + ~azure.mgmt.security.models.GovernanceEmailNotification + :keyword additional_data: The additional data for the governance assignment - e.g. links to + ticket (optional), see example. + :paramtype additional_data: ~azure.mgmt.security.models.GovernanceAssignmentAdditionalData + """ + super().__init__(**kwargs) + self.owner = owner + self.remediation_due_date = remediation_due_date + self.remediation_eta = remediation_eta + self.is_grace_period = is_grace_period + self.governance_email_notification = governance_email_notification + self.additional_data = additional_data + + +class GovernanceAssignmentAdditionalData(_serialization.Model): + """Describe the additional data of governance assignment - optional. + + :ivar ticket_number: Ticket number associated with this governance assignment. + :vartype ticket_number: int + :ivar ticket_link: Ticket link associated with this governance assignment - for example: + https://snow.com. + :vartype ticket_link: str + :ivar ticket_status: The ticket status associated with this governance assignment - for + example: Active. + :vartype ticket_status: str + """ + + _validation = { + "ticket_number": {"minimum": 0}, + } + + _attribute_map = { + "ticket_number": {"key": "ticketNumber", "type": "int"}, + "ticket_link": {"key": "ticketLink", "type": "str"}, + "ticket_status": {"key": "ticketStatus", "type": "str"}, + } + + def __init__( + self, + *, + ticket_number: Optional[int] = None, + ticket_link: Optional[str] = None, + ticket_status: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword ticket_number: Ticket number associated with this governance assignment. + :paramtype ticket_number: int + :keyword ticket_link: Ticket link associated with this governance assignment - for example: + https://snow.com. + :paramtype ticket_link: str + :keyword ticket_status: The ticket status associated with this governance assignment - for + example: Active. + :paramtype ticket_status: str + """ + super().__init__(**kwargs) + self.ticket_number = ticket_number + self.ticket_link = ticket_link + self.ticket_status = ticket_status + + +class GovernanceAssignmentsList(_serialization.Model): + """Page of a governance assignments list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of governance assignments in this page. + :vartype value: list[~azure.mgmt.security.models.GovernanceAssignment] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[GovernanceAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.GovernanceAssignment"]] = None + self.next_link: Optional[str] = None + + +class GovernanceEmailNotification(_serialization.Model): + """The governance email weekly notification configuration. + + :ivar disable_manager_email_notification: Exclude manager from weekly email notification. + :vartype disable_manager_email_notification: bool + :ivar disable_owner_email_notification: Exclude owner from weekly email notification. + :vartype disable_owner_email_notification: bool + """ + + _attribute_map = { + "disable_manager_email_notification": {"key": "disableManagerEmailNotification", "type": "bool"}, + "disable_owner_email_notification": {"key": "disableOwnerEmailNotification", "type": "bool"}, + } + + def __init__( + self, + *, + disable_manager_email_notification: Optional[bool] = None, + disable_owner_email_notification: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword disable_manager_email_notification: Exclude manager from weekly email notification. + :paramtype disable_manager_email_notification: bool + :keyword disable_owner_email_notification: Exclude owner from weekly email notification. + :paramtype disable_owner_email_notification: bool + """ + super().__init__(**kwargs) + self.disable_manager_email_notification = disable_manager_email_notification + self.disable_owner_email_notification = disable_owner_email_notification + + +class GovernanceRule(Resource): + """Governance rule over a given scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar tenant_id: The tenantId (GUID). + :vartype tenant_id: str + :ivar display_name: Display name of the governance rule. + :vartype display_name: str + :ivar description: Description of the governance rule. + :vartype description: str + :ivar remediation_timeframe: Governance rule remediation timeframe - this is the time that will + affect on the grace-period duration e.g. 7.00:00:00 - means 7 days. + :vartype remediation_timeframe: str + :ivar is_grace_period: Defines whether there is a grace period on the governance rule. + :vartype is_grace_period: bool + :ivar rule_priority: The governance rule priority, priority to the lower number. Rules with the + same priority on the same scope will not be allowed. + :vartype rule_priority: int + :ivar is_disabled: Defines whether the rule is active/inactive. + :vartype is_disabled: bool + :ivar rule_type: The rule type of the governance rule, defines the source of the rule e.g. + Integrated. Known values are: "Integrated" and "ServiceNow". + :vartype rule_type: str or ~azure.mgmt.security.models.GovernanceRuleType + :ivar source_resource_type: The governance rule source, what the rule affects, e.g. + Assessments. "Assessments" + :vartype source_resource_type: str or + ~azure.mgmt.security.models.GovernanceRuleSourceResourceType + :ivar excluded_scopes: Excluded scopes, filter out the descendants of the scope (on management + scopes). + :vartype excluded_scopes: list[str] + :ivar condition_sets: The governance rule conditionSets - see examples. + :vartype condition_sets: list[JSON] + :ivar include_member_scopes: Defines whether the rule is management scope rule (master + connector as a single scope or management scope). + :vartype include_member_scopes: bool + :ivar owner_source: The owner source for the governance rule - e.g. Manually by + user@contoso.com - see example. + :vartype owner_source: ~azure.mgmt.security.models.GovernanceRuleOwnerSource + :ivar governance_email_notification: The email notifications settings for the governance rule, + states whether to disable notifications for mangers and owners. + :vartype governance_email_notification: + ~azure.mgmt.security.models.GovernanceRuleEmailNotification + :ivar metadata: The governance rule metadata. + :vartype metadata: ~azure.mgmt.security.models.GovernanceRuleMetadata + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "tenant_id": {"readonly": True}, + "remediation_timeframe": {"pattern": r"^[0-9]+\.[0-9]{2}:[0-9]{2}:[0-9]{2}$"}, + "rule_priority": {"maximum": 1000, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "remediation_timeframe": {"key": "properties.remediationTimeframe", "type": "str"}, + "is_grace_period": {"key": "properties.isGracePeriod", "type": "bool"}, + "rule_priority": {"key": "properties.rulePriority", "type": "int"}, + "is_disabled": {"key": "properties.isDisabled", "type": "bool"}, + "rule_type": {"key": "properties.ruleType", "type": "str"}, + "source_resource_type": {"key": "properties.sourceResourceType", "type": "str"}, + "excluded_scopes": {"key": "properties.excludedScopes", "type": "[str]"}, + "condition_sets": {"key": "properties.conditionSets", "type": "[object]"}, + "include_member_scopes": {"key": "properties.includeMemberScopes", "type": "bool"}, + "owner_source": {"key": "properties.ownerSource", "type": "GovernanceRuleOwnerSource"}, + "governance_email_notification": { + "key": "properties.governanceEmailNotification", + "type": "GovernanceRuleEmailNotification", + }, + "metadata": {"key": "properties.metadata", "type": "GovernanceRuleMetadata"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + remediation_timeframe: Optional[str] = None, + is_grace_period: Optional[bool] = None, + rule_priority: Optional[int] = None, + is_disabled: Optional[bool] = None, + rule_type: Optional[Union[str, "_models.GovernanceRuleType"]] = None, + source_resource_type: Optional[Union[str, "_models.GovernanceRuleSourceResourceType"]] = None, + excluded_scopes: Optional[List[str]] = None, + condition_sets: Optional[List[JSON]] = None, + include_member_scopes: Optional[bool] = None, + owner_source: Optional["_models.GovernanceRuleOwnerSource"] = None, + governance_email_notification: Optional["_models.GovernanceRuleEmailNotification"] = None, + metadata: Optional["_models.GovernanceRuleMetadata"] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: Display name of the governance rule. + :paramtype display_name: str + :keyword description: Description of the governance rule. + :paramtype description: str + :keyword remediation_timeframe: Governance rule remediation timeframe - this is the time that + will affect on the grace-period duration e.g. 7.00:00:00 - means 7 days. + :paramtype remediation_timeframe: str + :keyword is_grace_period: Defines whether there is a grace period on the governance rule. + :paramtype is_grace_period: bool + :keyword rule_priority: The governance rule priority, priority to the lower number. Rules with + the same priority on the same scope will not be allowed. + :paramtype rule_priority: int + :keyword is_disabled: Defines whether the rule is active/inactive. + :paramtype is_disabled: bool + :keyword rule_type: The rule type of the governance rule, defines the source of the rule e.g. + Integrated. Known values are: "Integrated" and "ServiceNow". + :paramtype rule_type: str or ~azure.mgmt.security.models.GovernanceRuleType + :keyword source_resource_type: The governance rule source, what the rule affects, e.g. + Assessments. "Assessments" + :paramtype source_resource_type: str or + ~azure.mgmt.security.models.GovernanceRuleSourceResourceType + :keyword excluded_scopes: Excluded scopes, filter out the descendants of the scope (on + management scopes). + :paramtype excluded_scopes: list[str] + :keyword condition_sets: The governance rule conditionSets - see examples. + :paramtype condition_sets: list[JSON] + :keyword include_member_scopes: Defines whether the rule is management scope rule (master + connector as a single scope or management scope). + :paramtype include_member_scopes: bool + :keyword owner_source: The owner source for the governance rule - e.g. Manually by + user@contoso.com - see example. + :paramtype owner_source: ~azure.mgmt.security.models.GovernanceRuleOwnerSource + :keyword governance_email_notification: The email notifications settings for the governance + rule, states whether to disable notifications for mangers and owners. + :paramtype governance_email_notification: + ~azure.mgmt.security.models.GovernanceRuleEmailNotification + :keyword metadata: The governance rule metadata. + :paramtype metadata: ~azure.mgmt.security.models.GovernanceRuleMetadata + """ + super().__init__(**kwargs) + self.tenant_id: Optional[str] = None + self.display_name = display_name + self.description = description + self.remediation_timeframe = remediation_timeframe + self.is_grace_period = is_grace_period + self.rule_priority = rule_priority + self.is_disabled = is_disabled + self.rule_type = rule_type + self.source_resource_type = source_resource_type + self.excluded_scopes = excluded_scopes + self.condition_sets = condition_sets + self.include_member_scopes = include_member_scopes + self.owner_source = owner_source + self.governance_email_notification = governance_email_notification + self.metadata = metadata + + +class GovernanceRuleEmailNotification(_serialization.Model): + """The governance email weekly notification configuration. + + :ivar disable_manager_email_notification: Defines whether manager email notifications are + disabled. + :vartype disable_manager_email_notification: bool + :ivar disable_owner_email_notification: Defines whether owner email notifications are disabled. + :vartype disable_owner_email_notification: bool + """ + + _attribute_map = { + "disable_manager_email_notification": {"key": "disableManagerEmailNotification", "type": "bool"}, + "disable_owner_email_notification": {"key": "disableOwnerEmailNotification", "type": "bool"}, + } + + def __init__( + self, + *, + disable_manager_email_notification: Optional[bool] = None, + disable_owner_email_notification: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword disable_manager_email_notification: Defines whether manager email notifications are + disabled. + :paramtype disable_manager_email_notification: bool + :keyword disable_owner_email_notification: Defines whether owner email notifications are + disabled. + :paramtype disable_owner_email_notification: bool + """ + super().__init__(**kwargs) + self.disable_manager_email_notification = disable_manager_email_notification + self.disable_owner_email_notification = disable_owner_email_notification + + +class GovernanceRuleList(_serialization.Model): + """Page of a governance rules list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of governance rules in this page. + :vartype value: list[~azure.mgmt.security.models.GovernanceRule] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[GovernanceRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.GovernanceRule"]] = None + self.next_link: Optional[str] = None + + +class GovernanceRuleMetadata(_serialization.Model): + """The governance rule metadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar created_by: Governance rule Created by object id (GUID). + :vartype created_by: str + :ivar created_on: Governance rule creation date. + :vartype created_on: ~datetime.datetime + :ivar updated_by: Governance rule last updated by object id (GUID). + :vartype updated_by: str + :ivar updated_on: Governance rule last update date. + :vartype updated_on: ~datetime.datetime + """ + + _validation = { + "created_by": {"readonly": True}, + "created_on": {"readonly": True}, + "updated_by": {"readonly": True}, + "updated_on": {"readonly": True}, + } + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_on": {"key": "createdOn", "type": "iso-8601"}, + "updated_by": {"key": "updatedBy", "type": "str"}, + "updated_on": {"key": "updatedOn", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.created_by: Optional[str] = None + self.created_on: Optional[datetime.datetime] = None + self.updated_by: Optional[str] = None + self.updated_on: Optional[datetime.datetime] = None + + +class GovernanceRuleOwnerSource(_serialization.Model): + """Describe the owner source of governance rule. + + :ivar type: The owner type for the governance rule owner source. Known values are: "ByTag" and + "Manually". + :vartype type: str or ~azure.mgmt.security.models.GovernanceRuleOwnerSourceType + :ivar value: The source value e.g. tag key like owner name or email address. + :vartype value: str + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.GovernanceRuleOwnerSourceType"]] = None, + value: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The owner type for the governance rule owner source. Known values are: "ByTag" + and "Manually". + :paramtype type: str or ~azure.mgmt.security.models.GovernanceRuleOwnerSourceType + :keyword value: The source value e.g. tag key like owner name or email address. + :paramtype value: str + """ + super().__init__(**kwargs) + self.type = type + self.value = value + + +class HealthDataClassification(_serialization.Model): + """The classification of the health report. + + :ivar component: The component describes the name of the agent/service that scans the issue. + :vartype component: str + :ivar scenario: The scenario describes the health scenario issue of the component. + :vartype scenario: str + :ivar scope: The resource scope of the health report. + :vartype scope: str + """ + + _attribute_map = { + "component": {"key": "component", "type": "str"}, + "scenario": {"key": "scenario", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + } + + def __init__( + self, + *, + component: Optional[str] = None, + scenario: Optional[str] = None, + scope: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword component: The component describes the name of the agent/service that scans the issue. + :paramtype component: str + :keyword scenario: The scenario describes the health scenario issue of the component. + :paramtype scenario: str + :keyword scope: The resource scope of the health report. + :paramtype scope: str + """ + super().__init__(**kwargs) + self.component = component + self.scenario = scenario + self.scope = scope + + +class HealthReport(Resource): + """The health report resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar resource_details: The resource details of the health report. + :vartype resource_details: ~azure.mgmt.security.models.ResourceDetailsAutoGenerated + :ivar environment_details: The environment details of the resource. + :vartype environment_details: ~azure.mgmt.security.models.EnvironmentDetails + :ivar health_data_classification: The classification of the health report. + :vartype health_data_classification: ~azure.mgmt.security.models.HealthDataClassification + :ivar status: The status of the health report. + :vartype status: ~azure.mgmt.security.models.StatusAutoGenerated + :ivar affected_defenders_plans: The affected defenders plans by unhealthy report. + :vartype affected_defenders_plans: list[str] + :ivar affected_defenders_sub_plans: The affected defenders sub plans by unhealthy report. + :vartype affected_defenders_sub_plans: list[str] + :ivar report_additional_data: Additional data for the given health report, this field can + include more details on the resource and the health scenario. + :vartype report_additional_data: dict[str, str] + :ivar issues: A collection of the issues in the report. + :vartype issues: list[~azure.mgmt.security.models.Issue] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "report_additional_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetailsAutoGenerated"}, + "environment_details": {"key": "properties.environmentDetails", "type": "EnvironmentDetails"}, + "health_data_classification": { + "key": "properties.healthDataClassification", + "type": "HealthDataClassification", + }, + "status": {"key": "properties.status", "type": "StatusAutoGenerated"}, + "affected_defenders_plans": {"key": "properties.affectedDefendersPlans", "type": "[str]"}, + "affected_defenders_sub_plans": {"key": "properties.affectedDefendersSubPlans", "type": "[str]"}, + "report_additional_data": {"key": "properties.reportAdditionalData", "type": "{str}"}, + "issues": {"key": "properties.issues", "type": "[Issue]"}, + } + + def __init__( + self, + *, + resource_details: Optional["_models.ResourceDetailsAutoGenerated"] = None, + environment_details: Optional["_models.EnvironmentDetails"] = None, + health_data_classification: Optional["_models.HealthDataClassification"] = None, + status: Optional["_models.StatusAutoGenerated"] = None, + affected_defenders_plans: Optional[List[str]] = None, + affected_defenders_sub_plans: Optional[List[str]] = None, + issues: Optional[List["_models.Issue"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword resource_details: The resource details of the health report. + :paramtype resource_details: ~azure.mgmt.security.models.ResourceDetailsAutoGenerated + :keyword environment_details: The environment details of the resource. + :paramtype environment_details: ~azure.mgmt.security.models.EnvironmentDetails + :keyword health_data_classification: The classification of the health report. + :paramtype health_data_classification: ~azure.mgmt.security.models.HealthDataClassification + :keyword status: The status of the health report. + :paramtype status: ~azure.mgmt.security.models.StatusAutoGenerated + :keyword affected_defenders_plans: The affected defenders plans by unhealthy report. + :paramtype affected_defenders_plans: list[str] + :keyword affected_defenders_sub_plans: The affected defenders sub plans by unhealthy report. + :paramtype affected_defenders_sub_plans: list[str] + :keyword issues: A collection of the issues in the report. + :paramtype issues: list[~azure.mgmt.security.models.Issue] + """ + super().__init__(**kwargs) + self.resource_details = resource_details + self.environment_details = environment_details + self.health_data_classification = health_data_classification + self.status = status + self.affected_defenders_plans = affected_defenders_plans + self.affected_defenders_sub_plans = affected_defenders_sub_plans + self.report_additional_data: Optional[Dict[str, str]] = None + self.issues = issues + + +class HealthReportsList(_serialization.Model): + """Page of health reports list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of health reports in this page. + :vartype value: list[~azure.mgmt.security.models.HealthReport] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[HealthReport]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.HealthReport"]] = None + self.next_link: Optional[str] = None + + +class HttpC2DMessagesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of cloud to device messages (HTTP protocol) is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "HttpC2DMessagesNotInAllowedRange" + + +class HttpC2DRejectedMessagesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of rejected cloud to device messages (HTTP protocol) is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "HttpC2DRejectedMessagesNotInAllowedRange" + + +class HttpD2CMessagesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of device to cloud messages (HTTP protocol) is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "HttpD2CMessagesNotInAllowedRange" + + +class HybridComputeSettingsProperties(_serialization.Model): + """Settings for hybrid compute management. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar hybrid_compute_provisioning_state: State of the service principal and its secret. Known + values are: "Valid", "Invalid", and "Expired". + :vartype hybrid_compute_provisioning_state: str or + ~azure.mgmt.security.models.HybridComputeProvisioningState + :ivar auto_provision: Whether or not to automatically install Azure Arc (hybrid compute) agents + on machines. Required. Known values are: "On" and "Off". + :vartype auto_provision: str or ~azure.mgmt.security.models.AutoProvision + :ivar resource_group_name: The name of the resource group where Arc (Hybrid Compute) connectors + are connected. + :vartype resource_group_name: str + :ivar region: The location where the metadata of machines will be stored. + :vartype region: str + :ivar proxy_server: For a non-Azure machine that is not connected directly to the internet, + specify a proxy server that the non-Azure machine can use. + :vartype proxy_server: ~azure.mgmt.security.models.ProxyServerProperties + :ivar service_principal: An object to access resources that are secured by an Azure AD tenant. + :vartype service_principal: ~azure.mgmt.security.models.ServicePrincipalProperties + """ + + _validation = { + "hybrid_compute_provisioning_state": {"readonly": True}, + "auto_provision": {"required": True}, + } + + _attribute_map = { + "hybrid_compute_provisioning_state": {"key": "hybridComputeProvisioningState", "type": "str"}, + "auto_provision": {"key": "autoProvision", "type": "str"}, + "resource_group_name": {"key": "resourceGroupName", "type": "str"}, + "region": {"key": "region", "type": "str"}, + "proxy_server": {"key": "proxyServer", "type": "ProxyServerProperties"}, + "service_principal": {"key": "servicePrincipal", "type": "ServicePrincipalProperties"}, + } + + def __init__( + self, + *, + auto_provision: Union[str, "_models.AutoProvision"], + resource_group_name: Optional[str] = None, + region: Optional[str] = None, + proxy_server: Optional["_models.ProxyServerProperties"] = None, + service_principal: Optional["_models.ServicePrincipalProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_provision: Whether or not to automatically install Azure Arc (hybrid compute) + agents on machines. Required. Known values are: "On" and "Off". + :paramtype auto_provision: str or ~azure.mgmt.security.models.AutoProvision + :keyword resource_group_name: The name of the resource group where Arc (Hybrid Compute) + connectors are connected. + :paramtype resource_group_name: str + :keyword region: The location where the metadata of machines will be stored. + :paramtype region: str + :keyword proxy_server: For a non-Azure machine that is not connected directly to the internet, + specify a proxy server that the non-Azure machine can use. + :paramtype proxy_server: ~azure.mgmt.security.models.ProxyServerProperties + :keyword service_principal: An object to access resources that are secured by an Azure AD + tenant. + :paramtype service_principal: ~azure.mgmt.security.models.ServicePrincipalProperties + """ + super().__init__(**kwargs) + self.hybrid_compute_provisioning_state: Optional[Union[str, "_models.HybridComputeProvisioningState"]] = None + self.auto_provision = auto_provision + self.resource_group_name = resource_group_name + self.region = region + self.proxy_server = proxy_server + self.service_principal = service_principal + + +class Identity(_serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Default value is "SystemAssigned". + :vartype type: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Default value is "SystemAssigned". + :paramtype type: str + """ + super().__init__(**kwargs) + self.principal_id: Optional[str] = None + self.tenant_id: Optional[str] = None + self.type = type + + +class InformationProtectionKeyword(_serialization.Model): + """The information type keyword. + + :ivar pattern: The keyword pattern. + :vartype pattern: str + :ivar custom: Indicates whether the keyword is custom or not. + :vartype custom: bool + :ivar can_be_numeric: Indicates whether the keyword can be applied on numeric types or not. + :vartype can_be_numeric: bool + :ivar excluded: Indicates whether the keyword is excluded or not. + :vartype excluded: bool + """ + + _attribute_map = { + "pattern": {"key": "pattern", "type": "str"}, + "custom": {"key": "custom", "type": "bool"}, + "can_be_numeric": {"key": "canBeNumeric", "type": "bool"}, + "excluded": {"key": "excluded", "type": "bool"}, + } + + def __init__( + self, + *, + pattern: Optional[str] = None, + custom: Optional[bool] = None, + can_be_numeric: Optional[bool] = None, + excluded: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword pattern: The keyword pattern. + :paramtype pattern: str + :keyword custom: Indicates whether the keyword is custom or not. + :paramtype custom: bool + :keyword can_be_numeric: Indicates whether the keyword can be applied on numeric types or not. + :paramtype can_be_numeric: bool + :keyword excluded: Indicates whether the keyword is excluded or not. + :paramtype excluded: bool + """ + super().__init__(**kwargs) + self.pattern = pattern + self.custom = custom + self.can_be_numeric = can_be_numeric + self.excluded = excluded + + +class InformationProtectionPolicy(Resource): + """Information protection policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar last_modified_utc: Describes the last UTC time the policy was modified. + :vartype last_modified_utc: ~datetime.datetime + :ivar version: Describes the version of the policy. + :vartype version: str + :ivar labels: Dictionary of sensitivity labels. + :vartype labels: dict[str, ~azure.mgmt.security.models.SensitivityLabel] + :ivar information_types: The sensitivity information types. + :vartype information_types: dict[str, ~azure.mgmt.security.models.InformationType] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_utc": {"readonly": True}, + "version": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_utc": {"key": "properties.lastModifiedUtc", "type": "iso-8601"}, + "version": {"key": "properties.version", "type": "str"}, + "labels": {"key": "properties.labels", "type": "{SensitivityLabel}"}, + "information_types": {"key": "properties.informationTypes", "type": "{InformationType}"}, + } + + def __init__( + self, + *, + labels: Optional[Dict[str, "_models.SensitivityLabel"]] = None, + information_types: Optional[Dict[str, "_models.InformationType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword labels: Dictionary of sensitivity labels. + :paramtype labels: dict[str, ~azure.mgmt.security.models.SensitivityLabel] + :keyword information_types: The sensitivity information types. + :paramtype information_types: dict[str, ~azure.mgmt.security.models.InformationType] + """ + super().__init__(**kwargs) + self.last_modified_utc: Optional[datetime.datetime] = None + self.version: Optional[str] = None + self.labels = labels + self.information_types = information_types + + +class InformationProtectionPolicyList(_serialization.Model): + """Information protection policies response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of information protection policies. + :vartype value: list[~azure.mgmt.security.models.InformationProtectionPolicy] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[InformationProtectionPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.InformationProtectionPolicy"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of information protection policies. + :paramtype value: list[~azure.mgmt.security.models.InformationProtectionPolicy] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class InformationType(_serialization.Model): + """The information type. + + :ivar display_name: The name of the information type. + :vartype display_name: str + :ivar description: The description of the information type. + :vartype description: str + :ivar order: The order of the information type. + :vartype order: int + :ivar recommended_label_id: The recommended label id to be associated with this information + type. + :vartype recommended_label_id: str + :ivar enabled: Indicates whether the information type is enabled or not. + :vartype enabled: bool + :ivar custom: Indicates whether the information type is custom or not. + :vartype custom: bool + :ivar keywords: The information type keywords. + :vartype keywords: list[~azure.mgmt.security.models.InformationProtectionKeyword] + """ + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "order": {"key": "order", "type": "int"}, + "recommended_label_id": {"key": "recommendedLabelId", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "custom": {"key": "custom", "type": "bool"}, + "keywords": {"key": "keywords", "type": "[InformationProtectionKeyword]"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + order: Optional[int] = None, + recommended_label_id: Optional[str] = None, + enabled: Optional[bool] = None, + custom: Optional[bool] = None, + keywords: Optional[List["_models.InformationProtectionKeyword"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: The name of the information type. + :paramtype display_name: str + :keyword description: The description of the information type. + :paramtype description: str + :keyword order: The order of the information type. + :paramtype order: int + :keyword recommended_label_id: The recommended label id to be associated with this information + type. + :paramtype recommended_label_id: str + :keyword enabled: Indicates whether the information type is enabled or not. + :paramtype enabled: bool + :keyword custom: Indicates whether the information type is custom or not. + :paramtype custom: bool + :keyword keywords: The information type keywords. + :paramtype keywords: list[~azure.mgmt.security.models.InformationProtectionKeyword] + """ + super().__init__(**kwargs) + self.display_name = display_name + self.description = description + self.order = order + self.recommended_label_id = recommended_label_id + self.enabled = enabled + self.custom = custom + self.keywords = keywords + + +class InfoType(_serialization.Model): + """Custom user-defined information type. + + :ivar name: Display name of the info type. + :vartype name: str + :ivar id: Id of the info type. + :vartype id: str + :ivar description: Description of the info type. + :vartype description: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Display name of the info type. + :paramtype name: str + :keyword id: Id of the info type. + :paramtype id: str + :keyword description: Description of the info type. + :paramtype description: str + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.description = description + + +class InventoryList(_serialization.Model): + """Model for inventory to be included or excluded from Agentless. + + :ivar inventory_kind: Types for inventory kind. Known values are: "AzureDevOpsOrganization", + "AzureDevOpsProject", "AzureDevOpsRepository", "GitHubOwner", and "GitHubRepository". + :vartype inventory_kind: str or ~azure.mgmt.security.models.InventoryKind + :ivar value: Gets or sets the value for inventory type. + :vartype value: str + """ + + _attribute_map = { + "inventory_kind": {"key": "inventoryKind", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, + *, + inventory_kind: Optional[Union[str, "_models.InventoryKind"]] = None, + value: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword inventory_kind: Types for inventory kind. Known values are: "AzureDevOpsOrganization", + "AzureDevOpsProject", "AzureDevOpsRepository", "GitHubOwner", and "GitHubRepository". + :paramtype inventory_kind: str or ~azure.mgmt.security.models.InventoryKind + :keyword value: Gets or sets the value for inventory type. + :paramtype value: str + """ + super().__init__(**kwargs) + self.inventory_kind = inventory_kind + self.value = value + + +class TagsResource(_serialization.Model): + """A container holding only the Tags for a resource, allowing the user to update the tags. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class IoTSecurityAggregatedAlert(Resource, TagsResource): + """Security Solution Aggregated Alert information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar alert_type: Name of the alert type. + :vartype alert_type: str + :ivar alert_display_name: Display name of the alert type. + :vartype alert_display_name: str + :ivar aggregated_date_utc: Date of detection. + :vartype aggregated_date_utc: ~datetime.date + :ivar vendor_name: Name of the organization that raised the alert. + :vartype vendor_name: str + :ivar reported_severity: Assessed alert severity. Known values are: "Informational", "Low", + "Medium", and "High". + :vartype reported_severity: str or ~azure.mgmt.security.models.ReportedSeverity + :ivar remediation_steps: Recommended steps for remediation. + :vartype remediation_steps: str + :ivar description: Description of the suspected vulnerability and meaning. + :vartype description: str + :ivar count: Number of alerts occurrences within the aggregated time window. + :vartype count: int + :ivar effected_resource_type: Azure resource ID of the resource that received the alerts. + :vartype effected_resource_type: str + :ivar system_source: The type of the alerted resource (Azure, Non-Azure). + :vartype system_source: str + :ivar action_taken: IoT Security solution alert response. + :vartype action_taken: str + :ivar log_analytics_query: Log analytics query for getting the list of affected devices/alerts. + :vartype log_analytics_query: str + :ivar top_devices_list: 10 devices with the highest number of occurrences of this alert type, + on this day. + :vartype top_devices_list: + list[~azure.mgmt.security.models.IoTSecurityAggregatedAlertPropertiesTopDevicesListItem] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "alert_type": {"readonly": True}, + "alert_display_name": {"readonly": True}, + "aggregated_date_utc": {"readonly": True}, + "vendor_name": {"readonly": True}, + "reported_severity": {"readonly": True}, + "remediation_steps": {"readonly": True}, + "description": {"readonly": True}, + "count": {"readonly": True}, + "effected_resource_type": {"readonly": True}, + "system_source": {"readonly": True}, + "action_taken": {"readonly": True}, + "log_analytics_query": {"readonly": True}, + "top_devices_list": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "alert_display_name": {"key": "properties.alertDisplayName", "type": "str"}, + "aggregated_date_utc": {"key": "properties.aggregatedDateUtc", "type": "date"}, + "vendor_name": {"key": "properties.vendorName", "type": "str"}, + "reported_severity": {"key": "properties.reportedSeverity", "type": "str"}, + "remediation_steps": {"key": "properties.remediationSteps", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "count": {"key": "properties.count", "type": "int"}, + "effected_resource_type": {"key": "properties.effectedResourceType", "type": "str"}, + "system_source": {"key": "properties.systemSource", "type": "str"}, + "action_taken": {"key": "properties.actionTaken", "type": "str"}, + "log_analytics_query": {"key": "properties.logAnalyticsQuery", "type": "str"}, + "top_devices_list": { + "key": "properties.topDevicesList", + "type": "[IoTSecurityAggregatedAlertPropertiesTopDevicesListItem]", + }, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(tags=tags, **kwargs) + self.tags = tags + self.alert_type: Optional[str] = None + self.alert_display_name: Optional[str] = None + self.aggregated_date_utc: Optional[datetime.date] = None + self.vendor_name: Optional[str] = None + self.reported_severity: Optional[Union[str, "_models.ReportedSeverity"]] = None + self.remediation_steps: Optional[str] = None + self.description: Optional[str] = None + self.count: Optional[int] = None + self.effected_resource_type: Optional[str] = None + self.system_source: Optional[str] = None + self.action_taken: Optional[str] = None + self.log_analytics_query: Optional[str] = None + self.top_devices_list: Optional[List["_models.IoTSecurityAggregatedAlertPropertiesTopDevicesListItem"]] = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class IoTSecurityAggregatedAlertList(_serialization.Model): + """List of IoT Security solution aggregated alert data. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: List of aggregated alerts data. Required. + :vartype value: list[~azure.mgmt.security.models.IoTSecurityAggregatedAlert] + :ivar next_link: When there is too much alert data for one page, use this URI to fetch the next + page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IoTSecurityAggregatedAlert]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.IoTSecurityAggregatedAlert"], **kwargs: Any) -> None: + """ + :keyword value: List of aggregated alerts data. Required. + :paramtype value: list[~azure.mgmt.security.models.IoTSecurityAggregatedAlert] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class IoTSecurityAggregatedAlertPropertiesTopDevicesListItem(_serialization.Model): # pylint: disable=name-too-long + """IoTSecurityAggregatedAlertPropertiesTopDevicesListItem. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar device_id: Name of the device. + :vartype device_id: str + :ivar alerts_count: Number of alerts raised for this device. + :vartype alerts_count: int + :ivar last_occurrence: Most recent time this alert was raised for this device, on this day. + :vartype last_occurrence: str + """ + + _validation = { + "device_id": {"readonly": True}, + "alerts_count": {"readonly": True}, + "last_occurrence": {"readonly": True}, + } + + _attribute_map = { + "device_id": {"key": "deviceId", "type": "str"}, + "alerts_count": {"key": "alertsCount", "type": "int"}, + "last_occurrence": {"key": "lastOccurrence", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.device_id: Optional[str] = None + self.alerts_count: Optional[int] = None + self.last_occurrence: Optional[str] = None + + +class IoTSecurityAggregatedRecommendation(Resource, TagsResource): + """IoT Security solution recommendation information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar recommendation_name: Name of the recommendation. + :vartype recommendation_name: str + :ivar recommendation_display_name: Display name of the recommendation type. + :vartype recommendation_display_name: str + :ivar description: Description of the suspected vulnerability and meaning. + :vartype description: str + :ivar recommendation_type_id: Recommendation-type GUID. + :vartype recommendation_type_id: str + :ivar detected_by: Name of the organization that made the recommendation. + :vartype detected_by: str + :ivar remediation_steps: Recommended steps for remediation. + :vartype remediation_steps: str + :ivar reported_severity: Assessed recommendation severity. Known values are: "Informational", + "Low", "Medium", and "High". + :vartype reported_severity: str or ~azure.mgmt.security.models.ReportedSeverity + :ivar healthy_devices: Number of healthy devices within the IoT Security solution. + :vartype healthy_devices: int + :ivar unhealthy_device_count: Number of unhealthy devices within the IoT Security solution. + :vartype unhealthy_device_count: int + :ivar log_analytics_query: Log analytics query for getting the list of affected devices/alerts. + :vartype log_analytics_query: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "recommendation_display_name": {"readonly": True}, + "description": {"readonly": True}, + "recommendation_type_id": {"readonly": True}, + "detected_by": {"readonly": True}, + "remediation_steps": {"readonly": True}, + "reported_severity": {"readonly": True}, + "healthy_devices": {"readonly": True}, + "unhealthy_device_count": {"readonly": True}, + "log_analytics_query": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "recommendation_name": {"key": "properties.recommendationName", "type": "str"}, + "recommendation_display_name": {"key": "properties.recommendationDisplayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "recommendation_type_id": {"key": "properties.recommendationTypeId", "type": "str"}, + "detected_by": {"key": "properties.detectedBy", "type": "str"}, + "remediation_steps": {"key": "properties.remediationSteps", "type": "str"}, + "reported_severity": {"key": "properties.reportedSeverity", "type": "str"}, + "healthy_devices": {"key": "properties.healthyDevices", "type": "int"}, + "unhealthy_device_count": {"key": "properties.unhealthyDeviceCount", "type": "int"}, + "log_analytics_query": {"key": "properties.logAnalyticsQuery", "type": "str"}, + } + + def __init__( + self, *, tags: Optional[Dict[str, str]] = None, recommendation_name: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword recommendation_name: Name of the recommendation. + :paramtype recommendation_name: str + """ + super().__init__(tags=tags, **kwargs) + self.tags = tags + self.recommendation_name = recommendation_name + self.recommendation_display_name: Optional[str] = None + self.description: Optional[str] = None + self.recommendation_type_id: Optional[str] = None + self.detected_by: Optional[str] = None + self.remediation_steps: Optional[str] = None + self.reported_severity: Optional[Union[str, "_models.ReportedSeverity"]] = None + self.healthy_devices: Optional[int] = None + self.unhealthy_device_count: Optional[int] = None + self.log_analytics_query: Optional[str] = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class IoTSecurityAggregatedRecommendationList(_serialization.Model): + """List of IoT Security solution aggregated recommendations. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: List of aggregated recommendations data. Required. + :vartype value: list[~azure.mgmt.security.models.IoTSecurityAggregatedRecommendation] + :ivar next_link: When there is too much alert data for one page, use this URI to fetch the next + page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IoTSecurityAggregatedRecommendation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.IoTSecurityAggregatedRecommendation"], **kwargs: Any) -> None: + """ + :keyword value: List of aggregated recommendations data. Required. + :paramtype value: list[~azure.mgmt.security.models.IoTSecurityAggregatedRecommendation] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class IoTSecurityAlertedDevice(_serialization.Model): + """Statistical information about the number of alerts per device during last set number of days. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar device_id: Device identifier. + :vartype device_id: str + :ivar alerts_count: Number of alerts raised for this device. + :vartype alerts_count: int + """ + + _validation = { + "device_id": {"readonly": True}, + "alerts_count": {"readonly": True}, + } + + _attribute_map = { + "device_id": {"key": "deviceId", "type": "str"}, + "alerts_count": {"key": "alertsCount", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.device_id: Optional[str] = None + self.alerts_count: Optional[int] = None + + +class IoTSecurityDeviceAlert(_serialization.Model): + """Statistical information about the number of alerts per alert type during last set number of + days. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar alert_display_name: Display name of the alert. + :vartype alert_display_name: str + :ivar reported_severity: Assessed Alert severity. Known values are: "Informational", "Low", + "Medium", and "High". + :vartype reported_severity: str or ~azure.mgmt.security.models.ReportedSeverity + :ivar alerts_count: Number of alerts raised for this alert type. + :vartype alerts_count: int + """ + + _validation = { + "alert_display_name": {"readonly": True}, + "reported_severity": {"readonly": True}, + "alerts_count": {"readonly": True}, + } + + _attribute_map = { + "alert_display_name": {"key": "alertDisplayName", "type": "str"}, + "reported_severity": {"key": "reportedSeverity", "type": "str"}, + "alerts_count": {"key": "alertsCount", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.alert_display_name: Optional[str] = None + self.reported_severity: Optional[Union[str, "_models.ReportedSeverity"]] = None + self.alerts_count: Optional[int] = None + + +class IoTSecurityDeviceRecommendation(_serialization.Model): + """Statistical information about the number of recommendations per device, per recommendation + type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar recommendation_display_name: Display name of the recommendation. + :vartype recommendation_display_name: str + :ivar reported_severity: Assessed recommendation severity. Known values are: "Informational", + "Low", "Medium", and "High". + :vartype reported_severity: str or ~azure.mgmt.security.models.ReportedSeverity + :ivar devices_count: Number of devices with this recommendation. + :vartype devices_count: int + """ + + _validation = { + "recommendation_display_name": {"readonly": True}, + "reported_severity": {"readonly": True}, + "devices_count": {"readonly": True}, + } + + _attribute_map = { + "recommendation_display_name": {"key": "recommendationDisplayName", "type": "str"}, + "reported_severity": {"key": "reportedSeverity", "type": "str"}, + "devices_count": {"key": "devicesCount", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.recommendation_display_name: Optional[str] = None + self.reported_severity: Optional[Union[str, "_models.ReportedSeverity"]] = None + self.devices_count: Optional[int] = None + + +class IoTSecuritySolutionAnalyticsModel(Resource): + """Security analytics of your IoT Security solution. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar metrics: Security analytics of your IoT Security solution. + :vartype metrics: ~azure.mgmt.security.models.IoTSeverityMetrics + :ivar unhealthy_device_count: Number of unhealthy devices within your IoT Security solution. + :vartype unhealthy_device_count: int + :ivar devices_metrics: List of device metrics by the aggregation date. + :vartype devices_metrics: + list[~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem] + :ivar top_alerted_devices: List of the 3 devices with the most alerts. + :vartype top_alerted_devices: list[~azure.mgmt.security.models.IoTSecurityAlertedDevice] + :ivar most_prevalent_device_alerts: List of the 3 most prevalent device alerts. + :vartype most_prevalent_device_alerts: list[~azure.mgmt.security.models.IoTSecurityDeviceAlert] + :ivar most_prevalent_device_recommendations: List of the 3 most prevalent device + recommendations. + :vartype most_prevalent_device_recommendations: + list[~azure.mgmt.security.models.IoTSecurityDeviceRecommendation] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "metrics": {"readonly": True}, + "unhealthy_device_count": {"readonly": True}, + "devices_metrics": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "IoTSeverityMetrics"}, + "unhealthy_device_count": {"key": "properties.unhealthyDeviceCount", "type": "int"}, + "devices_metrics": { + "key": "properties.devicesMetrics", + "type": "[IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem]", + }, + "top_alerted_devices": {"key": "properties.topAlertedDevices", "type": "[IoTSecurityAlertedDevice]"}, + "most_prevalent_device_alerts": { + "key": "properties.mostPrevalentDeviceAlerts", + "type": "[IoTSecurityDeviceAlert]", + }, + "most_prevalent_device_recommendations": { + "key": "properties.mostPrevalentDeviceRecommendations", + "type": "[IoTSecurityDeviceRecommendation]", + }, + } + + def __init__( + self, + *, + top_alerted_devices: Optional[List["_models.IoTSecurityAlertedDevice"]] = None, + most_prevalent_device_alerts: Optional[List["_models.IoTSecurityDeviceAlert"]] = None, + most_prevalent_device_recommendations: Optional[List["_models.IoTSecurityDeviceRecommendation"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword top_alerted_devices: List of the 3 devices with the most alerts. + :paramtype top_alerted_devices: list[~azure.mgmt.security.models.IoTSecurityAlertedDevice] + :keyword most_prevalent_device_alerts: List of the 3 most prevalent device alerts. + :paramtype most_prevalent_device_alerts: + list[~azure.mgmt.security.models.IoTSecurityDeviceAlert] + :keyword most_prevalent_device_recommendations: List of the 3 most prevalent device + recommendations. + :paramtype most_prevalent_device_recommendations: + list[~azure.mgmt.security.models.IoTSecurityDeviceRecommendation] + """ + super().__init__(**kwargs) + self.metrics: Optional["_models.IoTSeverityMetrics"] = None + self.unhealthy_device_count: Optional[int] = None + self.devices_metrics: Optional[ + List["_models.IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem"] + ] = None + self.top_alerted_devices = top_alerted_devices + self.most_prevalent_device_alerts = most_prevalent_device_alerts + self.most_prevalent_device_recommendations = most_prevalent_device_recommendations + + +class IoTSecuritySolutionAnalyticsModelList(_serialization.Model): + """List of Security analytics of your IoT Security solution. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: List of Security analytics of your IoT Security solution. Required. + :vartype value: list[~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModel] + :ivar next_link: When there is too much alert data for one page, use this URI to fetch the next + page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IoTSecuritySolutionAnalyticsModel]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.IoTSecuritySolutionAnalyticsModel"], **kwargs: Any) -> None: + """ + :keyword value: List of Security analytics of your IoT Security solution. Required. + :paramtype value: list[~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModel] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem( + _serialization.Model +): # pylint: disable=name-too-long + """IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem. + + :ivar date: Aggregation of IoT Security solution device alert metrics by date. + :vartype date: ~datetime.datetime + :ivar devices_metrics: Device alert count by severity. + :vartype devices_metrics: ~azure.mgmt.security.models.IoTSeverityMetrics + """ + + _attribute_map = { + "date": {"key": "date", "type": "iso-8601"}, + "devices_metrics": {"key": "devicesMetrics", "type": "IoTSeverityMetrics"}, + } + + def __init__( + self, + *, + date: Optional[datetime.datetime] = None, + devices_metrics: Optional["_models.IoTSeverityMetrics"] = None, + **kwargs: Any + ) -> None: + """ + :keyword date: Aggregation of IoT Security solution device alert metrics by date. + :paramtype date: ~datetime.datetime + :keyword devices_metrics: Device alert count by severity. + :paramtype devices_metrics: ~azure.mgmt.security.models.IoTSeverityMetrics + """ + super().__init__(**kwargs) + self.date = date + self.devices_metrics = devices_metrics + + +class IoTSecuritySolutionModel(Resource, TagsResource): + """IoT Security solution configuration and resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: The resource location. + :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar workspace: Workspace resource ID. + :vartype workspace: str + :ivar display_name: Resource display name. + :vartype display_name: str + :ivar status: Status of the IoT Security solution. Known values are: "Enabled" and "Disabled". + :vartype status: str or ~azure.mgmt.security.models.SecuritySolutionStatus + :ivar export: List of additional options for exporting to workspace data. + :vartype export: list[str or ~azure.mgmt.security.models.ExportData] + :ivar disabled_data_sources: Disabled data sources. Disabling these data sources compromises + the system. + :vartype disabled_data_sources: list[str or ~azure.mgmt.security.models.DataSource] + :ivar iot_hubs: IoT Hub resource IDs. + :vartype iot_hubs: list[str] + :ivar user_defined_resources: Properties of the IoT Security solution's user defined resources. + :vartype user_defined_resources: ~azure.mgmt.security.models.UserDefinedResourcesProperties + :ivar auto_discovered_resources: List of resources that were automatically discovered as + relevant to the security solution. + :vartype auto_discovered_resources: list[str] + :ivar recommendations_configuration: List of the configuration status for each recommendation + type. + :vartype recommendations_configuration: + list[~azure.mgmt.security.models.RecommendationConfigurationProperties] + :ivar unmasked_ip_logging_status: Unmasked IP address logging status. Known values are: + "Disabled" and "Enabled". + :vartype unmasked_ip_logging_status: str or ~azure.mgmt.security.models.UnmaskedIpLoggingStatus + :ivar additional_workspaces: List of additional workspaces. + :vartype additional_workspaces: + list[~azure.mgmt.security.models.AdditionalWorkspacesProperties] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "auto_discovered_resources": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "workspace": {"key": "properties.workspace", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "export": {"key": "properties.export", "type": "[str]"}, + "disabled_data_sources": {"key": "properties.disabledDataSources", "type": "[str]"}, + "iot_hubs": {"key": "properties.iotHubs", "type": "[str]"}, + "user_defined_resources": {"key": "properties.userDefinedResources", "type": "UserDefinedResourcesProperties"}, + "auto_discovered_resources": {"key": "properties.autoDiscoveredResources", "type": "[str]"}, + "recommendations_configuration": { + "key": "properties.recommendationsConfiguration", + "type": "[RecommendationConfigurationProperties]", + }, + "unmasked_ip_logging_status": {"key": "properties.unmaskedIpLoggingStatus", "type": "str"}, + "additional_workspaces": {"key": "properties.additionalWorkspaces", "type": "[AdditionalWorkspacesProperties]"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + workspace: Optional[str] = None, + display_name: Optional[str] = None, + status: Union[str, "_models.SecuritySolutionStatus"] = "Enabled", + export: Optional[List[Union[str, "_models.ExportData"]]] = None, + disabled_data_sources: Optional[List[Union[str, "_models.DataSource"]]] = None, + iot_hubs: Optional[List[str]] = None, + user_defined_resources: Optional["_models.UserDefinedResourcesProperties"] = None, + recommendations_configuration: Optional[List["_models.RecommendationConfigurationProperties"]] = None, + unmasked_ip_logging_status: Union[str, "_models.UnmaskedIpLoggingStatus"] = "Disabled", + additional_workspaces: Optional[List["_models.AdditionalWorkspacesProperties"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The resource location. + :paramtype location: str + :keyword workspace: Workspace resource ID. + :paramtype workspace: str + :keyword display_name: Resource display name. + :paramtype display_name: str + :keyword status: Status of the IoT Security solution. Known values are: "Enabled" and + "Disabled". + :paramtype status: str or ~azure.mgmt.security.models.SecuritySolutionStatus + :keyword export: List of additional options for exporting to workspace data. + :paramtype export: list[str or ~azure.mgmt.security.models.ExportData] + :keyword disabled_data_sources: Disabled data sources. Disabling these data sources compromises + the system. + :paramtype disabled_data_sources: list[str or ~azure.mgmt.security.models.DataSource] + :keyword iot_hubs: IoT Hub resource IDs. + :paramtype iot_hubs: list[str] + :keyword user_defined_resources: Properties of the IoT Security solution's user defined + resources. + :paramtype user_defined_resources: ~azure.mgmt.security.models.UserDefinedResourcesProperties + :keyword recommendations_configuration: List of the configuration status for each + recommendation type. + :paramtype recommendations_configuration: + list[~azure.mgmt.security.models.RecommendationConfigurationProperties] + :keyword unmasked_ip_logging_status: Unmasked IP address logging status. Known values are: + "Disabled" and "Enabled". + :paramtype unmasked_ip_logging_status: str or + ~azure.mgmt.security.models.UnmaskedIpLoggingStatus + :keyword additional_workspaces: List of additional workspaces. + :paramtype additional_workspaces: + list[~azure.mgmt.security.models.AdditionalWorkspacesProperties] + """ + super().__init__(tags=tags, **kwargs) + self.tags = tags + self.location = location + self.system_data: Optional["_models.SystemData"] = None + self.workspace = workspace + self.display_name = display_name + self.status = status + self.export = export + self.disabled_data_sources = disabled_data_sources + self.iot_hubs = iot_hubs + self.user_defined_resources = user_defined_resources + self.auto_discovered_resources: Optional[List[str]] = None + self.recommendations_configuration = recommendations_configuration + self.unmasked_ip_logging_status = unmasked_ip_logging_status + self.additional_workspaces = additional_workspaces + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class IoTSecuritySolutionsList(_serialization.Model): + """List of IoT Security solutions. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: List of IoT Security solutions. Required. + :vartype value: list[~azure.mgmt.security.models.IoTSecuritySolutionModel] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IoTSecuritySolutionModel]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.IoTSecuritySolutionModel"], **kwargs: Any) -> None: + """ + :keyword value: List of IoT Security solutions. Required. + :paramtype value: list[~azure.mgmt.security.models.IoTSecuritySolutionModel] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class IoTSeverityMetrics(_serialization.Model): + """IoT Security solution analytics severity metrics. + + :ivar high: Count of high severity alerts/recommendations. + :vartype high: int + :ivar medium: Count of medium severity alerts/recommendations. + :vartype medium: int + :ivar low: Count of low severity alerts/recommendations. + :vartype low: int + """ + + _attribute_map = { + "high": {"key": "high", "type": "int"}, + "medium": {"key": "medium", "type": "int"}, + "low": {"key": "low", "type": "int"}, + } + + def __init__( + self, *, high: Optional[int] = None, medium: Optional[int] = None, low: Optional[int] = None, **kwargs: Any + ) -> None: + """ + :keyword high: Count of high severity alerts/recommendations. + :paramtype high: int + :keyword medium: Count of medium severity alerts/recommendations. + :paramtype medium: int + :keyword low: Count of low severity alerts/recommendations. + :paramtype low: int + """ + super().__init__(**kwargs) + self.high = high + self.medium = medium + self.low = low + + +class Issue(_serialization.Model): + """The issue that caused the resource to by unhealthy. + + All required parameters must be populated in order to send to server. + + :ivar issue_key: The unique issue key. Required. + :vartype issue_key: str + :ivar issue_name: The issue name. + :vartype issue_name: str + :ivar security_values: The affected security values that MDC offers that will be affected by + the issue, for example: recommendations, alerts, etc. + :vartype security_values: list[str] + :ivar issue_description: The issue description. + :vartype issue_description: str + :ivar remediation_steps: Human readable description of what you should do to mitigate this + health issue. + :vartype remediation_steps: str + :ivar remediation_script: The remediation script to solve this issue. + :vartype remediation_script: str + :ivar issue_additional_data: Additional data for the given issue. The additional data depends + on the issue type. + :vartype issue_additional_data: dict[str, str] + """ + + _validation = { + "issue_key": {"required": True}, + } + + _attribute_map = { + "issue_key": {"key": "issueKey", "type": "str"}, + "issue_name": {"key": "issueName", "type": "str"}, + "security_values": {"key": "securityValues", "type": "[str]"}, + "issue_description": {"key": "issueDescription", "type": "str"}, + "remediation_steps": {"key": "remediationSteps", "type": "str"}, + "remediation_script": {"key": "remediationScript", "type": "str"}, + "issue_additional_data": {"key": "issueAdditionalData", "type": "{str}"}, + } + + def __init__( + self, + *, + issue_key: str, + issue_name: Optional[str] = None, + security_values: Optional[List[str]] = None, + issue_description: Optional[str] = None, + remediation_steps: Optional[str] = None, + remediation_script: Optional[str] = None, + issue_additional_data: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword issue_key: The unique issue key. Required. + :paramtype issue_key: str + :keyword issue_name: The issue name. + :paramtype issue_name: str + :keyword security_values: The affected security values that MDC offers that will be affected by + the issue, for example: recommendations, alerts, etc. + :paramtype security_values: list[str] + :keyword issue_description: The issue description. + :paramtype issue_description: str + :keyword remediation_steps: Human readable description of what you should do to mitigate this + health issue. + :paramtype remediation_steps: str + :keyword remediation_script: The remediation script to solve this issue. + :paramtype remediation_script: str + :keyword issue_additional_data: Additional data for the given issue. The additional data + depends on the issue type. + :paramtype issue_additional_data: dict[str, str] + """ + super().__init__(**kwargs) + self.issue_key = issue_key + self.issue_name = issue_name + self.security_values = security_values + self.issue_description = issue_description + self.remediation_steps = remediation_steps + self.remediation_script = remediation_script + self.issue_additional_data = issue_additional_data + + +class JFrogEnvironmentData(EnvironmentData): + """The JFrog Artifactory connector environment data. + + All required parameters must be populated in order to send to server. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", "GitlabScope", + "DockerHubOrganization", and "JFrogArtifactory". + :vartype environment_type: str or ~azure.mgmt.security.models.EnvironmentType + :ivar scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :vartype scan_interval: int + """ + + _validation = { + "environment_type": {"required": True}, + "scan_interval": {"maximum": 24, "minimum": 1}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + "scan_interval": {"key": "scanInterval", "type": "int"}, + } + + def __init__(self, *, scan_interval: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :paramtype scan_interval: int + """ + super().__init__(**kwargs) + self.environment_type: str = "JFrogArtifactory" + self.scan_interval = scan_interval + + +class JitNetworkAccessPoliciesList(_serialization.Model): + """JitNetworkAccessPoliciesList. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.JitNetworkAccessPolicy] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[JitNetworkAccessPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.JitNetworkAccessPolicy"]] = None, **kwargs: Any) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.security.models.JitNetworkAccessPolicy] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class JitNetworkAccessPolicy(Resource, Kind, Location): + """JitNetworkAccessPolicy. + + 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 location: Location where the resource is stored. + :vartype location: str + :ivar kind: Kind of the resource. + :vartype kind: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar virtual_machines: Configurations for Microsoft.Compute/virtualMachines resource type. + Required. + :vartype virtual_machines: + list[~azure.mgmt.security.models.JitNetworkAccessPolicyVirtualMachine] + :ivar requests: + :vartype requests: list[~azure.mgmt.security.models.JitNetworkAccessRequest] + :ivar provisioning_state: Gets the provisioning state of the Just-in-Time policy. + :vartype provisioning_state: str + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "virtual_machines": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "virtual_machines": {"key": "properties.virtualMachines", "type": "[JitNetworkAccessPolicyVirtualMachine]"}, + "requests": {"key": "properties.requests", "type": "[JitNetworkAccessRequest]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + virtual_machines: List["_models.JitNetworkAccessPolicyVirtualMachine"], + kind: Optional[str] = None, + requests: Optional[List["_models.JitNetworkAccessRequest"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword kind: Kind of the resource. + :paramtype kind: str + :keyword virtual_machines: Configurations for Microsoft.Compute/virtualMachines resource type. + Required. + :paramtype virtual_machines: + list[~azure.mgmt.security.models.JitNetworkAccessPolicyVirtualMachine] + :keyword requests: + :paramtype requests: list[~azure.mgmt.security.models.JitNetworkAccessRequest] + """ + super().__init__(kind=kind, **kwargs) + self.location: Optional[str] = None + self.kind = kind + self.virtual_machines = virtual_machines + self.requests = requests + self.provisioning_state: Optional[str] = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class JitNetworkAccessPolicyInitiatePort(_serialization.Model): + """JitNetworkAccessPolicyInitiatePort. + + All required parameters must be populated in order to send to server. + + :ivar number: Required. + :vartype number: int + :ivar allowed_source_address_prefix: Source of the allowed traffic. If omitted, the request + will be for the source IP address of the initiate request. + :vartype allowed_source_address_prefix: str + :ivar end_time_utc: The time to close the request in UTC. Required. + :vartype end_time_utc: ~datetime.datetime + """ + + _validation = { + "number": {"required": True, "maximum": 65535, "minimum": 0}, + "end_time_utc": {"required": True}, + } + + _attribute_map = { + "number": {"key": "number", "type": "int"}, + "allowed_source_address_prefix": {"key": "allowedSourceAddressPrefix", "type": "str"}, + "end_time_utc": {"key": "endTimeUtc", "type": "iso-8601"}, + } + + def __init__( + self, + *, + number: int, + end_time_utc: datetime.datetime, + allowed_source_address_prefix: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword number: Required. + :paramtype number: int + :keyword allowed_source_address_prefix: Source of the allowed traffic. If omitted, the request + will be for the source IP address of the initiate request. + :paramtype allowed_source_address_prefix: str + :keyword end_time_utc: The time to close the request in UTC. Required. + :paramtype end_time_utc: ~datetime.datetime + """ + super().__init__(**kwargs) + self.number = number + self.allowed_source_address_prefix = allowed_source_address_prefix + self.end_time_utc = end_time_utc + + +class JitNetworkAccessPolicyInitiateRequest(_serialization.Model): + """JitNetworkAccessPolicyInitiateRequest. + + All required parameters must be populated in order to send to server. + + :ivar virtual_machines: A list of virtual machines & ports to open access for. Required. + :vartype virtual_machines: + list[~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateVirtualMachine] + :ivar justification: The justification for making the initiate request. + :vartype justification: str + """ + + _validation = { + "virtual_machines": {"required": True}, + } + + _attribute_map = { + "virtual_machines": {"key": "virtualMachines", "type": "[JitNetworkAccessPolicyInitiateVirtualMachine]"}, + "justification": {"key": "justification", "type": "str"}, + } + + def __init__( + self, + *, + virtual_machines: List["_models.JitNetworkAccessPolicyInitiateVirtualMachine"], + justification: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword virtual_machines: A list of virtual machines & ports to open access for. Required. + :paramtype virtual_machines: + list[~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateVirtualMachine] + :keyword justification: The justification for making the initiate request. + :paramtype justification: str + """ + super().__init__(**kwargs) + self.virtual_machines = virtual_machines + self.justification = justification + + +class JitNetworkAccessPolicyInitiateVirtualMachine(_serialization.Model): # pylint: disable=name-too-long + """JitNetworkAccessPolicyInitiateVirtualMachine. + + All required parameters must be populated in order to send to server. + + :ivar id: Resource ID of the virtual machine that is linked to this policy. Required. + :vartype id: str + :ivar ports: The ports to open for the resource with the ``id``. Required. + :vartype ports: list[~azure.mgmt.security.models.JitNetworkAccessPolicyInitiatePort] + """ + + _validation = { + "id": {"required": True}, + "ports": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "ports": {"key": "ports", "type": "[JitNetworkAccessPolicyInitiatePort]"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + ports: List["_models.JitNetworkAccessPolicyInitiatePort"], + **kwargs: Any + ) -> None: + """ + :keyword id: Resource ID of the virtual machine that is linked to this policy. Required. + :paramtype id: str + :keyword ports: The ports to open for the resource with the ``id``. Required. + :paramtype ports: list[~azure.mgmt.security.models.JitNetworkAccessPolicyInitiatePort] + """ + super().__init__(**kwargs) + self.id = id + self.ports = ports + + +class JitNetworkAccessPolicyVirtualMachine(_serialization.Model): + """JitNetworkAccessPolicyVirtualMachine. + + All required parameters must be populated in order to send to server. + + :ivar id: Resource ID of the virtual machine that is linked to this policy. Required. + :vartype id: str + :ivar ports: Port configurations for the virtual machine. Required. + :vartype ports: list[~azure.mgmt.security.models.JitNetworkAccessPortRule] + :ivar public_ip_address: Public IP address of the Azure Firewall that is linked to this policy, + if applicable. + :vartype public_ip_address: str + """ + + _validation = { + "id": {"required": True}, + "ports": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "ports": {"key": "ports", "type": "[JitNetworkAccessPortRule]"}, + "public_ip_address": {"key": "publicIpAddress", "type": "str"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + ports: List["_models.JitNetworkAccessPortRule"], + public_ip_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Resource ID of the virtual machine that is linked to this policy. Required. + :paramtype id: str + :keyword ports: Port configurations for the virtual machine. Required. + :paramtype ports: list[~azure.mgmt.security.models.JitNetworkAccessPortRule] + :keyword public_ip_address: Public IP address of the Azure Firewall that is linked to this + policy, if applicable. + :paramtype public_ip_address: str + """ + super().__init__(**kwargs) + self.id = id + self.ports = ports + self.public_ip_address = public_ip_address + + +class JitNetworkAccessPortRule(_serialization.Model): + """JitNetworkAccessPortRule. + + All required parameters must be populated in order to send to server. + + :ivar number: Required. + :vartype number: int + :ivar protocol: Required. Known values are: "TCP", "UDP", and "*". + :vartype protocol: str or ~azure.mgmt.security.models.ProtocolEnum + :ivar allowed_source_address_prefix: Mutually exclusive with the "allowedSourceAddressPrefixes" + parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16". + :vartype allowed_source_address_prefix: str + :ivar allowed_source_address_prefixes: Mutually exclusive with the "allowedSourceAddressPrefix" + parameter. + :vartype allowed_source_address_prefixes: list[str] + :ivar max_request_access_duration: Maximum duration requests can be made for. In ISO 8601 + duration format. Minimum 5 minutes, maximum 1 day. Required. + :vartype max_request_access_duration: str + """ + + _validation = { + "number": {"required": True, "maximum": 65535, "minimum": 0}, + "protocol": {"required": True}, + "max_request_access_duration": {"required": True}, + } + + _attribute_map = { + "number": {"key": "number", "type": "int"}, + "protocol": {"key": "protocol", "type": "str"}, + "allowed_source_address_prefix": {"key": "allowedSourceAddressPrefix", "type": "str"}, + "allowed_source_address_prefixes": {"key": "allowedSourceAddressPrefixes", "type": "[str]"}, + "max_request_access_duration": {"key": "maxRequestAccessDuration", "type": "str"}, + } + + def __init__( + self, + *, + number: int, + protocol: Union[str, "_models.ProtocolEnum"], + max_request_access_duration: str, + allowed_source_address_prefix: Optional[str] = None, + allowed_source_address_prefixes: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword number: Required. + :paramtype number: int + :keyword protocol: Required. Known values are: "TCP", "UDP", and "*". + :paramtype protocol: str or ~azure.mgmt.security.models.ProtocolEnum + :keyword allowed_source_address_prefix: Mutually exclusive with the + "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for example + "192.168.0.3" or "192.168.0.0/16". + :paramtype allowed_source_address_prefix: str + :keyword allowed_source_address_prefixes: Mutually exclusive with the + "allowedSourceAddressPrefix" parameter. + :paramtype allowed_source_address_prefixes: list[str] + :keyword max_request_access_duration: Maximum duration requests can be made for. In ISO 8601 + duration format. Minimum 5 minutes, maximum 1 day. Required. + :paramtype max_request_access_duration: str + """ + super().__init__(**kwargs) + self.number = number + self.protocol = protocol + self.allowed_source_address_prefix = allowed_source_address_prefix + self.allowed_source_address_prefixes = allowed_source_address_prefixes + self.max_request_access_duration = max_request_access_duration + + +class JitNetworkAccessRequest(_serialization.Model): + """JitNetworkAccessRequest. + + All required parameters must be populated in order to send to server. + + :ivar virtual_machines: Required. + :vartype virtual_machines: + list[~azure.mgmt.security.models.JitNetworkAccessRequestVirtualMachine] + :ivar start_time_utc: The start time of the request in UTC. Required. + :vartype start_time_utc: ~datetime.datetime + :ivar requestor: The identity of the person who made the request. Required. + :vartype requestor: str + :ivar justification: The justification for making the initiate request. + :vartype justification: str + """ + + _validation = { + "virtual_machines": {"required": True}, + "start_time_utc": {"required": True}, + "requestor": {"required": True}, + } + + _attribute_map = { + "virtual_machines": {"key": "virtualMachines", "type": "[JitNetworkAccessRequestVirtualMachine]"}, + "start_time_utc": {"key": "startTimeUtc", "type": "iso-8601"}, + "requestor": {"key": "requestor", "type": "str"}, + "justification": {"key": "justification", "type": "str"}, + } + + def __init__( + self, + *, + virtual_machines: List["_models.JitNetworkAccessRequestVirtualMachine"], + start_time_utc: datetime.datetime, + requestor: str, + justification: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword virtual_machines: Required. + :paramtype virtual_machines: + list[~azure.mgmt.security.models.JitNetworkAccessRequestVirtualMachine] + :keyword start_time_utc: The start time of the request in UTC. Required. + :paramtype start_time_utc: ~datetime.datetime + :keyword requestor: The identity of the person who made the request. Required. + :paramtype requestor: str + :keyword justification: The justification for making the initiate request. + :paramtype justification: str + """ + super().__init__(**kwargs) + self.virtual_machines = virtual_machines + self.start_time_utc = start_time_utc + self.requestor = requestor + self.justification = justification + + +class JitNetworkAccessRequestPort(_serialization.Model): + """JitNetworkAccessRequestPort. + + All required parameters must be populated in order to send to server. + + :ivar number: Required. + :vartype number: int + :ivar allowed_source_address_prefix: Mutually exclusive with the "allowedSourceAddressPrefixes" + parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16". + :vartype allowed_source_address_prefix: str + :ivar allowed_source_address_prefixes: Mutually exclusive with the "allowedSourceAddressPrefix" + parameter. + :vartype allowed_source_address_prefixes: list[str] + :ivar end_time_utc: The date & time at which the request ends in UTC. Required. + :vartype end_time_utc: ~datetime.datetime + :ivar status: The status of the port. Required. Known values are: "Revoked" and "Initiated". + :vartype status: str or ~azure.mgmt.security.models.Status + :ivar status_reason: A description of why the ``status`` has its value. Required. Known values + are: "Expired", "UserRequested", and "NewerRequestInitiated". + :vartype status_reason: str or ~azure.mgmt.security.models.StatusReason + :ivar mapped_port: The port which is mapped to this port's ``number`` in the Azure Firewall, if + applicable. + :vartype mapped_port: int + """ + + _validation = { + "number": {"required": True, "maximum": 65535, "minimum": 0}, + "end_time_utc": {"required": True}, + "status": {"required": True}, + "status_reason": {"required": True}, + } + + _attribute_map = { + "number": {"key": "number", "type": "int"}, + "allowed_source_address_prefix": {"key": "allowedSourceAddressPrefix", "type": "str"}, + "allowed_source_address_prefixes": {"key": "allowedSourceAddressPrefixes", "type": "[str]"}, + "end_time_utc": {"key": "endTimeUtc", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + "status_reason": {"key": "statusReason", "type": "str"}, + "mapped_port": {"key": "mappedPort", "type": "int"}, + } + + def __init__( + self, + *, + number: int, + end_time_utc: datetime.datetime, + status: Union[str, "_models.Status"], + status_reason: Union[str, "_models.StatusReason"], + allowed_source_address_prefix: Optional[str] = None, + allowed_source_address_prefixes: Optional[List[str]] = None, + mapped_port: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword number: Required. + :paramtype number: int + :keyword allowed_source_address_prefix: Mutually exclusive with the + "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for example + "192.168.0.3" or "192.168.0.0/16". + :paramtype allowed_source_address_prefix: str + :keyword allowed_source_address_prefixes: Mutually exclusive with the + "allowedSourceAddressPrefix" parameter. + :paramtype allowed_source_address_prefixes: list[str] + :keyword end_time_utc: The date & time at which the request ends in UTC. Required. + :paramtype end_time_utc: ~datetime.datetime + :keyword status: The status of the port. Required. Known values are: "Revoked" and "Initiated". + :paramtype status: str or ~azure.mgmt.security.models.Status + :keyword status_reason: A description of why the ``status`` has its value. Required. Known + values are: "Expired", "UserRequested", and "NewerRequestInitiated". + :paramtype status_reason: str or ~azure.mgmt.security.models.StatusReason + :keyword mapped_port: The port which is mapped to this port's ``number`` in the Azure Firewall, + if applicable. + :paramtype mapped_port: int + """ + super().__init__(**kwargs) + self.number = number + self.allowed_source_address_prefix = allowed_source_address_prefix + self.allowed_source_address_prefixes = allowed_source_address_prefixes + self.end_time_utc = end_time_utc + self.status = status + self.status_reason = status_reason + self.mapped_port = mapped_port + + +class JitNetworkAccessRequestVirtualMachine(_serialization.Model): + """JitNetworkAccessRequestVirtualMachine. + + All required parameters must be populated in order to send to server. + + :ivar id: Resource ID of the virtual machine that is linked to this policy. Required. + :vartype id: str + :ivar ports: The ports that were opened for the virtual machine. Required. + :vartype ports: list[~azure.mgmt.security.models.JitNetworkAccessRequestPort] + """ + + _validation = { + "id": {"required": True}, + "ports": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "ports": {"key": "ports", "type": "[JitNetworkAccessRequestPort]"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + ports: List["_models.JitNetworkAccessRequestPort"], + **kwargs: Any + ) -> None: + """ + :keyword id: Resource ID of the virtual machine that is linked to this policy. Required. + :paramtype id: str + :keyword ports: The ports that were opened for the virtual machine. Required. + :paramtype ports: list[~azure.mgmt.security.models.JitNetworkAccessRequestPort] + """ + super().__init__(**kwargs) + self.id = id + self.ports = ports + + +class Label(_serialization.Model): + """Microsoft information protection sensitivity label. + + :ivar name: The display name of the label. + :vartype name: str + :ivar id: The ID of the label. + :vartype id: str + :ivar order: Labels are ordered by sensitivity level. The higher the order of the label, the + more sensitive it is. + :vartype order: float + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "order": {"key": "order", "type": "float"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + order: Optional[float] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The display name of the label. + :paramtype name: str + :keyword id: The ID of the label. + :paramtype id: str + :keyword order: Labels are ordered by sensitivity level. The higher the order of the label, the + more sensitive it is. + :paramtype order: float + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.order = order + + +class LocalUserNotAllowed(AllowlistCustomAlertRule): + """Login by a local user that isn't allowed. Allow list consists of login names to allow. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and + "String". + :vartype value_type: str or ~azure.mgmt.security.models.ValueType + :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. + Required. + :vartype allowlist_values: list[str] + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "value_type": {"readonly": True}, + "allowlist_values": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "value_type": {"key": "valueType", "type": "str"}, + "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, + } + + def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword allowlist_values: The values to allow. The format of the values depends on the rule + type. Required. + :paramtype allowlist_values: list[str] + """ + super().__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) + self.rule_type: str = "LocalUserNotAllowed" + + +class LogAnalyticsIdentifier(ResourceIdentifier): + """Represents a Log Analytics workspace scope identifier. + + 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 type: There can be multiple identifiers of different type per alert, this field specify + the identifier type. Required. Known values are: "AzureResource" and "LogAnalytics". + :vartype type: str or ~azure.mgmt.security.models.ResourceIdentifierType + :ivar workspace_id: The LogAnalytics workspace id that stores this alert. + :vartype workspace_id: str + :ivar workspace_subscription_id: The azure subscription id for the LogAnalytics workspace + storing this alert. + :vartype workspace_subscription_id: str + :ivar workspace_resource_group: The azure resource group for the LogAnalytics workspace storing + this alert. + :vartype workspace_resource_group: str + :ivar agent_id: (optional) The LogAnalytics agent id reporting the event that this alert is + based on. + :vartype agent_id: str + """ + + _validation = { + "type": {"required": True}, + "workspace_id": {"readonly": True}, + "workspace_subscription_id": { + "readonly": True, + "pattern": r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + }, + "workspace_resource_group": {"readonly": True}, + "agent_id": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "workspace_subscription_id": {"key": "workspaceSubscriptionId", "type": "str"}, + "workspace_resource_group": {"key": "workspaceResourceGroup", "type": "str"}, + "agent_id": {"key": "agentId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: str = "LogAnalytics" + self.workspace_id: Optional[str] = None + self.workspace_subscription_id: Optional[str] = None + self.workspace_resource_group: Optional[str] = None + self.agent_id: Optional[str] = None + + +class MalwareScan(_serialization.Model): + """Describes the state of a malware scan operation. + + :ivar properties: + :vartype properties: ~azure.mgmt.security.models.MalwareScanProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "MalwareScanProperties"}, + } + + def __init__(self, *, properties: Optional["_models.MalwareScanProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: + :paramtype properties: ~azure.mgmt.security.models.MalwareScanProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class MalwareScanningProperties(_serialization.Model): + """Properties of Malware Scanning. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar on_upload: Properties of On Upload malware scanning. + :vartype on_upload: ~azure.mgmt.security.models.OnUploadProperties + :ivar scan_results_event_grid_topic_resource_id: Optional. Resource id of an Event Grid Topic + to send scan results to. + :vartype scan_results_event_grid_topic_resource_id: str + :ivar blob_scan_results_options: Optional. Write scan result on blobIndexTags by default. Known + values are: "blobIndexTags" and "None". + :vartype blob_scan_results_options: str or ~azure.mgmt.security.models.BlobScanResultsOptions + :ivar operation_status: Upon failure or partial success. Additional data describing Malware + Scanning enable/disable operation. + :vartype operation_status: ~azure.mgmt.security.models.OperationStatus + """ + + _validation = { + "operation_status": {"readonly": True}, + } + + _attribute_map = { + "on_upload": {"key": "onUpload", "type": "OnUploadProperties"}, + "scan_results_event_grid_topic_resource_id": {"key": "scanResultsEventGridTopicResourceId", "type": "str"}, + "blob_scan_results_options": {"key": "blobScanResultsOptions", "type": "str"}, + "operation_status": {"key": "operationStatus", "type": "OperationStatus"}, + } + + def __init__( + self, + *, + on_upload: Optional["_models.OnUploadProperties"] = None, + scan_results_event_grid_topic_resource_id: Optional[str] = None, + blob_scan_results_options: Optional[Union[str, "_models.BlobScanResultsOptions"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword on_upload: Properties of On Upload malware scanning. + :paramtype on_upload: ~azure.mgmt.security.models.OnUploadProperties + :keyword scan_results_event_grid_topic_resource_id: Optional. Resource id of an Event Grid + Topic to send scan results to. + :paramtype scan_results_event_grid_topic_resource_id: str + :keyword blob_scan_results_options: Optional. Write scan result on blobIndexTags by default. + Known values are: "blobIndexTags" and "None". + :paramtype blob_scan_results_options: str or ~azure.mgmt.security.models.BlobScanResultsOptions + """ + super().__init__(**kwargs) + self.on_upload = on_upload + self.scan_results_event_grid_topic_resource_id = scan_results_event_grid_topic_resource_id + self.blob_scan_results_options = blob_scan_results_options + self.operation_status: Optional["_models.OperationStatus"] = None + + +class MalwareScanProperties(_serialization.Model): + """MalwareScanProperties. + + :ivar scan_id: The identifier of the scan. + :vartype scan_id: str + :ivar scan_status: A status code of the scan operation. + :vartype scan_status: str + :ivar scan_status_message: A description of the status of the scan. + :vartype scan_status_message: str + :ivar scan_start_time: The time at which the scan had been initiated. + :vartype scan_start_time: str + :ivar scan_end_time: The time at which the scan has ended. Only available for a scan which has + terminated. + :vartype scan_end_time: str + :ivar scan_summary: A summary of the scan results. + :vartype scan_summary: ~azure.mgmt.security.models.ScanSummary + """ + + _attribute_map = { + "scan_id": {"key": "scanId", "type": "str"}, + "scan_status": {"key": "scanStatus", "type": "str"}, + "scan_status_message": {"key": "scanStatusMessage", "type": "str"}, + "scan_start_time": {"key": "scanStartTime", "type": "str"}, + "scan_end_time": {"key": "scanEndTime", "type": "str"}, + "scan_summary": {"key": "scanSummary", "type": "ScanSummary"}, + } + + def __init__( + self, + *, + scan_id: Optional[str] = None, + scan_status: Optional[str] = None, + scan_status_message: Optional[str] = None, + scan_start_time: Optional[str] = None, + scan_end_time: Optional[str] = None, + scan_summary: Optional["_models.ScanSummary"] = None, + **kwargs: Any + ) -> None: + """ + :keyword scan_id: The identifier of the scan. + :paramtype scan_id: str + :keyword scan_status: A status code of the scan operation. + :paramtype scan_status: str + :keyword scan_status_message: A description of the status of the scan. + :paramtype scan_status_message: str + :keyword scan_start_time: The time at which the scan had been initiated. + :paramtype scan_start_time: str + :keyword scan_end_time: The time at which the scan has ended. Only available for a scan which + has terminated. + :paramtype scan_end_time: str + :keyword scan_summary: A summary of the scan results. + :paramtype scan_summary: ~azure.mgmt.security.models.ScanSummary + """ + super().__init__(**kwargs) + self.scan_id = scan_id + self.scan_status = scan_status + self.scan_status_message = scan_status_message + self.scan_start_time = scan_start_time + self.scan_end_time = scan_end_time + self.scan_summary = scan_summary + + +class MdeOnboardingData(Resource): + """The resource of the configuration or data needed to onboard the machine to MDE. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar onboarding_package_windows: The onboarding package used to onboard Windows machines to + MDE, coded in base64. This can also be used for onboarding using the dedicated VM Extension. + :vartype onboarding_package_windows: bytes + :ivar onboarding_package_linux: The onboarding package used to onboard Linux machines to MDE, + coded in base64. This can also be used for onboarding using the dedicated VM Extension. + :vartype onboarding_package_linux: bytes + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "onboarding_package_windows": {"key": "properties.onboardingPackageWindows", "type": "bytearray"}, + "onboarding_package_linux": {"key": "properties.onboardingPackageLinux", "type": "bytearray"}, + } + + def __init__( + self, + *, + onboarding_package_windows: Optional[bytes] = None, + onboarding_package_linux: Optional[bytes] = None, + **kwargs: Any + ) -> None: + """ + :keyword onboarding_package_windows: The onboarding package used to onboard Windows machines to + MDE, coded in base64. This can also be used for onboarding using the dedicated VM Extension. + :paramtype onboarding_package_windows: bytes + :keyword onboarding_package_linux: The onboarding package used to onboard Linux machines to + MDE, coded in base64. This can also be used for onboarding using the dedicated VM Extension. + :paramtype onboarding_package_linux: bytes + """ + super().__init__(**kwargs) + self.onboarding_package_windows = onboarding_package_windows + self.onboarding_package_linux = onboarding_package_linux + + +class MdeOnboardingDataList(_serialization.Model): + """List of all MDE onboarding data resources. + + :ivar value: List of the resources of the configuration or data needed to onboard the machine + to MDE. + :vartype value: list[~azure.mgmt.security.models.MdeOnboardingData] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[MdeOnboardingData]"}, + } + + def __init__(self, *, value: Optional[List["_models.MdeOnboardingData"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of the resources of the configuration or data needed to onboard the + machine to MDE. + :paramtype value: list[~azure.mgmt.security.models.MdeOnboardingData] + """ + super().__init__(**kwargs) + self.value = value + + +class MqttC2DMessagesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of cloud to device messages (MQTT protocol) is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "MqttC2DMessagesNotInAllowedRange" + + +class MqttC2DRejectedMessagesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of rejected cloud to device messages (MQTT protocol) is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "MqttC2DRejectedMessagesNotInAllowedRange" + + +class MqttD2CMessagesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of device to cloud messages (MQTT protocol) is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "MqttD2CMessagesNotInAllowedRange" + + +class NodeIdentifier(_serialization.Model): + """Represents a node in the path. + + All required parameters must be populated in order to send to server. + + :ivar id: The unique identifier of the node. Required. + :vartype id: str + :ivar type: The type of the node. Required. + :vartype type: str + """ + + _validation = { + "id": {"required": True}, + "type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, id: str, type: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: The unique identifier of the node. Required. + :paramtype id: str + :keyword type: The type of the node. Required. + :paramtype type: str + """ + super().__init__(**kwargs) + self.id = id + self.type = type + + +class NotificationsSource(_serialization.Model): + """A valid notification source type. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + NotificationsSourceAlert, NotificationsSourceAttackPath + + All required parameters must be populated in order to send to server. + + :ivar source_type: The source type that will trigger the notification. Required. Known values + are: "Alert" and "AttackPath". + :vartype source_type: str or ~azure.mgmt.security.models.SourceType + """ + + _validation = { + "source_type": {"required": True}, + } + + _attribute_map = { + "source_type": {"key": "sourceType", "type": "str"}, + } + + _subtype_map = {"source_type": {"Alert": "NotificationsSourceAlert", "AttackPath": "NotificationsSourceAttackPath"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.source_type: Optional[str] = None + + +class NotificationsSourceAlert(NotificationsSource): + """Alert notification source. + + All required parameters must be populated in order to send to server. + + :ivar source_type: The source type that will trigger the notification. Required. Known values + are: "Alert" and "AttackPath". + :vartype source_type: str or ~azure.mgmt.security.models.SourceType + :ivar minimal_severity: Defines the minimal alert severity which will be sent as email + notifications. Known values are: "High", "Medium", and "Low". + :vartype minimal_severity: str or ~azure.mgmt.security.models.MinimalSeverity + """ + + _validation = { + "source_type": {"required": True}, + } + + _attribute_map = { + "source_type": {"key": "sourceType", "type": "str"}, + "minimal_severity": {"key": "minimalSeverity", "type": "str"}, + } + + def __init__( + self, *, minimal_severity: Optional[Union[str, "_models.MinimalSeverity"]] = None, **kwargs: Any + ) -> None: + """ + :keyword minimal_severity: Defines the minimal alert severity which will be sent as email + notifications. Known values are: "High", "Medium", and "Low". + :paramtype minimal_severity: str or ~azure.mgmt.security.models.MinimalSeverity + """ + super().__init__(**kwargs) + self.source_type: str = "Alert" + self.minimal_severity = minimal_severity + + +class NotificationsSourceAttackPath(NotificationsSource): + """Attack path notification source. + + All required parameters must be populated in order to send to server. + + :ivar source_type: The source type that will trigger the notification. Required. Known values + are: "Alert" and "AttackPath". + :vartype source_type: str or ~azure.mgmt.security.models.SourceType + :ivar minimal_risk_level: Defines the minimal attach path risk level which will be sent as + email notifications. Known values are: "Critical", "High", "Medium", and "Low". + :vartype minimal_risk_level: str or ~azure.mgmt.security.models.MinimalRiskLevel + """ + + _validation = { + "source_type": {"required": True}, + } + + _attribute_map = { + "source_type": {"key": "sourceType", "type": "str"}, + "minimal_risk_level": {"key": "minimalRiskLevel", "type": "str"}, + } + + def __init__( + self, *, minimal_risk_level: Optional[Union[str, "_models.MinimalRiskLevel"]] = None, **kwargs: Any + ) -> None: + """ + :keyword minimal_risk_level: Defines the minimal attach path risk level which will be sent as + email notifications. Known values are: "Critical", "High", "Medium", and "Low". + :paramtype minimal_risk_level: str or ~azure.mgmt.security.models.MinimalRiskLevel + """ + super().__init__(**kwargs) + self.source_type: str = "AttackPath" + self.minimal_risk_level = minimal_risk_level + + +class OnPremiseResourceDetails(ResourceDetails): + """Details of the On Premise resource that was assessed. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + OnPremiseSqlResourceDetails + + All required parameters must be populated in order to send to server. + + :ivar source: The platform where the assessed resource resides. Required. Known values are: + "Azure", "OnPremise", and "OnPremiseSql". + :vartype source: str or ~azure.mgmt.security.models.Source + :ivar workspace_id: Azure resource Id of the workspace the machine is attached to. Required. + :vartype workspace_id: str + :ivar vmuuid: The unique Id of the machine. Required. + :vartype vmuuid: str + :ivar source_computer_id: The oms agent Id installed on the machine. Required. + :vartype source_computer_id: str + :ivar machine_name: The name of the machine. Required. + :vartype machine_name: str + """ + + _validation = { + "source": {"required": True}, + "workspace_id": {"required": True}, + "vmuuid": {"required": True}, + "source_computer_id": {"required": True}, + "machine_name": {"required": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "vmuuid": {"key": "vmuuid", "type": "str"}, + "source_computer_id": {"key": "sourceComputerId", "type": "str"}, + "machine_name": {"key": "machineName", "type": "str"}, + } + + _subtype_map = {"source": {"OnPremiseSql": "OnPremiseSqlResourceDetails"}} + + def __init__( + self, *, workspace_id: str, vmuuid: str, source_computer_id: str, machine_name: str, **kwargs: Any + ) -> None: + """ + :keyword workspace_id: Azure resource Id of the workspace the machine is attached to. Required. + :paramtype workspace_id: str + :keyword vmuuid: The unique Id of the machine. Required. + :paramtype vmuuid: str + :keyword source_computer_id: The oms agent Id installed on the machine. Required. + :paramtype source_computer_id: str + :keyword machine_name: The name of the machine. Required. + :paramtype machine_name: str + """ + super().__init__(**kwargs) + self.source: str = "OnPremise" + self.workspace_id = workspace_id + self.vmuuid = vmuuid + self.source_computer_id = source_computer_id + self.machine_name = machine_name + + +class OnPremiseSqlResourceDetails(OnPremiseResourceDetails): + """Details of the On Premise Sql resource that was assessed. + + All required parameters must be populated in order to send to server. + + :ivar source: The platform where the assessed resource resides. Required. Known values are: + "Azure", "OnPremise", and "OnPremiseSql". + :vartype source: str or ~azure.mgmt.security.models.Source + :ivar workspace_id: Azure resource Id of the workspace the machine is attached to. Required. + :vartype workspace_id: str + :ivar vmuuid: The unique Id of the machine. Required. + :vartype vmuuid: str + :ivar source_computer_id: The oms agent Id installed on the machine. Required. + :vartype source_computer_id: str + :ivar machine_name: The name of the machine. Required. + :vartype machine_name: str + :ivar server_name: The Sql server name installed on the machine. Required. + :vartype server_name: str + :ivar database_name: The Sql database name installed on the machine. Required. + :vartype database_name: str + """ + + _validation = { + "source": {"required": True}, + "workspace_id": {"required": True}, + "vmuuid": {"required": True}, + "source_computer_id": {"required": True}, + "machine_name": {"required": True}, + "server_name": {"required": True}, + "database_name": {"required": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "vmuuid": {"key": "vmuuid", "type": "str"}, + "source_computer_id": {"key": "sourceComputerId", "type": "str"}, + "machine_name": {"key": "machineName", "type": "str"}, + "server_name": {"key": "serverName", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, + } + + def __init__( + self, + *, + workspace_id: str, + vmuuid: str, + source_computer_id: str, + machine_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> None: + """ + :keyword workspace_id: Azure resource Id of the workspace the machine is attached to. Required. + :paramtype workspace_id: str + :keyword vmuuid: The unique Id of the machine. Required. + :paramtype vmuuid: str + :keyword source_computer_id: The oms agent Id installed on the machine. Required. + :paramtype source_computer_id: str + :keyword machine_name: The name of the machine. Required. + :paramtype machine_name: str + :keyword server_name: The Sql server name installed on the machine. Required. + :paramtype server_name: str + :keyword database_name: The Sql database name installed on the machine. Required. + :paramtype database_name: str + """ + super().__init__( + workspace_id=workspace_id, + vmuuid=vmuuid, + source_computer_id=source_computer_id, + machine_name=machine_name, + **kwargs + ) + self.source: str = "OnPremiseSql" + self.server_name = server_name + self.database_name = database_name + + +class OnUploadFilters(_serialization.Model): + """Optional. Determine which blobs get scanned by On Upload malware scanning. An Or operation is + performed between each filter type. + + :ivar exclude_blobs_with_prefix: Optional. A list of prefixes to exclude from on-upload malware + scanning. + Format: ``container-name/blob-name`` (start with the container name; do not include the storage + account name). + Exclude entire containers: Use prefix of container names you want to exclude without a trailing + ``/``. + Exclude a single container: Add a trailing slash ``/`` after the container name to avoid + excluding other containers with similar prefixes. + :vartype exclude_blobs_with_prefix: list[str] + :ivar exclude_blobs_with_suffix: Optional. A list of suffixes to exclude from on-upload malware + scanning. Suffixes match only the end of blob names, and should be used for file extensions or + blob name endings only. + :vartype exclude_blobs_with_suffix: list[str] + :ivar exclude_blobs_larger_than: Optional. Specifies the maximum size in bytes for blobs to be + scanned. This parameter accepts a single positive integer value. Blobs larger than this value + will be excluded from scanning. + :vartype exclude_blobs_larger_than: any + """ + + _attribute_map = { + "exclude_blobs_with_prefix": {"key": "excludeBlobsWithPrefix", "type": "[str]"}, + "exclude_blobs_with_suffix": {"key": "excludeBlobsWithSuffix", "type": "[str]"}, + "exclude_blobs_larger_than": {"key": "excludeBlobsLargerThan", "type": "object"}, + } + + def __init__( + self, + *, + exclude_blobs_with_prefix: Optional[List[str]] = None, + exclude_blobs_with_suffix: Optional[List[str]] = None, + exclude_blobs_larger_than: Optional[Any] = None, + **kwargs: Any + ) -> None: + """ + :keyword exclude_blobs_with_prefix: Optional. A list of prefixes to exclude from on-upload + malware scanning. + Format: ``container-name/blob-name`` (start with the container name; do not include the storage + account name). + Exclude entire containers: Use prefix of container names you want to exclude without a trailing + ``/``. + Exclude a single container: Add a trailing slash ``/`` after the container name to avoid + excluding other containers with similar prefixes. + :paramtype exclude_blobs_with_prefix: list[str] + :keyword exclude_blobs_with_suffix: Optional. A list of suffixes to exclude from on-upload + malware scanning. Suffixes match only the end of blob names, and should be used for file + extensions or blob name endings only. + :paramtype exclude_blobs_with_suffix: list[str] + :keyword exclude_blobs_larger_than: Optional. Specifies the maximum size in bytes for blobs to + be scanned. This parameter accepts a single positive integer value. Blobs larger than this + value will be excluded from scanning. + :paramtype exclude_blobs_larger_than: any + """ + super().__init__(**kwargs) + self.exclude_blobs_with_prefix = exclude_blobs_with_prefix + self.exclude_blobs_with_suffix = exclude_blobs_with_suffix + self.exclude_blobs_larger_than = exclude_blobs_larger_than + + +class OnUploadProperties(_serialization.Model): + """Properties of On Upload malware scanning. + + :ivar is_enabled: Indicates whether On Upload malware scanning should be enabled. + :vartype is_enabled: bool + :ivar cap_gb_per_month: Defines the max GB to be scanned per Month. Set to -1 if no capping is + needed. If not specified, the default value is -1. + :vartype cap_gb_per_month: int + :ivar filters: Optional. Determine which blobs get scanned by On Upload malware scanning. An Or + operation is performed between each filter type. + :vartype filters: ~azure.mgmt.security.models.OnUploadFilters + """ + + _attribute_map = { + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "cap_gb_per_month": {"key": "capGBPerMonth", "type": "int"}, + "filters": {"key": "filters", "type": "OnUploadFilters"}, + } + + def __init__( + self, + *, + is_enabled: Optional[bool] = None, + cap_gb_per_month: Optional[int] = None, + filters: Optional["_models.OnUploadFilters"] = None, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Indicates whether On Upload malware scanning should be enabled. + :paramtype is_enabled: bool + :keyword cap_gb_per_month: Defines the max GB to be scanned per Month. Set to -1 if no capping + is needed. If not specified, the default value is -1. + :paramtype cap_gb_per_month: int + :keyword filters: Optional. Determine which blobs get scanned by On Upload malware scanning. An + Or operation is performed between each filter type. + :paramtype filters: ~azure.mgmt.security.models.OnUploadFilters + """ + super().__init__(**kwargs) + self.is_enabled = is_enabled + self.cap_gb_per_month = cap_gb_per_month + self.filters = filters + + +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.security.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.security.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal", "LogicApp", "EventHub", and "Workspace". + :vartype action_type: str or ~azure.mgmt.security.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.security.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.security.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 OperationResultAutoGenerated(_serialization.Model): + """Long run operation status of governance rule over a given scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The status of the long run operation result of governance rule. Known values are: + "Succeeded", "Failed", and "Canceled". + :vartype status: str or ~azure.mgmt.security.models.OperationResult + """ + + _validation = { + "status": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.status: Optional[Union[str, "_models.OperationResult"]] = None + + +class OperationStatus(_serialization.Model): + """A status describing the success/failure of the enablement/disablement operation. + + :ivar code: The operation status code. + :vartype code: str + :ivar message: Additional information regarding the success/failure of the operation. + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: The operation status code. + :paramtype code: str + :keyword message: Additional information regarding the success/failure of the operation. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class OperationStatusAutoGenerated(_serialization.Model): + """A status describing the success/failure of the extension's enablement/disablement operation. + + :ivar code: The operation status code. Known values are: "Succeeded" and "Failed". + :vartype code: str or ~azure.mgmt.security.models.Code + :ivar message: Additional information regarding the success/failure of the operation. + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__( + self, *, code: Optional[Union[str, "_models.Code"]] = None, message: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword code: The operation status code. Known values are: "Succeeded" and "Failed". + :paramtype code: str or ~azure.mgmt.security.models.Code + :keyword message: Additional information regarding the success/failure of the operation. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + 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 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.security.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.security.models.ErrorDetailAutoGenerated2 + """ + + _validation = { + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "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": "ErrorDetailAutoGenerated2"}, + } + + 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.ErrorDetailAutoGenerated2"] = 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.security.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.security.models.ErrorDetailAutoGenerated2 + """ + super().__init__(**kwargs) + self.id = id + 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 PartialAssessmentProperties(_serialization.Model): + """Describes properties of an assessment as related to the standard. + + :ivar assessment_key: The assessment key. + :vartype assessment_key: str + """ + + _attribute_map = { + "assessment_key": {"key": "assessmentKey", "type": "str"}, + } + + def __init__(self, *, assessment_key: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword assessment_key: The assessment key. + :paramtype assessment_key: str + """ + super().__init__(**kwargs) + self.assessment_key = assessment_key + + +class Path(_serialization.Model): + """Represents a path that composes the risk. + + All required parameters must be populated in order to send to server. + + :ivar id: Path ID. Required. + :vartype id: str + :ivar nodes: Path Nodes. Required. + :vartype nodes: list[~azure.mgmt.security.models.NodeIdentifier] + :ivar edges: Path Edges. Required. + :vartype edges: list[~azure.mgmt.security.models.EdgeIdentifiers] + """ + + _validation = { + "id": {"required": True}, + "nodes": {"required": True}, + "edges": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "nodes": {"key": "nodes", "type": "[NodeIdentifier]"}, + "edges": {"key": "edges", "type": "[EdgeIdentifiers]"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + nodes: List["_models.NodeIdentifier"], + edges: List["_models.EdgeIdentifiers"], + **kwargs: Any + ) -> None: + """ + :keyword id: Path ID. Required. + :paramtype id: str + :keyword nodes: Path Nodes. Required. + :paramtype nodes: list[~azure.mgmt.security.models.NodeIdentifier] + :keyword edges: Path Edges. Required. + :paramtype edges: list[~azure.mgmt.security.models.EdgeIdentifiers] + """ + super().__init__(**kwargs) + self.id = id + self.nodes = nodes + self.edges = edges + + +class Pricing(Resource): + """Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. The standard + tier offers advanced security capabilities, while the free tier offers basic security features. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar pricing_tier: Indicates whether the Defender plan is enabled on the selected scope. + Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. The standard + tier offers advanced security capabilities, while the free tier offers basic security features. + Known values are: "Free" and "Standard". + :vartype pricing_tier: str or ~azure.mgmt.security.models.PricingTier + :ivar sub_plan: The sub-plan selected for a Standard pricing configuration, when more than one + sub-plan is available. Each sub-plan enables a set of security features. When not specified, + full plan is applied. For VirtualMachines plan, available sub plans are 'P1' & 'P2', where for + resource level only 'P1' sub plan is supported. + :vartype sub_plan: str + :ivar free_trial_remaining_time: The duration left for the subscriptions free trial period - in + ISO 8601 format (e.g. P3Y6M4DT12H30M5S). + :vartype free_trial_remaining_time: ~datetime.timedelta + :ivar enablement_time: Optional. If ``pricingTier`` is ``Standard`` then this property holds + the date of the last time the ``pricingTier`` was set to ``Standard``\\ , when available (e.g + 2023-03-01T12:42:42.1921106Z). + :vartype enablement_time: ~datetime.datetime + :ivar enforce: If set to "False", it allows the descendants of this scope to override the + pricing configuration set on this scope (allows setting inherited="False"). If set to "True", + it prevents overrides and forces this pricing configuration on all the descendants of this + scope. This field is only available for subscription-level pricing. Known values are: "False" + and "True". + :vartype enforce: str or ~azure.mgmt.security.models.Enforce + :ivar inherited: "inherited" = "True" indicates that the current scope inherits its pricing + configuration from its parent. The ID of the parent scope that provides the inherited + configuration is displayed in the "inheritedFrom" field. On the other hand, "inherited" = + "False" indicates that the current scope has its own pricing configuration explicitly set, and + does not inherit from its parent. This field is read only and available only for resource-level + pricing. Known values are: "True" and "False". + :vartype inherited: str or ~azure.mgmt.security.models.Inherited + :ivar inherited_from: The id of the scope inherited from. "Null" if not inherited. This field + is only available for resource-level pricing. + :vartype inherited_from: str + :ivar resources_coverage_status: This field is available for subscription-level only, and + reflects the coverage status of the resources under the subscription. Please note: The + "pricingTier" field reflects the plan status of the subscription. However, since the plan + status can also be defined at the resource level, there might be misalignment between the + subscription's plan status and the resource status. This field helps indicate the coverage + status of the resources. Known values are: "FullyCovered", "PartiallyCovered", and + "NotCovered". + :vartype resources_coverage_status: str or ~azure.mgmt.security.models.ResourcesCoverageStatus + :ivar extensions: Optional. List of extensions offered under a plan. + :vartype extensions: list[~azure.mgmt.security.models.Extension] + :ivar deprecated: Optional. True if the plan is deprecated. If there are replacing plans they + will appear in ``replacedBy`` property. + :vartype deprecated: bool + :ivar replaced_by: Optional. List of plans that replace this plan. This property exists only if + this plan is deprecated. + :vartype replaced_by: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "free_trial_remaining_time": {"readonly": True}, + "enablement_time": {"readonly": True}, + "inherited": {"readonly": True}, + "inherited_from": {"readonly": True}, + "resources_coverage_status": {"readonly": True}, + "deprecated": {"readonly": True}, + "replaced_by": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "pricing_tier": {"key": "properties.pricingTier", "type": "str"}, + "sub_plan": {"key": "properties.subPlan", "type": "str"}, + "free_trial_remaining_time": {"key": "properties.freeTrialRemainingTime", "type": "duration"}, + "enablement_time": {"key": "properties.enablementTime", "type": "iso-8601"}, + "enforce": {"key": "properties.enforce", "type": "str"}, + "inherited": {"key": "properties.inherited", "type": "str"}, + "inherited_from": {"key": "properties.inheritedFrom", "type": "str"}, + "resources_coverage_status": {"key": "properties.resourcesCoverageStatus", "type": "str"}, + "extensions": {"key": "properties.extensions", "type": "[Extension]"}, + "deprecated": {"key": "properties.deprecated", "type": "bool"}, + "replaced_by": {"key": "properties.replacedBy", "type": "[str]"}, + } + + def __init__( + self, + *, + pricing_tier: Optional[Union[str, "_models.PricingTier"]] = None, + sub_plan: Optional[str] = None, + enforce: Optional[Union[str, "_models.Enforce"]] = None, + extensions: Optional[List["_models.Extension"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword pricing_tier: Indicates whether the Defender plan is enabled on the selected scope. + Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. The standard + tier offers advanced security capabilities, while the free tier offers basic security features. + Known values are: "Free" and "Standard". + :paramtype pricing_tier: str or ~azure.mgmt.security.models.PricingTier + :keyword sub_plan: The sub-plan selected for a Standard pricing configuration, when more than + one sub-plan is available. Each sub-plan enables a set of security features. When not + specified, full plan is applied. For VirtualMachines plan, available sub plans are 'P1' & 'P2', + where for resource level only 'P1' sub plan is supported. + :paramtype sub_plan: str + :keyword enforce: If set to "False", it allows the descendants of this scope to override the + pricing configuration set on this scope (allows setting inherited="False"). If set to "True", + it prevents overrides and forces this pricing configuration on all the descendants of this + scope. This field is only available for subscription-level pricing. Known values are: "False" + and "True". + :paramtype enforce: str or ~azure.mgmt.security.models.Enforce + :keyword extensions: Optional. List of extensions offered under a plan. + :paramtype extensions: list[~azure.mgmt.security.models.Extension] + """ + super().__init__(**kwargs) + self.pricing_tier = pricing_tier + self.sub_plan = sub_plan + self.free_trial_remaining_time: Optional[datetime.timedelta] = None + self.enablement_time: Optional[datetime.datetime] = None + self.enforce = enforce + self.inherited: Optional[Union[str, "_models.Inherited"]] = None + self.inherited_from: Optional[str] = None + self.resources_coverage_status: Optional[Union[str, "_models.ResourcesCoverageStatus"]] = None + self.extensions = extensions + self.deprecated: Optional[bool] = None + self.replaced_by: Optional[List[str]] = None + + +class PricingList(_serialization.Model): + """List of pricing configurations response. + + All required parameters must be populated in order to send to server. + + :ivar value: List of pricing configurations. Required. + :vartype value: list[~azure.mgmt.security.models.Pricing] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Pricing]"}, + } + + def __init__(self, *, value: List["_models.Pricing"], **kwargs: Any) -> None: + """ + :keyword value: List of pricing configurations. Required. + :paramtype value: list[~azure.mgmt.security.models.Pricing] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateEndpoint(_serialization.Model): + """The private endpoint resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ARM identifier for private endpoint. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + + +class PrivateEndpointConnection(ResourceAutoGenerated): + """The private endpoint connection 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.security.models.SystemData + :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.security.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.security.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.security.models.PrivateEndpointConnectionProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "group_ids": {"readonly": True}, + "provisioning_state": {"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"}, + "group_ids": {"key": "properties.groupIds", "type": "[str]"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_endpoint: The private endpoint resource. + :paramtype private_endpoint: ~azure.mgmt.security.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.security.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.group_ids: Optional[List[str]] = None + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """List of private endpoint connections associated with the specified resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.security.models.PrivateEndpointConnection] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.security.models.PrivateEndpointConnection] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class PrivateLinkParameters(_serialization.Model): + """Parameter group. + + All required parameters must be populated in order to send to server. + + :ivar private_link_name: The name of the private link resource. Must be unique within the + resource group and follow Azure naming conventions. Required. + :vartype private_link_name: str + """ + + _validation = { + "private_link_name": { + "required": True, + "max_length": 63, + "min_length": 3, + "pattern": r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + }, + } + + _attribute_map = { + "private_link_name": {"key": "privateLinkName", "type": "str"}, + } + + def __init__(self, *, private_link_name: str, **kwargs: Any) -> None: + """ + :keyword private_link_name: The name of the private link resource. Must be unique within the + resource group and follow Azure naming conventions. Required. + :paramtype private_link_name: str + """ + super().__init__(**kwargs) + self.private_link_name = private_link_name + + +class ResourceAutoGenerated2(_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.security.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 TrackedResourceAutoGenerated(ResourceAutoGenerated2): + """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.security.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 PrivateLinkResource(TrackedResourceAutoGenerated): + """A private link resource that enables secure, private connectivity to Microsoft Defender for + Cloud services. This resource manages the lifecycle of private endpoint connections and + provides the necessary infrastructure for private connectivity. + + 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.security.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 provisioning_state: The current provisioning state of the private link resource. + Indicates whether the resource is being created, updated, deleted, or has completed + successfully. Known values are: "Succeeded", "Failed", and "Updating". + :vartype provisioning_state: str or ~azure.mgmt.security.models.ProvisioningState + :ivar private_endpoint_connections: List of private endpoint connections associated with this + private link. Each connection represents a private endpoint from a customer's virtual network. + :vartype private_endpoint_connections: + list[~azure.mgmt.security.models.PrivateEndpointConnection] + :ivar private_link_resources: List of private link resources available for connection. For + Defender services, this typically includes the 'containers' group with 'api' and regional data + endpoints. + :vartype private_link_resources: + list[~azure.mgmt.security.models.PrivateLinkResourceAutoGenerated] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "private_link_resources": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "private_link_resources": { + "key": "properties.privateLinkResources", + "type": "[PrivateLinkResourceAutoGenerated]", + }, + } + + 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__(tags=tags, location=location, **kwargs) + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None + self.private_link_resources: Optional[List["_models.PrivateLinkResourceAutoGenerated"]] = None + + +class PrivateLinkResourceAutoGenerated(ResourceAutoGenerated): + """A private link 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.security.models.SystemData + :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] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"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"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, + } + + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword required_zone_names: The private link resource private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.group_id: Optional[str] = None + self.required_members: Optional[List[str]] = None + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(_serialization.Model): + """A list of private link resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.security.models.PrivateLinkResourceAutoGenerated] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResourceAutoGenerated]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.PrivateLinkResourceAutoGenerated"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.security.models.PrivateLinkResourceAutoGenerated] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class PrivateLinkServiceConnectionState(_serialization.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.security.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 + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Known values are: "Pending", "Approved", and "Rejected". + :paramtype status: str or ~azure.mgmt.security.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype actions_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class PrivateLinksList(_serialization.Model): + """Paginated list of private link resources. Contains an array of private links and optional + pagination information. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: Collection of private links in this page. Required. + :vartype value: list[~azure.mgmt.security.models.PrivateLinkResource] + :ivar next_link: The URI to fetch the next page of private links. Present only when there are + additional results available. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True, "readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.PrivateLinkResource"]] = None + self.next_link: Optional[str] = None + + +class PrivateLinkUpdate(_serialization.Model): + """Request payload for updating a private link resource. Used in PATCH operations to update + specific mutable properties without affecting the entire resource configuration. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class ProcessNotAllowed(AllowlistCustomAlertRule): + """Execution of a process that isn't allowed. Allow list consists of process names to allow. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and + "String". + :vartype value_type: str or ~azure.mgmt.security.models.ValueType + :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. + Required. + :vartype allowlist_values: list[str] + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "value_type": {"readonly": True}, + "allowlist_values": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "value_type": {"key": "valueType", "type": "str"}, + "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, + } + + def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword allowlist_values: The values to allow. The format of the values depends on the rule + type. Required. + :paramtype allowlist_values: list[str] + """ + super().__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) + self.rule_type: str = "ProcessNotAllowed" + + +class ProxyServerProperties(_serialization.Model): + """For a non-Azure machine that is not connected directly to the internet, specify a proxy server + that the non-Azure machine can use. + + :ivar ip: Proxy server IP. + :vartype ip: str + :ivar port: Proxy server port. + :vartype port: str + """ + + _attribute_map = { + "ip": {"key": "ip", "type": "str"}, + "port": {"key": "port", "type": "str"}, + } + + def __init__(self, *, ip: Optional[str] = None, port: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword ip: Proxy server IP. + :paramtype ip: str + :keyword port: Proxy server port. + :paramtype port: str + """ + super().__init__(**kwargs) + self.ip = ip + self.port = port + + +class QueryCheck(_serialization.Model): + """The rule query details. + + :ivar query: The rule query. + :vartype query: str + :ivar expected_result: Expected result. + :vartype expected_result: list[list[str]] + :ivar column_names: Column names of expected result. + :vartype column_names: list[str] + """ + + _attribute_map = { + "query": {"key": "query", "type": "str"}, + "expected_result": {"key": "expectedResult", "type": "[[str]]"}, + "column_names": {"key": "columnNames", "type": "[str]"}, + } + + def __init__( + self, + *, + query: Optional[str] = None, + expected_result: Optional[List[List[str]]] = None, + column_names: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword query: The rule query. + :paramtype query: str + :keyword expected_result: Expected result. + :paramtype expected_result: list[list[str]] + :keyword column_names: Column names of expected result. + :paramtype column_names: list[str] + """ + super().__init__(**kwargs) + self.query = query + self.expected_result = expected_result + self.column_names = column_names + + +class QueuePurgesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of device queue purges is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "QueuePurgesNotInAllowedRange" + + +class RecommendationConfigurationProperties(_serialization.Model): + """The type of IoT Security recommendation. + + 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 recommendation_type: The type of IoT Security recommendation. Required. Known values are: + "IoT_ACRAuthentication", "IoT_AgentSendsUnutilizedMessages", "IoT_Baseline", + "IoT_EdgeHubMemOptimize", "IoT_EdgeLoggingOptions", "IoT_InconsistentModuleSettings", + "IoT_InstallAgent", "IoT_IPFilter_DenyAll", "IoT_IPFilter_PermissiveRule", "IoT_OpenPorts", + "IoT_PermissiveFirewallPolicy", "IoT_PermissiveInputFirewallRules", + "IoT_PermissiveOutputFirewallRules", "IoT_PrivilegedDockerOptions", "IoT_SharedCredentials", + and "IoT_VulnerableTLSCipherSuite". + :vartype recommendation_type: str or ~azure.mgmt.security.models.RecommendationType + :ivar name: + :vartype name: str + :ivar status: Recommendation status. When the recommendation status is disabled recommendations + are not generated. Known values are: "Disabled" and "Enabled". + :vartype status: str or ~azure.mgmt.security.models.RecommendationConfigStatus + """ + + _validation = { + "recommendation_type": {"required": True}, + "name": {"readonly": True}, + "status": {"required": True}, + } + + _attribute_map = { + "recommendation_type": {"key": "recommendationType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + recommendation_type: Union[str, "_models.RecommendationType"], + status: Union[str, "_models.RecommendationConfigStatus"] = "Enabled", + **kwargs: Any + ) -> None: + """ + :keyword recommendation_type: The type of IoT Security recommendation. Required. Known values + are: "IoT_ACRAuthentication", "IoT_AgentSendsUnutilizedMessages", "IoT_Baseline", + "IoT_EdgeHubMemOptimize", "IoT_EdgeLoggingOptions", "IoT_InconsistentModuleSettings", + "IoT_InstallAgent", "IoT_IPFilter_DenyAll", "IoT_IPFilter_PermissiveRule", "IoT_OpenPorts", + "IoT_PermissiveFirewallPolicy", "IoT_PermissiveInputFirewallRules", + "IoT_PermissiveOutputFirewallRules", "IoT_PrivilegedDockerOptions", "IoT_SharedCredentials", + and "IoT_VulnerableTLSCipherSuite". + :paramtype recommendation_type: str or ~azure.mgmt.security.models.RecommendationType + :keyword status: Recommendation status. When the recommendation status is disabled + recommendations are not generated. Known values are: "Disabled" and "Enabled". + :paramtype status: str or ~azure.mgmt.security.models.RecommendationConfigStatus + """ + super().__init__(**kwargs) + self.recommendation_type = recommendation_type + self.name: Optional[str] = None + self.status = status + + +class RegulatoryComplianceAssessment(Resource): + """Regulatory compliance assessment details and state. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar description: The description of the regulatory compliance assessment. + :vartype description: str + :ivar assessment_type: The expected type of assessment contained in the AssessmentDetailsLink. + :vartype assessment_type: str + :ivar assessment_details_link: Link to more detailed assessment results data. The response type + will be according to the assessmentType field. + :vartype assessment_details_link: str + :ivar state: Aggregative state based on the assessment's scanned resources states. Known values + are: "Passed", "Failed", "Skipped", and "Unsupported". + :vartype state: str or ~azure.mgmt.security.models.State + :ivar passed_resources: The given assessment's related resources count with passed state. + :vartype passed_resources: int + :ivar failed_resources: The given assessment's related resources count with failed state. + :vartype failed_resources: int + :ivar skipped_resources: The given assessment's related resources count with skipped state. + :vartype skipped_resources: int + :ivar unsupported_resources: The given assessment's related resources count with unsupported + state. + :vartype unsupported_resources: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "description": {"readonly": True}, + "assessment_type": {"readonly": True}, + "assessment_details_link": {"readonly": True}, + "passed_resources": {"readonly": True}, + "failed_resources": {"readonly": True}, + "skipped_resources": {"readonly": True}, + "unsupported_resources": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "assessment_type": {"key": "properties.assessmentType", "type": "str"}, + "assessment_details_link": {"key": "properties.assessmentDetailsLink", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "passed_resources": {"key": "properties.passedResources", "type": "int"}, + "failed_resources": {"key": "properties.failedResources", "type": "int"}, + "skipped_resources": {"key": "properties.skippedResources", "type": "int"}, + "unsupported_resources": {"key": "properties.unsupportedResources", "type": "int"}, + } + + def __init__(self, *, state: Optional[Union[str, "_models.State"]] = None, **kwargs: Any) -> None: + """ + :keyword state: Aggregative state based on the assessment's scanned resources states. Known + values are: "Passed", "Failed", "Skipped", and "Unsupported". + :paramtype state: str or ~azure.mgmt.security.models.State + """ + super().__init__(**kwargs) + self.description: Optional[str] = None + self.assessment_type: Optional[str] = None + self.assessment_details_link: Optional[str] = None + self.state = state + self.passed_resources: Optional[int] = None + self.failed_resources: Optional[int] = None + self.skipped_resources: Optional[int] = None + self.unsupported_resources: Optional[int] = None + + +class RegulatoryComplianceAssessmentList(_serialization.Model): + """List of regulatory compliance assessment response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: Required. + :vartype value: list[~azure.mgmt.security.models.RegulatoryComplianceAssessment] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[RegulatoryComplianceAssessment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.RegulatoryComplianceAssessment"], **kwargs: Any) -> None: + """ + :keyword value: Required. + :paramtype value: list[~azure.mgmt.security.models.RegulatoryComplianceAssessment] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class RegulatoryComplianceControl(Resource): + """Regulatory compliance control details and state. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar description: The description of the regulatory compliance control. + :vartype description: str + :ivar state: Aggregative state based on the control's supported assessments states. Known + values are: "Passed", "Failed", "Skipped", and "Unsupported". + :vartype state: str or ~azure.mgmt.security.models.State + :ivar passed_assessments: The number of supported regulatory compliance assessments of the + given control with a passed state. + :vartype passed_assessments: int + :ivar failed_assessments: The number of supported regulatory compliance assessments of the + given control with a failed state. + :vartype failed_assessments: int + :ivar skipped_assessments: The number of supported regulatory compliance assessments of the + given control with a skipped state. + :vartype skipped_assessments: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "description": {"readonly": True}, + "passed_assessments": {"readonly": True}, + "failed_assessments": {"readonly": True}, + "skipped_assessments": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "passed_assessments": {"key": "properties.passedAssessments", "type": "int"}, + "failed_assessments": {"key": "properties.failedAssessments", "type": "int"}, + "skipped_assessments": {"key": "properties.skippedAssessments", "type": "int"}, + } + + def __init__(self, *, state: Optional[Union[str, "_models.State"]] = None, **kwargs: Any) -> None: + """ + :keyword state: Aggregative state based on the control's supported assessments states. Known + values are: "Passed", "Failed", "Skipped", and "Unsupported". + :paramtype state: str or ~azure.mgmt.security.models.State + """ + super().__init__(**kwargs) + self.description: Optional[str] = None + self.state = state + self.passed_assessments: Optional[int] = None + self.failed_assessments: Optional[int] = None + self.skipped_assessments: Optional[int] = None + + +class RegulatoryComplianceControlList(_serialization.Model): + """List of regulatory compliance controls response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: List of regulatory compliance controls. Required. + :vartype value: list[~azure.mgmt.security.models.RegulatoryComplianceControl] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[RegulatoryComplianceControl]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.RegulatoryComplianceControl"], **kwargs: Any) -> None: + """ + :keyword value: List of regulatory compliance controls. Required. + :paramtype value: list[~azure.mgmt.security.models.RegulatoryComplianceControl] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class RegulatoryComplianceStandard(Resource): + """Regulatory compliance standard details and state. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar state: Aggregative state based on the standard's supported controls states. Known values + are: "Passed", "Failed", "Skipped", and "Unsupported". + :vartype state: str or ~azure.mgmt.security.models.State + :ivar passed_controls: The number of supported regulatory compliance controls of the given + standard with a passed state. + :vartype passed_controls: int + :ivar failed_controls: The number of supported regulatory compliance controls of the given + standard with a failed state. + :vartype failed_controls: int + :ivar skipped_controls: The number of supported regulatory compliance controls of the given + standard with a skipped state. + :vartype skipped_controls: int + :ivar unsupported_controls: The number of regulatory compliance controls of the given standard + which are unsupported by automated assessments. + :vartype unsupported_controls: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "passed_controls": {"readonly": True}, + "failed_controls": {"readonly": True}, + "skipped_controls": {"readonly": True}, + "unsupported_controls": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "passed_controls": {"key": "properties.passedControls", "type": "int"}, + "failed_controls": {"key": "properties.failedControls", "type": "int"}, + "skipped_controls": {"key": "properties.skippedControls", "type": "int"}, + "unsupported_controls": {"key": "properties.unsupportedControls", "type": "int"}, + } + + def __init__(self, *, state: Optional[Union[str, "_models.State"]] = None, **kwargs: Any) -> None: + """ + :keyword state: Aggregative state based on the standard's supported controls states. Known + values are: "Passed", "Failed", "Skipped", and "Unsupported". + :paramtype state: str or ~azure.mgmt.security.models.State + """ + super().__init__(**kwargs) + self.state = state + self.passed_controls: Optional[int] = None + self.failed_controls: Optional[int] = None + self.skipped_controls: Optional[int] = None + self.unsupported_controls: Optional[int] = None + + +class RegulatoryComplianceStandardList(_serialization.Model): + """List of regulatory compliance standards response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: Required. + :vartype value: list[~azure.mgmt.security.models.RegulatoryComplianceStandard] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[RegulatoryComplianceStandard]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.RegulatoryComplianceStandard"], **kwargs: Any) -> None: + """ + :keyword value: Required. + :paramtype value: list[~azure.mgmt.security.models.RegulatoryComplianceStandard] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class Remediation(_serialization.Model): + """Remediation details. + + :ivar description: Remediation description. + :vartype description: str + :ivar scripts: Remediation script. + :vartype scripts: list[str] + :ivar automated: Is remediation automated. + :vartype automated: bool + :ivar portal_link: Optional link to remediate in Azure Portal. + :vartype portal_link: str + """ + + _attribute_map = { + "description": {"key": "description", "type": "str"}, + "scripts": {"key": "scripts", "type": "[str]"}, + "automated": {"key": "automated", "type": "bool"}, + "portal_link": {"key": "portalLink", "type": "str"}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + scripts: Optional[List[str]] = None, + automated: Optional[bool] = None, + portal_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword description: Remediation description. + :paramtype description: str + :keyword scripts: Remediation script. + :paramtype scripts: list[str] + :keyword automated: Is remediation automated. + :paramtype automated: bool + :keyword portal_link: Optional link to remediate in Azure Portal. + :paramtype portal_link: str + """ + super().__init__(**kwargs) + self.description = description + self.scripts = scripts + self.automated = automated + self.portal_link = portal_link + + +class RemediationEta(_serialization.Model): + """The ETA (estimated time of arrival) for remediation. + + All required parameters must be populated in order to send to server. + + :ivar eta: ETA for remediation. Required. + :vartype eta: ~datetime.datetime + :ivar justification: Justification for change of Eta. Required. + :vartype justification: str + """ + + _validation = { + "eta": {"required": True}, + "justification": {"required": True}, + } + + _attribute_map = { + "eta": {"key": "eta", "type": "iso-8601"}, + "justification": {"key": "justification", "type": "str"}, + } + + def __init__(self, *, eta: datetime.datetime, justification: str, **kwargs: Any) -> None: + """ + :keyword eta: ETA for remediation. Required. + :paramtype eta: ~datetime.datetime + :keyword justification: Justification for change of Eta. Required. + :paramtype justification: str + """ + super().__init__(**kwargs) + self.eta = eta + self.justification = justification + + +class ResourceDetailsAutoGenerated(_serialization.Model): + """The resource details of the health report. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar source: The status of the health report. Known values are: "Azure", "OnPremise", and + "OnPremiseSql". + :vartype source: str or ~azure.mgmt.security.models.Source + :ivar id: The azure id of the resource. + :vartype id: str + :ivar connector_id: The id of the connector. + :vartype connector_id: str + """ + + _validation = { + "id": {"readonly": True}, + "connector_id": {"readonly": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "connector_id": {"key": "connectorId", "type": "str"}, + } + + def __init__(self, *, source: Optional[Union[str, "_models.Source"]] = None, **kwargs: Any) -> None: + """ + :keyword source: The status of the health report. Known values are: "Azure", "OnPremise", and + "OnPremiseSql". + :paramtype source: str or ~azure.mgmt.security.models.Source + """ + super().__init__(**kwargs) + self.source = source + self.id: Optional[str] = None + self.connector_id: Optional[str] = None + + +class RuleResults(Resource): + """Rule results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: Rule results properties. + :vartype properties: ~azure.mgmt.security.models.RuleResultsProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "RuleResultsProperties"}, + } + + def __init__(self, *, properties: Optional["_models.RuleResultsProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Rule results properties. + :paramtype properties: ~azure.mgmt.security.models.RuleResultsProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class RuleResultsInput(_serialization.Model): + """Rule results input. + + :ivar latest_scan: Take results from latest scan. + :vartype latest_scan: bool + :ivar results: Expected results to be inserted into the baseline. + Leave this field empty it LatestScan == true. + :vartype results: list[list[str]] + """ + + _attribute_map = { + "latest_scan": {"key": "latestScan", "type": "bool"}, + "results": {"key": "results", "type": "[[str]]"}, + } + + def __init__( + self, *, latest_scan: Optional[bool] = None, results: Optional[List[List[str]]] = None, **kwargs: Any + ) -> None: + """ + :keyword latest_scan: Take results from latest scan. + :paramtype latest_scan: bool + :keyword results: Expected results to be inserted into the baseline. + Leave this field empty it LatestScan == true. + :paramtype results: list[list[str]] + """ + super().__init__(**kwargs) + self.latest_scan = latest_scan + self.results = results + + +class RuleResultsProperties(_serialization.Model): + """Rule results properties. + + :ivar results: Expected results in the baseline. + :vartype results: list[list[str]] + """ + + _attribute_map = { + "results": {"key": "results", "type": "[[str]]"}, + } + + def __init__(self, *, results: Optional[List[List[str]]] = None, **kwargs: Any) -> None: + """ + :keyword results: Expected results in the baseline. + :paramtype results: list[list[str]] + """ + super().__init__(**kwargs) + self.results = results + + +class RulesResults(_serialization.Model): + """A list of rules results. + + :ivar value: List of rule results. + :vartype value: list[~azure.mgmt.security.models.RuleResults] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RuleResults]"}, + } + + def __init__(self, *, value: Optional[List["_models.RuleResults"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of rule results. + :paramtype value: list[~azure.mgmt.security.models.RuleResults] + """ + super().__init__(**kwargs) + self.value = value + + +class RulesResultsInput(_serialization.Model): + """Rules results input. + + :ivar latest_scan: Take results from latest scan. + :vartype latest_scan: bool + :ivar results: Expected results to be inserted into the baseline. + Leave this field empty it LatestScan == true. + :vartype results: dict[str, list[list[str]]] + """ + + _attribute_map = { + "latest_scan": {"key": "latestScan", "type": "bool"}, + "results": {"key": "results", "type": "{[[str]]}"}, + } + + def __init__( + self, *, latest_scan: Optional[bool] = None, results: Optional[Dict[str, List[List[str]]]] = None, **kwargs: Any + ) -> None: + """ + :keyword latest_scan: Take results from latest scan. + :paramtype latest_scan: bool + :keyword results: Expected results to be inserted into the baseline. + Leave this field empty it LatestScan == true. + :paramtype results: dict[str, list[list[str]]] + """ + super().__init__(**kwargs) + self.latest_scan = latest_scan + self.results = results + + +class Scan(Resource): + """A vulnerability assessment scan record. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: A vulnerability assessment scan record properties. + :vartype properties: ~azure.mgmt.security.models.ScanProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ScanProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ScanProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: A vulnerability assessment scan record properties. + :paramtype properties: ~azure.mgmt.security.models.ScanProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ScanProperties(_serialization.Model): + """A vulnerability assessment scan record properties. + + :ivar trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". + :vartype trigger_type: str or ~azure.mgmt.security.models.ScanTriggerType + :ivar state: The scan status. Known values are: "Failed", "FailedToRun", "InProgress", and + "Passed". + :vartype state: str or ~azure.mgmt.security.models.ScanState + :ivar server: The server name. + :vartype server: str + :ivar database: The database name. + :vartype database: str + :ivar sql_version: The SQL version. + :vartype sql_version: str + :ivar start_time: The scan start time (UTC). + :vartype start_time: ~datetime.datetime + :ivar end_time: Scan results are valid until end time (UTC). + :vartype end_time: ~datetime.datetime + :ivar high_severity_failed_rules_count: The number of failed rules with high severity. + :vartype high_severity_failed_rules_count: int + :ivar medium_severity_failed_rules_count: The number of failed rules with medium severity. + :vartype medium_severity_failed_rules_count: int + :ivar low_severity_failed_rules_count: The number of failed rules with low severity. + :vartype low_severity_failed_rules_count: int + :ivar total_passed_rules_count: The number of total passed rules. + :vartype total_passed_rules_count: int + :ivar total_failed_rules_count: The number of total failed rules. + :vartype total_failed_rules_count: int + :ivar total_rules_count: The number of total rules assessed. + :vartype total_rules_count: int + :ivar is_baseline_applied: Baseline created for this database, and has one or more rules. + :vartype is_baseline_applied: bool + :ivar last_scan_time: Last scan time. + :vartype last_scan_time: ~datetime.datetime + """ + + _attribute_map = { + "trigger_type": {"key": "triggerType", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "server": {"key": "server", "type": "str"}, + "database": {"key": "database", "type": "str"}, + "sql_version": {"key": "sqlVersion", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "high_severity_failed_rules_count": {"key": "highSeverityFailedRulesCount", "type": "int"}, + "medium_severity_failed_rules_count": {"key": "mediumSeverityFailedRulesCount", "type": "int"}, + "low_severity_failed_rules_count": {"key": "lowSeverityFailedRulesCount", "type": "int"}, + "total_passed_rules_count": {"key": "totalPassedRulesCount", "type": "int"}, + "total_failed_rules_count": {"key": "totalFailedRulesCount", "type": "int"}, + "total_rules_count": {"key": "totalRulesCount", "type": "int"}, + "is_baseline_applied": {"key": "isBaselineApplied", "type": "bool"}, + "last_scan_time": {"key": "lastScanTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + trigger_type: Optional[Union[str, "_models.ScanTriggerType"]] = None, + state: Optional[Union[str, "_models.ScanState"]] = None, + server: Optional[str] = None, + database: Optional[str] = None, + sql_version: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + high_severity_failed_rules_count: Optional[int] = None, + medium_severity_failed_rules_count: Optional[int] = None, + low_severity_failed_rules_count: Optional[int] = None, + total_passed_rules_count: Optional[int] = None, + total_failed_rules_count: Optional[int] = None, + total_rules_count: Optional[int] = None, + is_baseline_applied: Optional[bool] = None, + last_scan_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". + :paramtype trigger_type: str or ~azure.mgmt.security.models.ScanTriggerType + :keyword state: The scan status. Known values are: "Failed", "FailedToRun", "InProgress", and + "Passed". + :paramtype state: str or ~azure.mgmt.security.models.ScanState + :keyword server: The server name. + :paramtype server: str + :keyword database: The database name. + :paramtype database: str + :keyword sql_version: The SQL version. + :paramtype sql_version: str + :keyword start_time: The scan start time (UTC). + :paramtype start_time: ~datetime.datetime + :keyword end_time: Scan results are valid until end time (UTC). + :paramtype end_time: ~datetime.datetime + :keyword high_severity_failed_rules_count: The number of failed rules with high severity. + :paramtype high_severity_failed_rules_count: int + :keyword medium_severity_failed_rules_count: The number of failed rules with medium severity. + :paramtype medium_severity_failed_rules_count: int + :keyword low_severity_failed_rules_count: The number of failed rules with low severity. + :paramtype low_severity_failed_rules_count: int + :keyword total_passed_rules_count: The number of total passed rules. + :paramtype total_passed_rules_count: int + :keyword total_failed_rules_count: The number of total failed rules. + :paramtype total_failed_rules_count: int + :keyword total_rules_count: The number of total rules assessed. + :paramtype total_rules_count: int + :keyword is_baseline_applied: Baseline created for this database, and has one or more rules. + :paramtype is_baseline_applied: bool + :keyword last_scan_time: Last scan time. + :paramtype last_scan_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.trigger_type = trigger_type + self.state = state + self.server = server + self.database = database + self.sql_version = sql_version + self.start_time = start_time + self.end_time = end_time + self.high_severity_failed_rules_count = high_severity_failed_rules_count + self.medium_severity_failed_rules_count = medium_severity_failed_rules_count + self.low_severity_failed_rules_count = low_severity_failed_rules_count + self.total_passed_rules_count = total_passed_rules_count + self.total_failed_rules_count = total_failed_rules_count + self.total_rules_count = total_rules_count + self.is_baseline_applied = is_baseline_applied + self.last_scan_time = last_scan_time + + +class ScanResult(Resource): + """A vulnerability assessment scan result for a single rule. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: A vulnerability assessment scan result properties for a single rule. + :vartype properties: ~azure.mgmt.security.models.ScanResultProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ScanResultProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ScanResultProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: A vulnerability assessment scan result properties for a single rule. + :paramtype properties: ~azure.mgmt.security.models.ScanResultProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ScanResultProperties(_serialization.Model): + """A vulnerability assessment scan result properties for a single rule. + + :ivar rule_id: The rule Id. + :vartype rule_id: str + :ivar status: The rule result status. Known values are: "NonFinding", "Finding", and + "InternalError". + :vartype status: str or ~azure.mgmt.security.models.RuleStatus + :ivar is_trimmed: Indicated whether the results specified here are trimmed. + :vartype is_trimmed: bool + :ivar query_results: The results of the query that was run. + :vartype query_results: list[list[str]] + :ivar remediation: Remediation details. + :vartype remediation: ~azure.mgmt.security.models.Remediation + :ivar baseline_adjusted_result: The rule result adjusted with baseline. + :vartype baseline_adjusted_result: ~azure.mgmt.security.models.BaselineAdjustedResult + :ivar rule_metadata: vulnerability assessment rule metadata details. + :vartype rule_metadata: ~azure.mgmt.security.models.VaRule + """ + + _attribute_map = { + "rule_id": {"key": "ruleId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "is_trimmed": {"key": "isTrimmed", "type": "bool"}, + "query_results": {"key": "queryResults", "type": "[[str]]"}, + "remediation": {"key": "remediation", "type": "Remediation"}, + "baseline_adjusted_result": {"key": "baselineAdjustedResult", "type": "BaselineAdjustedResult"}, + "rule_metadata": {"key": "ruleMetadata", "type": "VaRule"}, + } + + def __init__( + self, + *, + rule_id: Optional[str] = None, + status: Optional[Union[str, "_models.RuleStatus"]] = None, + is_trimmed: Optional[bool] = None, + query_results: Optional[List[List[str]]] = None, + remediation: Optional["_models.Remediation"] = None, + baseline_adjusted_result: Optional["_models.BaselineAdjustedResult"] = None, + rule_metadata: Optional["_models.VaRule"] = None, + **kwargs: Any + ) -> None: + """ + :keyword rule_id: The rule Id. + :paramtype rule_id: str + :keyword status: The rule result status. Known values are: "NonFinding", "Finding", and + "InternalError". + :paramtype status: str or ~azure.mgmt.security.models.RuleStatus + :keyword is_trimmed: Indicated whether the results specified here are trimmed. + :paramtype is_trimmed: bool + :keyword query_results: The results of the query that was run. + :paramtype query_results: list[list[str]] + :keyword remediation: Remediation details. + :paramtype remediation: ~azure.mgmt.security.models.Remediation + :keyword baseline_adjusted_result: The rule result adjusted with baseline. + :paramtype baseline_adjusted_result: ~azure.mgmt.security.models.BaselineAdjustedResult + :keyword rule_metadata: vulnerability assessment rule metadata details. + :paramtype rule_metadata: ~azure.mgmt.security.models.VaRule + """ + super().__init__(**kwargs) + self.rule_id = rule_id + self.status = status + self.is_trimmed = is_trimmed + self.query_results = query_results + self.remediation = remediation + self.baseline_adjusted_result = baseline_adjusted_result + self.rule_metadata = rule_metadata + + +class ScanResults(_serialization.Model): + """A list of vulnerability assessment scan results. + + :ivar value: List of vulnerability assessment scan results. + :vartype value: list[~azure.mgmt.security.models.ScanResult] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ScanResult]"}, + } + + def __init__(self, *, value: Optional[List["_models.ScanResult"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of vulnerability assessment scan results. + :paramtype value: list[~azure.mgmt.security.models.ScanResult] + """ + super().__init__(**kwargs) + self.value = value + + +class Scans(_serialization.Model): + """A list of vulnerability assessment scan records. + + :ivar value: List of vulnerability assessment scan records. + :vartype value: list[~azure.mgmt.security.models.Scan] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Scan]"}, + } + + def __init__(self, *, value: Optional[List["_models.Scan"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of vulnerability assessment scan records. + :paramtype value: list[~azure.mgmt.security.models.Scan] + """ + super().__init__(**kwargs) + self.value = value + + +class ScanSummary(_serialization.Model): + """A summary of the scan results. + + :ivar blobs: A summary of the scan results of the blobs that were scanned. + :vartype blobs: ~azure.mgmt.security.models.BlobsScanSummary + :ivar estimated_scan_cost_usd: The estimated cost of the scan. Only available for a scan which + has terminated. + :vartype estimated_scan_cost_usd: float + """ + + _attribute_map = { + "blobs": {"key": "blobs", "type": "BlobsScanSummary"}, + "estimated_scan_cost_usd": {"key": "estimatedScanCostUSD", "type": "float"}, + } + + def __init__( + self, + *, + blobs: Optional["_models.BlobsScanSummary"] = None, + estimated_scan_cost_usd: Optional[float] = None, + **kwargs: Any + ) -> None: + """ + :keyword blobs: A summary of the scan results of the blobs that were scanned. + :paramtype blobs: ~azure.mgmt.security.models.BlobsScanSummary + :keyword estimated_scan_cost_usd: The estimated cost of the scan. Only available for a scan + which has terminated. + :paramtype estimated_scan_cost_usd: float + """ + super().__init__(**kwargs) + self.blobs = blobs + self.estimated_scan_cost_usd = estimated_scan_cost_usd + + +class ScopeElement(_serialization.Model): + """A more specific scope used to identify the alerts to suppress. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar field: The alert entity type to suppress by. + :vartype field: str + """ + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "field": {"key": "field", "type": "str"}, + } + + def __init__( + self, *, additional_properties: Optional[Dict[str, Any]] = None, field: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword field: The alert entity type to suppress by. + :paramtype field: str + """ + super().__init__(**kwargs) + self.additional_properties = additional_properties + self.field = field + + +class SecureScoreControlDefinitionItem(Resource): + """Information about the security control. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: User friendly display name of the control. + :vartype display_name: str + :ivar description: User friendly description of the control. + :vartype description: str + :ivar max_score: Maximum control score (0..10). + :vartype max_score: int + :ivar source: Source object from which the control was created. + :vartype source: ~azure.mgmt.security.models.SecureScoreControlDefinitionSource + :ivar assessment_definitions: Array of assessments metadata IDs that are included in this + security control. + :vartype assessment_definitions: list[~azure.mgmt.security.models.AzureResourceLink] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "description": {"readonly": True, "max_length": 256}, + "max_score": {"readonly": True, "maximum": 10, "minimum": 0}, + "source": {"readonly": True}, + "assessment_definitions": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "max_score": {"key": "properties.maxScore", "type": "int"}, + "source": {"key": "properties.source", "type": "SecureScoreControlDefinitionSource"}, + "assessment_definitions": {"key": "properties.assessmentDefinitions", "type": "[AzureResourceLink]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.display_name: Optional[str] = None + self.description: Optional[str] = None + self.max_score: Optional[int] = None + self.source: Optional["_models.SecureScoreControlDefinitionSource"] = None + self.assessment_definitions: Optional[List["_models.AzureResourceLink"]] = None + + +class SecureScoreControlDefinitionList(_serialization.Model): + """List of security controls definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of security controls definition in this page. + :vartype value: list[~azure.mgmt.security.models.SecureScoreControlDefinitionItem] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecureScoreControlDefinitionItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.SecureScoreControlDefinitionItem"]] = None + self.next_link: Optional[str] = None + + +class SecureScoreControlDefinitionSource(_serialization.Model): + """The type of the security control (For example, BuiltIn). + + :ivar source_type: The type of security control (for example, BuiltIn). Known values are: + "BuiltIn" and "Custom". + :vartype source_type: str or ~azure.mgmt.security.models.ControlType + """ + + _attribute_map = { + "source_type": {"key": "sourceType", "type": "str"}, + } + + def __init__(self, *, source_type: Optional[Union[str, "_models.ControlType"]] = None, **kwargs: Any) -> None: + """ + :keyword source_type: The type of security control (for example, BuiltIn). Known values are: + "BuiltIn" and "Custom". + :paramtype source_type: str or ~azure.mgmt.security.models.ControlType + """ + super().__init__(**kwargs) + self.source_type = source_type + + +class SecureScoreControlDetails(Resource): + """Details of the security control, its score, and the health status of the relevant resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: User friendly display name of the control. + :vartype display_name: str + :ivar healthy_resource_count: Number of healthy resources in the control. + :vartype healthy_resource_count: int + :ivar unhealthy_resource_count: Number of unhealthy resources in the control. + :vartype unhealthy_resource_count: int + :ivar not_applicable_resource_count: Number of not applicable resources in the control. + :vartype not_applicable_resource_count: int + :ivar weight: The relative weight for this specific control in each of your subscriptions. Used + when calculating an aggregated score for this control across all of your subscriptions. + :vartype weight: int + :ivar definition: Information about the security control. + :vartype definition: ~azure.mgmt.security.models.SecureScoreControlDefinitionItem + :ivar max: Maximum score available. + :vartype max: int + :ivar current: Current score. + :vartype current: float + :ivar percentage: Ratio of the current score divided by the maximum. Rounded to 4 digits after + the decimal point. + :vartype percentage: float + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "healthy_resource_count": {"readonly": True}, + "unhealthy_resource_count": {"readonly": True}, + "not_applicable_resource_count": {"readonly": True}, + "weight": {"readonly": True, "minimum": 0}, + "max": {"readonly": True, "minimum": 0}, + "current": {"readonly": True, "minimum": 0}, + "percentage": {"readonly": True, "maximum": 1, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "healthy_resource_count": {"key": "properties.healthyResourceCount", "type": "int"}, + "unhealthy_resource_count": {"key": "properties.unhealthyResourceCount", "type": "int"}, + "not_applicable_resource_count": {"key": "properties.notApplicableResourceCount", "type": "int"}, + "weight": {"key": "properties.weight", "type": "int"}, + "definition": {"key": "properties.definition", "type": "SecureScoreControlDefinitionItem"}, + "max": {"key": "properties.score.max", "type": "int"}, + "current": {"key": "properties.score.current", "type": "float"}, + "percentage": {"key": "properties.score.percentage", "type": "float"}, + } + + def __init__( + self, *, definition: Optional["_models.SecureScoreControlDefinitionItem"] = None, **kwargs: Any + ) -> None: + """ + :keyword definition: Information about the security control. + :paramtype definition: ~azure.mgmt.security.models.SecureScoreControlDefinitionItem + """ + super().__init__(**kwargs) + self.display_name: Optional[str] = None + self.healthy_resource_count: Optional[int] = None + self.unhealthy_resource_count: Optional[int] = None + self.not_applicable_resource_count: Optional[int] = None + self.weight: Optional[int] = None + self.definition = definition + self.max: Optional[int] = None + self.current: Optional[float] = None + self.percentage: Optional[float] = None + + +class SecureScoreControlList(_serialization.Model): + """List of security controls. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of security controls in this page. + :vartype value: list[~azure.mgmt.security.models.SecureScoreControlDetails] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecureScoreControlDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.SecureScoreControlDetails"]] = None + self.next_link: Optional[str] = None + + +class SecureScoreControlScore(_serialization.Model): + """Calculation result data. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar max: Maximum control score (0..10). + :vartype max: int + :ivar current: Actual score for the control = (achieved points / total points) * max score. if + total points is zeroed, the return number is 0.00. + :vartype current: float + :ivar percentage: Ratio of the current score divided by the maximum. Rounded to 4 digits after + the decimal point. + :vartype percentage: float + """ + + _validation = { + "max": {"readonly": True, "maximum": 10, "minimum": 0}, + "current": {"readonly": True, "maximum": 10, "minimum": 0}, + "percentage": {"readonly": True, "maximum": 1, "minimum": 0}, + } + + _attribute_map = { + "max": {"key": "max", "type": "int"}, + "current": {"key": "current", "type": "float"}, + "percentage": {"key": "percentage", "type": "float"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.max: Optional[int] = None + self.current: Optional[float] = None + self.percentage: Optional[float] = None + + +class SecureScoreItem(Resource): + """Secure score item data model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: The initiative’s name. + :vartype display_name: str + :ivar weight: The relative weight for each subscription. Used when calculating an aggregated + secure score for multiple subscriptions. + :vartype weight: int + :ivar max: Maximum score available. + :vartype max: int + :ivar current: Current score. + :vartype current: float + :ivar percentage: Ratio of the current score divided by the maximum. Rounded to 4 digits after + the decimal point. + :vartype percentage: float + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "weight": {"readonly": True, "minimum": 0}, + "max": {"readonly": True, "minimum": 0}, + "current": {"readonly": True, "minimum": 0}, + "percentage": {"readonly": True, "maximum": 1, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "weight": {"key": "properties.weight", "type": "int"}, + "max": {"key": "properties.score.max", "type": "int"}, + "current": {"key": "properties.score.current", "type": "float"}, + "percentage": {"key": "properties.score.percentage", "type": "float"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.display_name: Optional[str] = None + self.weight: Optional[int] = None + self.max: Optional[int] = None + self.current: Optional[float] = None + self.percentage: Optional[float] = None + + +class SecureScoresList(_serialization.Model): + """List of secure scores. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of secure scores in this page. + :vartype value: list[~azure.mgmt.security.models.SecureScoreItem] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecureScoreItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.SecureScoreItem"]] = None + self.next_link: Optional[str] = None + + +class SecurityAssessment(Resource): + """Security assessment on a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar risk: External model of risk result. + :vartype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :ivar resource_details: Details of the resource that was assessed. + :vartype resource_details: ~azure.mgmt.security.models.ResourceDetails + :ivar display_name: User friendly display name of the assessment. + :vartype display_name: str + :ivar additional_data: Additional data regarding the assessment. + :vartype additional_data: dict[str, str] + :ivar links: Links relevant to the assessment. + :vartype links: ~azure.mgmt.security.models.AssessmentLinks + :ivar metadata: Describes properties of an assessment metadata. + :vartype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :ivar partners_data: Data regarding 3rd party partner integration. + :vartype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + :ivar status: The result of the assessment. + :vartype status: ~azure.mgmt.security.models.AssessmentStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "links": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "risk": {"key": "properties.risk", "type": "SecurityAssessmentPropertiesBaseRisk"}, + "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "additional_data": {"key": "properties.additionalData", "type": "{str}"}, + "links": {"key": "properties.links", "type": "AssessmentLinks"}, + "metadata": {"key": "properties.metadata", "type": "SecurityAssessmentMetadataProperties"}, + "partners_data": {"key": "properties.partnersData", "type": "SecurityAssessmentPartnerData"}, + "status": {"key": "properties.status", "type": "AssessmentStatus"}, + } + + def __init__( + self, + *, + risk: Optional["_models.SecurityAssessmentPropertiesBaseRisk"] = None, + resource_details: Optional["_models.ResourceDetails"] = None, + additional_data: Optional[Dict[str, str]] = None, + metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, + partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, + status: Optional["_models.AssessmentStatus"] = None, + **kwargs: Any + ) -> None: + """ + :keyword risk: External model of risk result. + :paramtype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :keyword resource_details: Details of the resource that was assessed. + :paramtype resource_details: ~azure.mgmt.security.models.ResourceDetails + :keyword additional_data: Additional data regarding the assessment. + :paramtype additional_data: dict[str, str] + :keyword metadata: Describes properties of an assessment metadata. + :paramtype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :keyword partners_data: Data regarding 3rd party partner integration. + :paramtype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + :keyword status: The result of the assessment. + :paramtype status: ~azure.mgmt.security.models.AssessmentStatus + """ + super().__init__(**kwargs) + self.risk = risk + self.resource_details = resource_details + self.display_name: Optional[str] = None + self.additional_data = additional_data + self.links: Optional["_models.AssessmentLinks"] = None + self.metadata = metadata + self.partners_data = partners_data + self.status = status + + +class SecurityAssessmentList(_serialization.Model): + """Page of a security assessments list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of security assessments in this page. + :vartype value: list[~azure.mgmt.security.models.SecurityAssessmentResponse] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityAssessmentResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.SecurityAssessmentResponse"]] = None + self.next_link: Optional[str] = None + + +class SecurityAssessmentMetadata(Resource): + """Security assessment metadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: User friendly display name of the assessment. + :vartype display_name: str + :ivar policy_definition_id: Azure resource ID of the policy definition that turns this + assessment calculation on. + :vartype policy_definition_id: str + :ivar description: Human readable description of the assessment. + :vartype description: str + :ivar remediation_description: Human readable description of what you should do to mitigate + this security issue. + :vartype remediation_description: str + :ivar categories: + :vartype categories: list[str or ~azure.mgmt.security.models.Categories] + :ivar severity: The severity level of the assessment. Known values are: "Low", "Medium", and + "High". + :vartype severity: str or ~azure.mgmt.security.models.Severity + :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and + "High". + :vartype user_impact: str or ~azure.mgmt.security.models.UserImpact + :ivar implementation_effort: The implementation effort required to remediate this assessment. + Known values are: "Low", "Moderate", and "High". + :vartype implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort + :ivar threats: + :vartype threats: list[str or ~azure.mgmt.security.models.Threats] + :ivar preview: True if this assessment is in preview release status. + :vartype preview: bool + :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, + Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", + "CustomPolicy", "CustomerManaged", "BuiltInPolicy", "VerifiedPartner", "ManualBuiltInPolicy", + "ManualBuiltIn", "ManualCustomPolicy", and "DynamicBuiltIn". + :vartype assessment_type: str or ~azure.mgmt.security.models.AssessmentType + :ivar partner_data: Describes the partner that created the assessment. + :vartype partner_data: ~azure.mgmt.security.models.SecurityAssessmentMetadataPartnerData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_definition_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, + "categories": {"key": "properties.categories", "type": "[str]"}, + "severity": {"key": "properties.severity", "type": "str"}, + "user_impact": {"key": "properties.userImpact", "type": "str"}, + "implementation_effort": {"key": "properties.implementationEffort", "type": "str"}, + "threats": {"key": "properties.threats", "type": "[str]"}, + "preview": {"key": "properties.preview", "type": "bool"}, + "assessment_type": {"key": "properties.assessmentType", "type": "str"}, + "partner_data": {"key": "properties.partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + remediation_description: Optional[str] = None, + categories: Optional[List[Union[str, "_models.Categories"]]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + user_impact: Optional[Union[str, "_models.UserImpact"]] = None, + implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, + threats: Optional[List[Union[str, "_models.Threats"]]] = None, + preview: Optional[bool] = None, + assessment_type: Optional[Union[str, "_models.AssessmentType"]] = None, + partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: User friendly display name of the assessment. + :paramtype display_name: str + :keyword description: Human readable description of the assessment. + :paramtype description: str + :keyword remediation_description: Human readable description of what you should do to mitigate + this security issue. + :paramtype remediation_description: str + :keyword categories: + :paramtype categories: list[str or ~azure.mgmt.security.models.Categories] + :keyword severity: The severity level of the assessment. Known values are: "Low", "Medium", and + "High". + :paramtype severity: str or ~azure.mgmt.security.models.Severity + :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", + and "High". + :paramtype user_impact: str or ~azure.mgmt.security.models.UserImpact + :keyword implementation_effort: The implementation effort required to remediate this + assessment. Known values are: "Low", "Moderate", and "High". + :paramtype implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort + :keyword threats: + :paramtype threats: list[str or ~azure.mgmt.security.models.Threats] + :keyword preview: True if this assessment is in preview release status. + :paramtype preview: bool + :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, + Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", + "CustomPolicy", "CustomerManaged", "BuiltInPolicy", "VerifiedPartner", "ManualBuiltInPolicy", + "ManualBuiltIn", "ManualCustomPolicy", and "DynamicBuiltIn". + :paramtype assessment_type: str or ~azure.mgmt.security.models.AssessmentType + :keyword partner_data: Describes the partner that created the assessment. + :paramtype partner_data: ~azure.mgmt.security.models.SecurityAssessmentMetadataPartnerData + """ + super().__init__(**kwargs) + self.display_name = display_name + self.policy_definition_id: Optional[str] = None + self.description = description + self.remediation_description = remediation_description + self.categories = categories + self.severity = severity + self.user_impact = user_impact + self.implementation_effort = implementation_effort + self.threats = threats + self.preview = preview + self.assessment_type = assessment_type + self.partner_data = partner_data + + +class SecurityAssessmentMetadataPartnerData(_serialization.Model): + """Describes the partner that created the assessment. + + All required parameters must be populated in order to send to server. + + :ivar partner_name: Name of the company of the partner. Required. + :vartype partner_name: str + :ivar product_name: Name of the product of the partner that created the assessment. + :vartype product_name: str + :ivar secret: Secret to authenticate the partner and verify it created the assessment - write + only. Required. + :vartype secret: str + """ + + _validation = { + "partner_name": {"required": True}, + "secret": {"required": True}, + } + + _attribute_map = { + "partner_name": {"key": "partnerName", "type": "str"}, + "product_name": {"key": "productName", "type": "str"}, + "secret": {"key": "secret", "type": "str"}, + } + + def __init__(self, *, partner_name: str, secret: str, product_name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword partner_name: Name of the company of the partner. Required. + :paramtype partner_name: str + :keyword product_name: Name of the product of the partner that created the assessment. + :paramtype product_name: str + :keyword secret: Secret to authenticate the partner and verify it created the assessment - + write only. Required. + :paramtype secret: str + """ + super().__init__(**kwargs) + self.partner_name = partner_name + self.product_name = product_name + self.secret = secret + + +class SecurityAssessmentMetadataProperties(_serialization.Model): + """Describes properties of an assessment metadata. + + 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 display_name: User friendly display name of the assessment. Required. + :vartype display_name: str + :ivar policy_definition_id: Azure resource ID of the policy definition that turns this + assessment calculation on. + :vartype policy_definition_id: str + :ivar description: Human readable description of the assessment. + :vartype description: str + :ivar remediation_description: Human readable description of what you should do to mitigate + this security issue. + :vartype remediation_description: str + :ivar categories: + :vartype categories: list[str or ~azure.mgmt.security.models.Categories] + :ivar severity: The severity level of the assessment. Required. Known values are: "Low", + "Medium", and "High". + :vartype severity: str or ~azure.mgmt.security.models.Severity + :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and + "High". + :vartype user_impact: str or ~azure.mgmt.security.models.UserImpact + :ivar implementation_effort: The implementation effort required to remediate this assessment. + Known values are: "Low", "Moderate", and "High". + :vartype implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort + :ivar threats: + :vartype threats: list[str or ~azure.mgmt.security.models.Threats] + :ivar preview: True if this assessment is in preview release status. + :vartype preview: bool + :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, + Custom if the assessment based on custom Azure Policy definition. Required. Known values are: + "BuiltIn", "CustomPolicy", "CustomerManaged", "BuiltInPolicy", "VerifiedPartner", + "ManualBuiltInPolicy", "ManualBuiltIn", "ManualCustomPolicy", and "DynamicBuiltIn". + :vartype assessment_type: str or ~azure.mgmt.security.models.AssessmentType + :ivar partner_data: Describes the partner that created the assessment. + :vartype partner_data: ~azure.mgmt.security.models.SecurityAssessmentMetadataPartnerData + """ + + _validation = { + "display_name": {"required": True}, + "policy_definition_id": {"readonly": True}, + "severity": {"required": True}, + "assessment_type": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "remediation_description": {"key": "remediationDescription", "type": "str"}, + "categories": {"key": "categories", "type": "[str]"}, + "severity": {"key": "severity", "type": "str"}, + "user_impact": {"key": "userImpact", "type": "str"}, + "implementation_effort": {"key": "implementationEffort", "type": "str"}, + "threats": {"key": "threats", "type": "[str]"}, + "preview": {"key": "preview", "type": "bool"}, + "assessment_type": {"key": "assessmentType", "type": "str"}, + "partner_data": {"key": "partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, + } + + def __init__( + self, + *, + display_name: str, + severity: Union[str, "_models.Severity"], + assessment_type: Union[str, "_models.AssessmentType"], + description: Optional[str] = None, + remediation_description: Optional[str] = None, + categories: Optional[List[Union[str, "_models.Categories"]]] = None, + user_impact: Optional[Union[str, "_models.UserImpact"]] = None, + implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, + threats: Optional[List[Union[str, "_models.Threats"]]] = None, + preview: Optional[bool] = None, + partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: User friendly display name of the assessment. Required. + :paramtype display_name: str + :keyword description: Human readable description of the assessment. + :paramtype description: str + :keyword remediation_description: Human readable description of what you should do to mitigate + this security issue. + :paramtype remediation_description: str + :keyword categories: + :paramtype categories: list[str or ~azure.mgmt.security.models.Categories] + :keyword severity: The severity level of the assessment. Required. Known values are: "Low", + "Medium", and "High". + :paramtype severity: str or ~azure.mgmt.security.models.Severity + :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", + and "High". + :paramtype user_impact: str or ~azure.mgmt.security.models.UserImpact + :keyword implementation_effort: The implementation effort required to remediate this + assessment. Known values are: "Low", "Moderate", and "High". + :paramtype implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort + :keyword threats: + :paramtype threats: list[str or ~azure.mgmt.security.models.Threats] + :keyword preview: True if this assessment is in preview release status. + :paramtype preview: bool + :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, + Custom if the assessment based on custom Azure Policy definition. Required. Known values are: + "BuiltIn", "CustomPolicy", "CustomerManaged", "BuiltInPolicy", "VerifiedPartner", + "ManualBuiltInPolicy", "ManualBuiltIn", "ManualCustomPolicy", and "DynamicBuiltIn". + :paramtype assessment_type: str or ~azure.mgmt.security.models.AssessmentType + :keyword partner_data: Describes the partner that created the assessment. + :paramtype partner_data: ~azure.mgmt.security.models.SecurityAssessmentMetadataPartnerData + """ + super().__init__(**kwargs) + self.display_name = display_name + self.policy_definition_id: Optional[str] = None + self.description = description + self.remediation_description = remediation_description + self.categories = categories + self.severity = severity + self.user_impact = user_impact + self.implementation_effort = implementation_effort + self.threats = threats + self.preview = preview + self.assessment_type = assessment_type + self.partner_data = partner_data + + +class SecurityAssessmentMetadataPropertiesResponse( + SecurityAssessmentMetadataProperties +): # pylint: disable=name-too-long + """Describes properties of an assessment metadata response. + + 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 display_name: User friendly display name of the assessment. Required. + :vartype display_name: str + :ivar policy_definition_id: Azure resource ID of the policy definition that turns this + assessment calculation on. + :vartype policy_definition_id: str + :ivar description: Human readable description of the assessment. + :vartype description: str + :ivar remediation_description: Human readable description of what you should do to mitigate + this security issue. + :vartype remediation_description: str + :ivar categories: + :vartype categories: list[str or ~azure.mgmt.security.models.Categories] + :ivar severity: The severity level of the assessment. Required. Known values are: "Low", + "Medium", and "High". + :vartype severity: str or ~azure.mgmt.security.models.Severity + :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and + "High". + :vartype user_impact: str or ~azure.mgmt.security.models.UserImpact + :ivar implementation_effort: The implementation effort required to remediate this assessment. + Known values are: "Low", "Moderate", and "High". + :vartype implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort + :ivar threats: + :vartype threats: list[str or ~azure.mgmt.security.models.Threats] + :ivar preview: True if this assessment is in preview release status. + :vartype preview: bool + :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, + Custom if the assessment based on custom Azure Policy definition. Required. Known values are: + "BuiltIn", "CustomPolicy", "CustomerManaged", "BuiltInPolicy", "VerifiedPartner", + "ManualBuiltInPolicy", "ManualBuiltIn", "ManualCustomPolicy", and "DynamicBuiltIn". + :vartype assessment_type: str or ~azure.mgmt.security.models.AssessmentType + :ivar partner_data: Describes the partner that created the assessment. + :vartype partner_data: ~azure.mgmt.security.models.SecurityAssessmentMetadataPartnerData + :ivar publish_dates: + :vartype publish_dates: + ~azure.mgmt.security.models.SecurityAssessmentMetadataPropertiesResponsePublishDates + :ivar planned_deprecation_date: + :vartype planned_deprecation_date: str + :ivar tactics: + :vartype tactics: list[str or ~azure.mgmt.security.models.Tactics] + :ivar techniques: + :vartype techniques: list[str or ~azure.mgmt.security.models.Techniques] + """ + + _validation = { + "display_name": {"required": True}, + "policy_definition_id": {"readonly": True}, + "severity": {"required": True}, + "assessment_type": {"required": True}, + "planned_deprecation_date": {"pattern": r"^[0-9]{2}/[0-9]{4}$"}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "remediation_description": {"key": "remediationDescription", "type": "str"}, + "categories": {"key": "categories", "type": "[str]"}, + "severity": {"key": "severity", "type": "str"}, + "user_impact": {"key": "userImpact", "type": "str"}, + "implementation_effort": {"key": "implementationEffort", "type": "str"}, + "threats": {"key": "threats", "type": "[str]"}, + "preview": {"key": "preview", "type": "bool"}, + "assessment_type": {"key": "assessmentType", "type": "str"}, + "partner_data": {"key": "partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, + "publish_dates": {"key": "publishDates", "type": "SecurityAssessmentMetadataPropertiesResponsePublishDates"}, + "planned_deprecation_date": {"key": "plannedDeprecationDate", "type": "str"}, + "tactics": {"key": "tactics", "type": "[str]"}, + "techniques": {"key": "techniques", "type": "[str]"}, + } + + def __init__( + self, + *, + display_name: str, + severity: Union[str, "_models.Severity"], + assessment_type: Union[str, "_models.AssessmentType"], + description: Optional[str] = None, + remediation_description: Optional[str] = None, + categories: Optional[List[Union[str, "_models.Categories"]]] = None, + user_impact: Optional[Union[str, "_models.UserImpact"]] = None, + implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, + threats: Optional[List[Union[str, "_models.Threats"]]] = None, + preview: Optional[bool] = None, + partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, + publish_dates: Optional["_models.SecurityAssessmentMetadataPropertiesResponsePublishDates"] = None, + planned_deprecation_date: Optional[str] = None, + tactics: Optional[List[Union[str, "_models.Tactics"]]] = None, + techniques: Optional[List[Union[str, "_models.Techniques"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: User friendly display name of the assessment. Required. + :paramtype display_name: str + :keyword description: Human readable description of the assessment. + :paramtype description: str + :keyword remediation_description: Human readable description of what you should do to mitigate + this security issue. + :paramtype remediation_description: str + :keyword categories: + :paramtype categories: list[str or ~azure.mgmt.security.models.Categories] + :keyword severity: The severity level of the assessment. Required. Known values are: "Low", + "Medium", and "High". + :paramtype severity: str or ~azure.mgmt.security.models.Severity + :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", + and "High". + :paramtype user_impact: str or ~azure.mgmt.security.models.UserImpact + :keyword implementation_effort: The implementation effort required to remediate this + assessment. Known values are: "Low", "Moderate", and "High". + :paramtype implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort + :keyword threats: + :paramtype threats: list[str or ~azure.mgmt.security.models.Threats] + :keyword preview: True if this assessment is in preview release status. + :paramtype preview: bool + :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, + Custom if the assessment based on custom Azure Policy definition. Required. Known values are: + "BuiltIn", "CustomPolicy", "CustomerManaged", "BuiltInPolicy", "VerifiedPartner", + "ManualBuiltInPolicy", "ManualBuiltIn", "ManualCustomPolicy", and "DynamicBuiltIn". + :paramtype assessment_type: str or ~azure.mgmt.security.models.AssessmentType + :keyword partner_data: Describes the partner that created the assessment. + :paramtype partner_data: ~azure.mgmt.security.models.SecurityAssessmentMetadataPartnerData + :keyword publish_dates: + :paramtype publish_dates: + ~azure.mgmt.security.models.SecurityAssessmentMetadataPropertiesResponsePublishDates + :keyword planned_deprecation_date: + :paramtype planned_deprecation_date: str + :keyword tactics: + :paramtype tactics: list[str or ~azure.mgmt.security.models.Tactics] + :keyword techniques: + :paramtype techniques: list[str or ~azure.mgmt.security.models.Techniques] + """ + super().__init__( + display_name=display_name, + description=description, + remediation_description=remediation_description, + categories=categories, + severity=severity, + user_impact=user_impact, + implementation_effort=implementation_effort, + threats=threats, + preview=preview, + assessment_type=assessment_type, + partner_data=partner_data, + **kwargs + ) + self.publish_dates = publish_dates + self.planned_deprecation_date = planned_deprecation_date + self.tactics = tactics + self.techniques = techniques + + +class SecurityAssessmentMetadataPropertiesResponsePublishDates(_serialization.Model): # pylint: disable=name-too-long + """SecurityAssessmentMetadataPropertiesResponsePublishDates. + + All required parameters must be populated in order to send to server. + + :ivar ga: + :vartype ga: str + :ivar public: Required. + :vartype public: str + """ + + _validation = { + "ga": {"pattern": r"^([0-9]{2}/){2}[0-9]{4}$"}, + "public": {"required": True, "pattern": r"^([0-9]{2}/){2}[0-9]{4}$"}, + } + + _attribute_map = { + "ga": {"key": "GA", "type": "str"}, + "public": {"key": "public", "type": "str"}, + } + + def __init__(self, *, public: str, ga: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword ga: + :paramtype ga: str + :keyword public: Required. + :paramtype public: str + """ + super().__init__(**kwargs) + self.ga = ga + self.public = public + + +class SecurityAssessmentMetadataResponse(Resource): + """Security assessment metadata response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: User friendly display name of the assessment. + :vartype display_name: str + :ivar policy_definition_id: Azure resource ID of the policy definition that turns this + assessment calculation on. + :vartype policy_definition_id: str + :ivar description: Human readable description of the assessment. + :vartype description: str + :ivar remediation_description: Human readable description of what you should do to mitigate + this security issue. + :vartype remediation_description: str + :ivar categories: + :vartype categories: list[str or ~azure.mgmt.security.models.Categories] + :ivar severity: The severity level of the assessment. Known values are: "Low", "Medium", and + "High". + :vartype severity: str or ~azure.mgmt.security.models.Severity + :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and + "High". + :vartype user_impact: str or ~azure.mgmt.security.models.UserImpact + :ivar implementation_effort: The implementation effort required to remediate this assessment. + Known values are: "Low", "Moderate", and "High". + :vartype implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort + :ivar threats: + :vartype threats: list[str or ~azure.mgmt.security.models.Threats] + :ivar preview: True if this assessment is in preview release status. + :vartype preview: bool + :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, + Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", + "CustomPolicy", "CustomerManaged", "BuiltInPolicy", "VerifiedPartner", "ManualBuiltInPolicy", + "ManualBuiltIn", "ManualCustomPolicy", and "DynamicBuiltIn". + :vartype assessment_type: str or ~azure.mgmt.security.models.AssessmentType + :ivar partner_data: Describes the partner that created the assessment. + :vartype partner_data: ~azure.mgmt.security.models.SecurityAssessmentMetadataPartnerData + :ivar publish_dates: + :vartype publish_dates: + ~azure.mgmt.security.models.SecurityAssessmentMetadataPropertiesResponsePublishDates + :ivar planned_deprecation_date: + :vartype planned_deprecation_date: str + :ivar tactics: + :vartype tactics: list[str or ~azure.mgmt.security.models.Tactics] + :ivar techniques: + :vartype techniques: list[str or ~azure.mgmt.security.models.Techniques] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_definition_id": {"readonly": True}, + "planned_deprecation_date": {"pattern": r"^[0-9]{2}/[0-9]{4}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, + "categories": {"key": "properties.categories", "type": "[str]"}, + "severity": {"key": "properties.severity", "type": "str"}, + "user_impact": {"key": "properties.userImpact", "type": "str"}, + "implementation_effort": {"key": "properties.implementationEffort", "type": "str"}, + "threats": {"key": "properties.threats", "type": "[str]"}, + "preview": {"key": "properties.preview", "type": "bool"}, + "assessment_type": {"key": "properties.assessmentType", "type": "str"}, + "partner_data": {"key": "properties.partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, + "publish_dates": { + "key": "properties.publishDates", + "type": "SecurityAssessmentMetadataPropertiesResponsePublishDates", + }, + "planned_deprecation_date": {"key": "properties.plannedDeprecationDate", "type": "str"}, + "tactics": {"key": "properties.tactics", "type": "[str]"}, + "techniques": {"key": "properties.techniques", "type": "[str]"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + remediation_description: Optional[str] = None, + categories: Optional[List[Union[str, "_models.Categories"]]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + user_impact: Optional[Union[str, "_models.UserImpact"]] = None, + implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, + threats: Optional[List[Union[str, "_models.Threats"]]] = None, + preview: Optional[bool] = None, + assessment_type: Optional[Union[str, "_models.AssessmentType"]] = None, + partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, + publish_dates: Optional["_models.SecurityAssessmentMetadataPropertiesResponsePublishDates"] = None, + planned_deprecation_date: Optional[str] = None, + tactics: Optional[List[Union[str, "_models.Tactics"]]] = None, + techniques: Optional[List[Union[str, "_models.Techniques"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: User friendly display name of the assessment. + :paramtype display_name: str + :keyword description: Human readable description of the assessment. + :paramtype description: str + :keyword remediation_description: Human readable description of what you should do to mitigate + this security issue. + :paramtype remediation_description: str + :keyword categories: + :paramtype categories: list[str or ~azure.mgmt.security.models.Categories] + :keyword severity: The severity level of the assessment. Known values are: "Low", "Medium", and + "High". + :paramtype severity: str or ~azure.mgmt.security.models.Severity + :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", + and "High". + :paramtype user_impact: str or ~azure.mgmt.security.models.UserImpact + :keyword implementation_effort: The implementation effort required to remediate this + assessment. Known values are: "Low", "Moderate", and "High". + :paramtype implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort + :keyword threats: + :paramtype threats: list[str or ~azure.mgmt.security.models.Threats] + :keyword preview: True if this assessment is in preview release status. + :paramtype preview: bool + :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, + Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", + "CustomPolicy", "CustomerManaged", "BuiltInPolicy", "VerifiedPartner", "ManualBuiltInPolicy", + "ManualBuiltIn", "ManualCustomPolicy", and "DynamicBuiltIn". + :paramtype assessment_type: str or ~azure.mgmt.security.models.AssessmentType + :keyword partner_data: Describes the partner that created the assessment. + :paramtype partner_data: ~azure.mgmt.security.models.SecurityAssessmentMetadataPartnerData + :keyword publish_dates: + :paramtype publish_dates: + ~azure.mgmt.security.models.SecurityAssessmentMetadataPropertiesResponsePublishDates + :keyword planned_deprecation_date: + :paramtype planned_deprecation_date: str + :keyword tactics: + :paramtype tactics: list[str or ~azure.mgmt.security.models.Tactics] + :keyword techniques: + :paramtype techniques: list[str or ~azure.mgmt.security.models.Techniques] + """ + super().__init__(**kwargs) + self.display_name = display_name + self.policy_definition_id: Optional[str] = None + self.description = description + self.remediation_description = remediation_description + self.categories = categories + self.severity = severity + self.user_impact = user_impact + self.implementation_effort = implementation_effort + self.threats = threats + self.preview = preview + self.assessment_type = assessment_type + self.partner_data = partner_data + self.publish_dates = publish_dates + self.planned_deprecation_date = planned_deprecation_date + self.tactics = tactics + self.techniques = techniques + + +class SecurityAssessmentMetadataResponseList(_serialization.Model): + """List of security assessment metadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.SecurityAssessmentMetadataResponse] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityAssessmentMetadataResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.SecurityAssessmentMetadataResponse"]] = None + self.next_link: Optional[str] = None + + +class SecurityAssessmentPartnerData(_serialization.Model): + """Data regarding 3rd party partner integration. + + All required parameters must be populated in order to send to server. + + :ivar partner_name: Name of the company of the partner. Required. + :vartype partner_name: str + :ivar secret: secret to authenticate the partner - write only. Required. + :vartype secret: str + """ + + _validation = { + "partner_name": {"required": True}, + "secret": {"required": True}, + } + + _attribute_map = { + "partner_name": {"key": "partnerName", "type": "str"}, + "secret": {"key": "secret", "type": "str"}, + } + + def __init__(self, *, partner_name: str, secret: str, **kwargs: Any) -> None: + """ + :keyword partner_name: Name of the company of the partner. Required. + :paramtype partner_name: str + :keyword secret: secret to authenticate the partner - write only. Required. + :paramtype secret: str + """ + super().__init__(**kwargs) + self.partner_name = partner_name + self.secret = secret + + +class SecurityAssessmentPropertiesBase(_serialization.Model): + """Describes properties of an assessment. + + 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 risk: External model of risk result. + :vartype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :ivar resource_details: Details of the resource that was assessed. Required. + :vartype resource_details: ~azure.mgmt.security.models.ResourceDetails + :ivar display_name: User friendly display name of the assessment. + :vartype display_name: str + :ivar additional_data: Additional data regarding the assessment. + :vartype additional_data: dict[str, str] + :ivar links: Links relevant to the assessment. + :vartype links: ~azure.mgmt.security.models.AssessmentLinks + :ivar metadata: Describes properties of an assessment metadata. + :vartype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :ivar partners_data: Data regarding 3rd party partner integration. + :vartype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + """ + + _validation = { + "resource_details": {"required": True}, + "display_name": {"readonly": True}, + "links": {"readonly": True}, + } + + _attribute_map = { + "risk": {"key": "risk", "type": "SecurityAssessmentPropertiesBaseRisk"}, + "resource_details": {"key": "resourceDetails", "type": "ResourceDetails"}, + "display_name": {"key": "displayName", "type": "str"}, + "additional_data": {"key": "additionalData", "type": "{str}"}, + "links": {"key": "links", "type": "AssessmentLinks"}, + "metadata": {"key": "metadata", "type": "SecurityAssessmentMetadataProperties"}, + "partners_data": {"key": "partnersData", "type": "SecurityAssessmentPartnerData"}, + } + + def __init__( + self, + *, + resource_details: "_models.ResourceDetails", + risk: Optional["_models.SecurityAssessmentPropertiesBaseRisk"] = None, + additional_data: Optional[Dict[str, str]] = None, + metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, + partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, + **kwargs: Any + ) -> None: + """ + :keyword risk: External model of risk result. + :paramtype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :keyword resource_details: Details of the resource that was assessed. Required. + :paramtype resource_details: ~azure.mgmt.security.models.ResourceDetails + :keyword additional_data: Additional data regarding the assessment. + :paramtype additional_data: dict[str, str] + :keyword metadata: Describes properties of an assessment metadata. + :paramtype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :keyword partners_data: Data regarding 3rd party partner integration. + :paramtype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + """ + super().__init__(**kwargs) + self.risk = risk + self.resource_details = resource_details + self.display_name: Optional[str] = None + self.additional_data = additional_data + self.links: Optional["_models.AssessmentLinks"] = None + self.metadata = metadata + self.partners_data = partners_data + + +class SecurityAssessmentProperties(SecurityAssessmentPropertiesBase): + """Describes properties of an assessment. + + 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 risk: External model of risk result. + :vartype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :ivar resource_details: Details of the resource that was assessed. Required. + :vartype resource_details: ~azure.mgmt.security.models.ResourceDetails + :ivar display_name: User friendly display name of the assessment. + :vartype display_name: str + :ivar additional_data: Additional data regarding the assessment. + :vartype additional_data: dict[str, str] + :ivar links: Links relevant to the assessment. + :vartype links: ~azure.mgmt.security.models.AssessmentLinks + :ivar metadata: Describes properties of an assessment metadata. + :vartype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :ivar partners_data: Data regarding 3rd party partner integration. + :vartype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + :ivar status: The result of the assessment. Required. + :vartype status: ~azure.mgmt.security.models.AssessmentStatus + """ + + _validation = { + "resource_details": {"required": True}, + "display_name": {"readonly": True}, + "links": {"readonly": True}, + "status": {"required": True}, + } + + _attribute_map = { + "risk": {"key": "risk", "type": "SecurityAssessmentPropertiesBaseRisk"}, + "resource_details": {"key": "resourceDetails", "type": "ResourceDetails"}, + "display_name": {"key": "displayName", "type": "str"}, + "additional_data": {"key": "additionalData", "type": "{str}"}, + "links": {"key": "links", "type": "AssessmentLinks"}, + "metadata": {"key": "metadata", "type": "SecurityAssessmentMetadataProperties"}, + "partners_data": {"key": "partnersData", "type": "SecurityAssessmentPartnerData"}, + "status": {"key": "status", "type": "AssessmentStatus"}, + } + + def __init__( + self, + *, + resource_details: "_models.ResourceDetails", + status: "_models.AssessmentStatus", + risk: Optional["_models.SecurityAssessmentPropertiesBaseRisk"] = None, + additional_data: Optional[Dict[str, str]] = None, + metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, + partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, + **kwargs: Any + ) -> None: + """ + :keyword risk: External model of risk result. + :paramtype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :keyword resource_details: Details of the resource that was assessed. Required. + :paramtype resource_details: ~azure.mgmt.security.models.ResourceDetails + :keyword additional_data: Additional data regarding the assessment. + :paramtype additional_data: dict[str, str] + :keyword metadata: Describes properties of an assessment metadata. + :paramtype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :keyword partners_data: Data regarding 3rd party partner integration. + :paramtype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + :keyword status: The result of the assessment. Required. + :paramtype status: ~azure.mgmt.security.models.AssessmentStatus + """ + super().__init__( + risk=risk, + resource_details=resource_details, + additional_data=additional_data, + metadata=metadata, + partners_data=partners_data, + **kwargs + ) + self.status = status + + +class SecurityAssessmentPropertiesBaseRisk(_serialization.Model): + """External model of risk result. + + :ivar risk_factors: The factors of the risk adding base factor. + :vartype risk_factors: list[str] + :ivar level: The risk level. Known values are: "Low", "Medium", and "High". + :vartype level: str or ~azure.mgmt.security.models.RiskLevel + :ivar attack_paths_references: The attack paths references of the risk. + :vartype attack_paths_references: list[str] + :ivar paths: + :vartype paths: list[~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRiskPathsItem] + :ivar is_contextual_risk: Indicates if the risk is contextual or static. + :vartype is_contextual_risk: bool + """ + + _validation = { + "risk_factors": {"unique": True}, + } + + _attribute_map = { + "risk_factors": {"key": "riskFactors", "type": "[str]"}, + "level": {"key": "level", "type": "str"}, + "attack_paths_references": {"key": "attackPathsReferences", "type": "[str]"}, + "paths": {"key": "paths", "type": "[SecurityAssessmentPropertiesBaseRiskPathsItem]"}, + "is_contextual_risk": {"key": "isContextualRisk", "type": "bool"}, + } + + def __init__( + self, + *, + risk_factors: Optional[List[str]] = None, + level: Optional[Union[str, "_models.RiskLevel"]] = None, + attack_paths_references: Optional[List[str]] = None, + paths: Optional[List["_models.SecurityAssessmentPropertiesBaseRiskPathsItem"]] = None, + is_contextual_risk: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword risk_factors: The factors of the risk adding base factor. + :paramtype risk_factors: list[str] + :keyword level: The risk level. Known values are: "Low", "Medium", and "High". + :paramtype level: str or ~azure.mgmt.security.models.RiskLevel + :keyword attack_paths_references: The attack paths references of the risk. + :paramtype attack_paths_references: list[str] + :keyword paths: + :paramtype paths: + list[~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRiskPathsItem] + :keyword is_contextual_risk: Indicates if the risk is contextual or static. + :paramtype is_contextual_risk: bool + """ + super().__init__(**kwargs) + self.risk_factors = risk_factors + self.level = level + self.attack_paths_references = attack_paths_references + self.paths = paths + self.is_contextual_risk = is_contextual_risk + + +class SecurityAssessmentPropertiesBaseRiskPathsItem(_serialization.Model): # pylint: disable=name-too-long + """SecurityAssessmentPropertiesBaseRiskPathsItem. + + :ivar id: Unique identifier for the path. + :vartype id: str + :ivar nodes: + :vartype nodes: + list[~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRiskPathsPropertiesItemsItem] + :ivar edges: Connections between nodes. + :vartype edges: + list[~azure.mgmt.security.models.Components1Uu4J47SchemasSecurityassessmentpropertiesbasePropertiesRiskPropertiesPathsItemsPropertiesEdgesItems] + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "nodes": {"key": "nodes", "type": "[SecurityAssessmentPropertiesBaseRiskPathsPropertiesItemsItem]"}, + "edges": { + "key": "edges", + "type": "[Components1Uu4J47SchemasSecurityassessmentpropertiesbasePropertiesRiskPropertiesPathsItemsPropertiesEdgesItems]", + }, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + nodes: Optional[List["_models.SecurityAssessmentPropertiesBaseRiskPathsPropertiesItemsItem"]] = None, + edges: Optional[ + List[ + "_models.Components1Uu4J47SchemasSecurityassessmentpropertiesbasePropertiesRiskPropertiesPathsItemsPropertiesEdgesItems" + ] + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Unique identifier for the path. + :paramtype id: str + :keyword nodes: + :paramtype nodes: + list[~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRiskPathsPropertiesItemsItem] + :keyword edges: Connections between nodes. + :paramtype edges: + list[~azure.mgmt.security.models.Components1Uu4J47SchemasSecurityassessmentpropertiesbasePropertiesRiskPropertiesPathsItemsPropertiesEdgesItems] + """ + super().__init__(**kwargs) + self.id = id + self.nodes = nodes + self.edges = edges + + +class SecurityAssessmentPropertiesBaseRiskPathsPropertiesItemsItem( + _serialization.Model +): # pylint: disable=name-too-long + """SecurityAssessmentPropertiesBaseRiskPathsPropertiesItemsItem. + + :ivar id: Node identifier. + :vartype id: str + :ivar node_properties_label: Properties associated with the node. + :vartype node_properties_label: list[str] + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "node_properties_label": {"key": "nodePropertiesLabel", "type": "[str]"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + node_properties_label: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Node identifier. + :paramtype id: str + :keyword node_properties_label: Properties associated with the node. + :paramtype node_properties_label: list[str] + """ + super().__init__(**kwargs) + self.id = id + self.node_properties_label = node_properties_label + + +class SecurityAssessmentPropertiesResponse(SecurityAssessmentPropertiesBase): + """Describes properties of an assessment. + + 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 risk: External model of risk result. + :vartype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :ivar resource_details: Details of the resource that was assessed. Required. + :vartype resource_details: ~azure.mgmt.security.models.ResourceDetails + :ivar display_name: User friendly display name of the assessment. + :vartype display_name: str + :ivar additional_data: Additional data regarding the assessment. + :vartype additional_data: dict[str, str] + :ivar links: Links relevant to the assessment. + :vartype links: ~azure.mgmt.security.models.AssessmentLinks + :ivar metadata: Describes properties of an assessment metadata. + :vartype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :ivar partners_data: Data regarding 3rd party partner integration. + :vartype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + :ivar status: The result of the assessment. Required. + :vartype status: ~azure.mgmt.security.models.AssessmentStatusResponse + """ + + _validation = { + "resource_details": {"required": True}, + "display_name": {"readonly": True}, + "links": {"readonly": True}, + "status": {"required": True}, + } + + _attribute_map = { + "risk": {"key": "risk", "type": "SecurityAssessmentPropertiesBaseRisk"}, + "resource_details": {"key": "resourceDetails", "type": "ResourceDetails"}, + "display_name": {"key": "displayName", "type": "str"}, + "additional_data": {"key": "additionalData", "type": "{str}"}, + "links": {"key": "links", "type": "AssessmentLinks"}, + "metadata": {"key": "metadata", "type": "SecurityAssessmentMetadataProperties"}, + "partners_data": {"key": "partnersData", "type": "SecurityAssessmentPartnerData"}, + "status": {"key": "status", "type": "AssessmentStatusResponse"}, + } + + def __init__( + self, + *, + resource_details: "_models.ResourceDetails", + status: "_models.AssessmentStatusResponse", + risk: Optional["_models.SecurityAssessmentPropertiesBaseRisk"] = None, + additional_data: Optional[Dict[str, str]] = None, + metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, + partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, + **kwargs: Any + ) -> None: + """ + :keyword risk: External model of risk result. + :paramtype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :keyword resource_details: Details of the resource that was assessed. Required. + :paramtype resource_details: ~azure.mgmt.security.models.ResourceDetails + :keyword additional_data: Additional data regarding the assessment. + :paramtype additional_data: dict[str, str] + :keyword metadata: Describes properties of an assessment metadata. + :paramtype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :keyword partners_data: Data regarding 3rd party partner integration. + :paramtype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + :keyword status: The result of the assessment. Required. + :paramtype status: ~azure.mgmt.security.models.AssessmentStatusResponse + """ + super().__init__( + risk=risk, + resource_details=resource_details, + additional_data=additional_data, + metadata=metadata, + partners_data=partners_data, + **kwargs + ) + self.status = status + + +class SecurityAssessmentResponse(Resource): + """Security assessment on a resource - response format. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar risk: External model of risk result. + :vartype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :ivar resource_details: Details of the resource that was assessed. + :vartype resource_details: ~azure.mgmt.security.models.ResourceDetails + :ivar display_name: User friendly display name of the assessment. + :vartype display_name: str + :ivar additional_data: Additional data regarding the assessment. + :vartype additional_data: dict[str, str] + :ivar links: Links relevant to the assessment. + :vartype links: ~azure.mgmt.security.models.AssessmentLinks + :ivar metadata: Describes properties of an assessment metadata. + :vartype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :ivar partners_data: Data regarding 3rd party partner integration. + :vartype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + :ivar status: The result of the assessment. + :vartype status: ~azure.mgmt.security.models.AssessmentStatusResponse + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "links": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "risk": {"key": "properties.risk", "type": "SecurityAssessmentPropertiesBaseRisk"}, + "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "additional_data": {"key": "properties.additionalData", "type": "{str}"}, + "links": {"key": "properties.links", "type": "AssessmentLinks"}, + "metadata": {"key": "properties.metadata", "type": "SecurityAssessmentMetadataProperties"}, + "partners_data": {"key": "properties.partnersData", "type": "SecurityAssessmentPartnerData"}, + "status": {"key": "properties.status", "type": "AssessmentStatusResponse"}, + } + + def __init__( + self, + *, + risk: Optional["_models.SecurityAssessmentPropertiesBaseRisk"] = None, + resource_details: Optional["_models.ResourceDetails"] = None, + additional_data: Optional[Dict[str, str]] = None, + metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, + partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, + status: Optional["_models.AssessmentStatusResponse"] = None, + **kwargs: Any + ) -> None: + """ + :keyword risk: External model of risk result. + :paramtype risk: ~azure.mgmt.security.models.SecurityAssessmentPropertiesBaseRisk + :keyword resource_details: Details of the resource that was assessed. + :paramtype resource_details: ~azure.mgmt.security.models.ResourceDetails + :keyword additional_data: Additional data regarding the assessment. + :paramtype additional_data: dict[str, str] + :keyword metadata: Describes properties of an assessment metadata. + :paramtype metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties + :keyword partners_data: Data regarding 3rd party partner integration. + :paramtype partners_data: ~azure.mgmt.security.models.SecurityAssessmentPartnerData + :keyword status: The result of the assessment. + :paramtype status: ~azure.mgmt.security.models.AssessmentStatusResponse + """ + super().__init__(**kwargs) + self.risk = risk + self.resource_details = resource_details + self.display_name: Optional[str] = None + self.additional_data = additional_data + self.links: Optional["_models.AssessmentLinks"] = None + self.metadata = metadata + self.partners_data = partners_data + self.status = status + + +class SecurityConnector(TrackedResource): + """The security connector resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + :ivar kind: Kind of the resource. + :vartype kind: str + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.models.SystemData + :ivar hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS + connector, project number in case of GCP connector). + :vartype hierarchy_identifier: str + :ivar hierarchy_identifier_trial_end_date: The date on which the trial period will end, if + applicable. Trial period exists for 30 days after upgrading to payed offerings. + :vartype hierarchy_identifier_trial_end_date: ~datetime.datetime + :ivar environment_name: The multi cloud resource's cloud name. Known values are: "Azure", + "AWS", "GCP", "Github", "AzureDevOps", "GitLab", "DockerHub", and "JFrog". + :vartype environment_name: str or ~azure.mgmt.security.models.CloudName + :ivar offerings: A collection of offerings for the security connector. + :vartype offerings: list[~azure.mgmt.security.models.CloudOffering] + :ivar environment_data: The security connector environment data. + :vartype environment_data: ~azure.mgmt.security.models.EnvironmentData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "hierarchy_identifier_trial_end_date": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "hierarchy_identifier": {"key": "properties.hierarchyIdentifier", "type": "str"}, + "hierarchy_identifier_trial_end_date": { + "key": "properties.hierarchyIdentifierTrialEndDate", + "type": "iso-8601", + }, + "environment_name": {"key": "properties.environmentName", "type": "str"}, + "offerings": {"key": "properties.offerings", "type": "[CloudOffering]"}, + "environment_data": {"key": "properties.environmentData", "type": "EnvironmentData"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + kind: Optional[str] = None, + location: Optional[str] = None, + hierarchy_identifier: Optional[str] = None, + environment_name: Optional[Union[str, "_models.CloudName"]] = None, + offerings: Optional[List["_models.CloudOffering"]] = None, + environment_data: Optional["_models.EnvironmentData"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + :keyword kind: Kind of the resource. + :paramtype kind: str + :keyword location: Location where the resource is stored. + :paramtype location: str + :keyword hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS + connector, project number in case of GCP connector). + :paramtype hierarchy_identifier: str + :keyword environment_name: The multi cloud resource's cloud name. Known values are: "Azure", + "AWS", "GCP", "Github", "AzureDevOps", "GitLab", "DockerHub", and "JFrog". + :paramtype environment_name: str or ~azure.mgmt.security.models.CloudName + :keyword offerings: A collection of offerings for the security connector. + :paramtype offerings: list[~azure.mgmt.security.models.CloudOffering] + :keyword environment_data: The security connector environment data. + :paramtype environment_data: ~azure.mgmt.security.models.EnvironmentData + """ + super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.hierarchy_identifier = hierarchy_identifier + self.hierarchy_identifier_trial_end_date: Optional[datetime.datetime] = None + self.environment_name = environment_name + self.offerings = offerings + self.environment_data = environment_data + + +class SecurityConnectorsList(_serialization.Model): + """List of security connectors response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of security connectors under the given scope. Required. + :vartype value: list[~azure.mgmt.security.models.SecurityConnector] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityConnector]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.SecurityConnector"], **kwargs: Any) -> None: + """ + :keyword value: The list of security connectors under the given scope. Required. + :paramtype value: list[~azure.mgmt.security.models.SecurityConnector] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class SecurityContact(Resource): + """Contact details and configurations for notifications coming from Microsoft Defender for Cloud. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar emails: List of email addresses which will get notifications from Microsoft Defender for + Cloud by the configurations defined in this security contact. + :vartype emails: str + :ivar phone: The security contact's phone number. + :vartype phone: str + :ivar is_enabled: Indicates whether the security contact is enabled. + :vartype is_enabled: bool + :ivar notifications_sources: A collection of sources types which evaluate the email + notification. + :vartype notifications_sources: list[~azure.mgmt.security.models.NotificationsSource] + :ivar notifications_by_role: Defines whether to send email notifications from Microsoft + Defender for Cloud to persons with specific RBAC roles on the subscription. + :vartype notifications_by_role: + ~azure.mgmt.security.models.SecurityContactPropertiesNotificationsByRole + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "emails": {"key": "properties.emails", "type": "str"}, + "phone": {"key": "properties.phone", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "notifications_sources": {"key": "properties.notificationsSources", "type": "[NotificationsSource]"}, + "notifications_by_role": { + "key": "properties.notificationsByRole", + "type": "SecurityContactPropertiesNotificationsByRole", + }, + } + + def __init__( + self, + *, + emails: Optional[str] = None, + phone: Optional[str] = None, + is_enabled: Optional[bool] = None, + notifications_sources: Optional[List["_models.NotificationsSource"]] = None, + notifications_by_role: Optional["_models.SecurityContactPropertiesNotificationsByRole"] = None, + **kwargs: Any + ) -> None: + """ + :keyword emails: List of email addresses which will get notifications from Microsoft Defender + for Cloud by the configurations defined in this security contact. + :paramtype emails: str + :keyword phone: The security contact's phone number. + :paramtype phone: str + :keyword is_enabled: Indicates whether the security contact is enabled. + :paramtype is_enabled: bool + :keyword notifications_sources: A collection of sources types which evaluate the email + notification. + :paramtype notifications_sources: list[~azure.mgmt.security.models.NotificationsSource] + :keyword notifications_by_role: Defines whether to send email notifications from Microsoft + Defender for Cloud to persons with specific RBAC roles on the subscription. + :paramtype notifications_by_role: + ~azure.mgmt.security.models.SecurityContactPropertiesNotificationsByRole + """ + super().__init__(**kwargs) + self.emails = emails + self.phone = phone + self.is_enabled = is_enabled + self.notifications_sources = notifications_sources + self.notifications_by_role = notifications_by_role + + +class SecurityContactList(_serialization.Model): + """List of security contacts response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: List of security contacts. Required. + :vartype value: list[~azure.mgmt.security.models.SecurityContact] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityContact]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.SecurityContact"], **kwargs: Any) -> None: + """ + :keyword value: List of security contacts. Required. + :paramtype value: list[~azure.mgmt.security.models.SecurityContact] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class SecurityContactPropertiesNotificationsByRole(_serialization.Model): # pylint: disable=name-too-long + """Defines whether to send email notifications from Microsoft Defender for Cloud to persons with + specific RBAC roles on the subscription. + + :ivar state: Defines whether to send email notifications from AMicrosoft Defender for Cloud to + persons with specific RBAC roles on the subscription. Known values are: "Passed", "Failed", + "Skipped", and "Unsupported". + :vartype state: str or ~azure.mgmt.security.models.State + :ivar roles: Defines which RBAC roles will get email notifications from Microsoft Defender for + Cloud. List of allowed RBAC roles:. + :vartype roles: list[str or ~azure.mgmt.security.models.SecurityContactRole] + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "roles": {"key": "roles", "type": "[str]"}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.State"]] = None, + roles: Optional[List[Union[str, "_models.SecurityContactRole"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword state: Defines whether to send email notifications from AMicrosoft Defender for Cloud + to persons with specific RBAC roles on the subscription. Known values are: "Passed", "Failed", + "Skipped", and "Unsupported". + :paramtype state: str or ~azure.mgmt.security.models.State + :keyword roles: Defines which RBAC roles will get email notifications from Microsoft Defender + for Cloud. List of allowed RBAC roles:. + :paramtype roles: list[str or ~azure.mgmt.security.models.SecurityContactRole] + """ + super().__init__(**kwargs) + self.state = state + self.roles = roles + + +class SecurityOperator(Resource): + """Security operator under a given subscription and pricing. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.security.models.Identity + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + } + + def __init__(self, *, identity: Optional["_models.Identity"] = None, **kwargs: Any) -> None: + """ + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.security.models.Identity + """ + super().__init__(**kwargs) + self.identity = identity + + +class SecurityOperatorList(_serialization.Model): + """List of SecurityOperator response. + + All required parameters must be populated in order to send to server. + + :ivar value: List of SecurityOperator configurations. Required. + :vartype value: list[~azure.mgmt.security.models.SecurityOperator] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityOperator]"}, + } + + def __init__(self, *, value: List["_models.SecurityOperator"], **kwargs: Any) -> None: + """ + :keyword value: List of SecurityOperator configurations. Required. + :paramtype value: list[~azure.mgmt.security.models.SecurityOperator] + """ + super().__init__(**kwargs) + self.value = value + + +class SecuritySolution(Resource, Location): + """SecuritySolution. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar security_family: The security family of the security solution. Known values are: "Waf", + "Ngfw", "SaasWaf", and "Va". + :vartype security_family: str or ~azure.mgmt.security.models.SecurityFamily + :ivar provisioning_state: The security family provisioning State. Known values are: + "Succeeded", "Failed", and "Updating". + :vartype provisioning_state: str or ~azure.mgmt.security.models.ProvisioningState + :ivar template: The security solutions' template. + :vartype template: str + :ivar protection_status: The security solutions' status. + :vartype protection_status: str + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "security_family": {"key": "properties.securityFamily", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "template": {"key": "properties.template", "type": "str"}, + "protection_status": {"key": "properties.protectionStatus", "type": "str"}, + } + + def __init__( + self, + *, + security_family: Optional[Union[str, "_models.SecurityFamily"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + template: Optional[str] = None, + protection_status: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword security_family: The security family of the security solution. Known values are: + "Waf", "Ngfw", "SaasWaf", and "Va". + :paramtype security_family: str or ~azure.mgmt.security.models.SecurityFamily + :keyword provisioning_state: The security family provisioning State. Known values are: + "Succeeded", "Failed", and "Updating". + :paramtype provisioning_state: str or ~azure.mgmt.security.models.ProvisioningState + :keyword template: The security solutions' template. + :paramtype template: str + :keyword protection_status: The security solutions' status. + :paramtype protection_status: str + """ + super().__init__(**kwargs) + self.location: Optional[str] = None + self.security_family = security_family + self.provisioning_state = provisioning_state + self.template = template + self.protection_status = protection_status + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class SecuritySolutionList(_serialization.Model): + """SecuritySolutionList. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.SecuritySolution] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecuritySolution]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.SecuritySolution"]] = None, **kwargs: Any) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.security.models.SecuritySolution] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class SecuritySolutionsReferenceData(Resource, Location): + """SecuritySolutionsReferenceData. + + 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 location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar security_family: The security family of the security solution. Required. Known values + are: "Waf", "Ngfw", "SaasWaf", and "Va". + :vartype security_family: str or ~azure.mgmt.security.models.SecurityFamily + :ivar alert_vendor_name: The security solutions' vendor name. Required. + :vartype alert_vendor_name: str + :ivar package_info_url: The security solutions' package info url. Required. + :vartype package_info_url: str + :ivar product_name: The security solutions' product name. Required. + :vartype product_name: str + :ivar publisher: The security solutions' publisher. Required. + :vartype publisher: str + :ivar publisher_display_name: The security solutions' publisher display name. Required. + :vartype publisher_display_name: str + :ivar template: The security solutions' template. Required. + :vartype template: str + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "security_family": {"required": True}, + "alert_vendor_name": {"required": True}, + "package_info_url": {"required": True}, + "product_name": {"required": True}, + "publisher": {"required": True}, + "publisher_display_name": {"required": True}, + "template": {"required": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "security_family": {"key": "properties.securityFamily", "type": "str"}, + "alert_vendor_name": {"key": "properties.alertVendorName", "type": "str"}, + "package_info_url": {"key": "properties.packageInfoUrl", "type": "str"}, + "product_name": {"key": "properties.productName", "type": "str"}, + "publisher": {"key": "properties.publisher", "type": "str"}, + "publisher_display_name": {"key": "properties.publisherDisplayName", "type": "str"}, + "template": {"key": "properties.template", "type": "str"}, + } + + def __init__( + self, + *, + security_family: Union[str, "_models.SecurityFamily"], + alert_vendor_name: str, + package_info_url: str, + product_name: str, + publisher: str, + publisher_display_name: str, + template: str, + **kwargs: Any + ) -> None: + """ + :keyword security_family: The security family of the security solution. Required. Known values + are: "Waf", "Ngfw", "SaasWaf", and "Va". + :paramtype security_family: str or ~azure.mgmt.security.models.SecurityFamily + :keyword alert_vendor_name: The security solutions' vendor name. Required. + :paramtype alert_vendor_name: str + :keyword package_info_url: The security solutions' package info url. Required. + :paramtype package_info_url: str + :keyword product_name: The security solutions' product name. Required. + :paramtype product_name: str + :keyword publisher: The security solutions' publisher. Required. + :paramtype publisher: str + :keyword publisher_display_name: The security solutions' publisher display name. Required. + :paramtype publisher_display_name: str + :keyword template: The security solutions' template. Required. + :paramtype template: str + """ + super().__init__(**kwargs) + self.location: Optional[str] = None + self.security_family = security_family + self.alert_vendor_name = alert_vendor_name + self.package_info_url = package_info_url + self.product_name = product_name + self.publisher = publisher + self.publisher_display_name = publisher_display_name + self.template = template + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class SecuritySolutionsReferenceDataList(_serialization.Model): + """SecuritySolutionsReferenceDataList. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.SecuritySolutionsReferenceData] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SecuritySolutionsReferenceData]"}, + } + + def __init__( + self, *, value: Optional[List["_models.SecuritySolutionsReferenceData"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.security.models.SecuritySolutionsReferenceData] + """ + super().__init__(**kwargs) + self.value = value + + +class SecurityStandard(Resource): + """Security Standard on a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: Display name of the standard, equivalent to the standardId. + :vartype display_name: str + :ivar standard_type: Standard type (Custom or Default or Compliance only currently). Known + values are: "Custom", "Default", and "Compliance". + :vartype standard_type: str or ~azure.mgmt.security.models.StandardType + :ivar description: Description of the standard. + :vartype description: str + :ivar assessments: List of assessment keys to apply to standard scope. + :vartype assessments: list[~azure.mgmt.security.models.PartialAssessmentProperties] + :ivar cloud_providers: List of all standard supported clouds. + :vartype cloud_providers: list[str or ~azure.mgmt.security.models.StandardSupportedCloud] + :ivar policy_set_definition_id: The policy set definition id associated with the standard. + :vartype policy_set_definition_id: str + :ivar metadata: The security standard metadata. + :vartype metadata: ~azure.mgmt.security.models.StandardMetadata + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "standard_type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "standard_type": {"key": "properties.standardType", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "assessments": {"key": "properties.assessments", "type": "[PartialAssessmentProperties]"}, + "cloud_providers": {"key": "properties.cloudProviders", "type": "[str]"}, + "policy_set_definition_id": {"key": "properties.policySetDefinitionId", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "StandardMetadata"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + assessments: Optional[List["_models.PartialAssessmentProperties"]] = None, + cloud_providers: Optional[List[Union[str, "_models.StandardSupportedCloud"]]] = None, + policy_set_definition_id: Optional[str] = None, + metadata: Optional["_models.StandardMetadata"] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: Display name of the standard, equivalent to the standardId. + :paramtype display_name: str + :keyword description: Description of the standard. + :paramtype description: str + :keyword assessments: List of assessment keys to apply to standard scope. + :paramtype assessments: list[~azure.mgmt.security.models.PartialAssessmentProperties] + :keyword cloud_providers: List of all standard supported clouds. + :paramtype cloud_providers: list[str or ~azure.mgmt.security.models.StandardSupportedCloud] + :keyword policy_set_definition_id: The policy set definition id associated with the standard. + :paramtype policy_set_definition_id: str + :keyword metadata: The security standard metadata. + :paramtype metadata: ~azure.mgmt.security.models.StandardMetadata + """ + super().__init__(**kwargs) + self.display_name = display_name + self.standard_type: Optional[Union[str, "_models.StandardType"]] = None + self.description = description + self.assessments = assessments + self.cloud_providers = cloud_providers + self.policy_set_definition_id = policy_set_definition_id + self.metadata = metadata + + +class SecurityStandardList(_serialization.Model): + """Page of a Standard list. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: Collection of standards in this page. Required. + :vartype value: list[~azure.mgmt.security.models.SecurityStandard] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True, "readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityStandard]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.SecurityStandard"]] = None + self.next_link: Optional[str] = None + + +class SecuritySubAssessment(Resource): + """Security sub-assessment on a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar id_properties_id: Vulnerability ID. + :vartype id_properties_id: str + :ivar display_name: User friendly display name of the sub-assessment. + :vartype display_name: str + :ivar status: Status of the sub-assessment. + :vartype status: ~azure.mgmt.security.models.SubAssessmentStatus + :ivar remediation: Information on how to remediate this sub-assessment. + :vartype remediation: str + :ivar impact: Description of the impact of this sub-assessment. + :vartype impact: str + :ivar category: Category of the sub-assessment. + :vartype category: str + :ivar description: Human readable description of the assessment status. + :vartype description: str + :ivar time_generated: The date and time the sub-assessment was generated. + :vartype time_generated: ~datetime.datetime + :ivar resource_details: Details of the resource that was assessed. + :vartype resource_details: ~azure.mgmt.security.models.ResourceDetails + :ivar additional_data: Details of the sub-assessment. + :vartype additional_data: ~azure.mgmt.security.models.AdditionalData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "id_properties_id": {"readonly": True}, + "display_name": {"readonly": True}, + "remediation": {"readonly": True}, + "impact": {"readonly": True}, + "category": {"readonly": True}, + "description": {"readonly": True}, + "time_generated": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "id_properties_id": {"key": "properties.id", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "status": {"key": "properties.status", "type": "SubAssessmentStatus"}, + "remediation": {"key": "properties.remediation", "type": "str"}, + "impact": {"key": "properties.impact", "type": "str"}, + "category": {"key": "properties.category", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "time_generated": {"key": "properties.timeGenerated", "type": "iso-8601"}, + "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, + "additional_data": {"key": "properties.additionalData", "type": "AdditionalData"}, + } + + def __init__( + self, + *, + status: Optional["_models.SubAssessmentStatus"] = None, + resource_details: Optional["_models.ResourceDetails"] = None, + additional_data: Optional["_models.AdditionalData"] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: Status of the sub-assessment. + :paramtype status: ~azure.mgmt.security.models.SubAssessmentStatus + :keyword resource_details: Details of the resource that was assessed. + :paramtype resource_details: ~azure.mgmt.security.models.ResourceDetails + :keyword additional_data: Details of the sub-assessment. + :paramtype additional_data: ~azure.mgmt.security.models.AdditionalData + """ + super().__init__(**kwargs) + self.id_properties_id: Optional[str] = None + self.display_name: Optional[str] = None + self.status = status + self.remediation: Optional[str] = None + self.impact: Optional[str] = None + self.category: Optional[str] = None + self.description: Optional[str] = None + self.time_generated: Optional[datetime.datetime] = None + self.resource_details = resource_details + self.additional_data = additional_data + + +class SecuritySubAssessmentList(_serialization.Model): + """List of security sub-assessments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.SecuritySubAssessment] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecuritySubAssessment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.SecuritySubAssessment"]] = None + self.next_link: Optional[str] = None + + +class SecurityTask(Resource): + """Security task that we recommend to do in order to strengthen security. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar state: State of the task (Active, Resolved etc.). + :vartype state: str + :ivar creation_time_utc: The time this task was discovered in UTC. + :vartype creation_time_utc: ~datetime.datetime + :ivar security_task_parameters: Changing set of properties, depending on the task type that is + derived from the name field. + :vartype security_task_parameters: ~azure.mgmt.security.models.SecurityTaskParameters + :ivar last_state_change_time_utc: The time this task's details were last changed in UTC. + :vartype last_state_change_time_utc: ~datetime.datetime + :ivar sub_state: Additional data on the state of the task. + :vartype sub_state: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "state": {"readonly": True}, + "creation_time_utc": {"readonly": True}, + "last_state_change_time_utc": {"readonly": True}, + "sub_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time_utc": {"key": "properties.creationTimeUtc", "type": "iso-8601"}, + "security_task_parameters": {"key": "properties.securityTaskParameters", "type": "SecurityTaskParameters"}, + "last_state_change_time_utc": {"key": "properties.lastStateChangeTimeUtc", "type": "iso-8601"}, + "sub_state": {"key": "properties.subState", "type": "str"}, + } + + def __init__( + self, *, security_task_parameters: Optional["_models.SecurityTaskParameters"] = None, **kwargs: Any + ) -> None: + """ + :keyword security_task_parameters: Changing set of properties, depending on the task type that + is derived from the name field. + :paramtype security_task_parameters: ~azure.mgmt.security.models.SecurityTaskParameters + """ + super().__init__(**kwargs) + self.state: Optional[str] = None + self.creation_time_utc: Optional[datetime.datetime] = None + self.security_task_parameters = security_task_parameters + self.last_state_change_time_utc: Optional[datetime.datetime] = None + self.sub_state: Optional[str] = None + + +class SecurityTaskList(_serialization.Model): + """List of security task recommendations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.SecurityTask] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityTask]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.SecurityTask"]] = None + self.next_link: Optional[str] = None + + +class SecurityTaskParameters(_serialization.Model): + """Changing set of properties, depending on the task type that is derived from the name field. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar name: Name of the task type. + :vartype name: str + """ + + _validation = { + "name": {"readonly": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, additional_properties: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + """ + super().__init__(**kwargs) + self.additional_properties = additional_properties + self.name: Optional[str] = None + + +class SensitiveDataDiscoveryProperties(_serialization.Model): + """Properties of Sensitive Data Discovery. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar is_enabled: Indicates whether Sensitive Data Discovery should be enabled. + :vartype is_enabled: bool + :ivar operation_status: Upon failure or partial success. Additional data describing Sensitive + Data Discovery enable/disable operation. + :vartype operation_status: ~azure.mgmt.security.models.OperationStatus + """ + + _validation = { + "operation_status": {"readonly": True}, + } + + _attribute_map = { + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "operation_status": {"key": "operationStatus", "type": "OperationStatus"}, + } + + def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword is_enabled: Indicates whether Sensitive Data Discovery should be enabled. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.is_enabled = is_enabled + self.operation_status: Optional["_models.OperationStatus"] = None + + +class SensitivityLabel(_serialization.Model): + """The sensitivity label. + + :ivar display_name: The name of the sensitivity label. + :vartype display_name: str + :ivar description: The description of the sensitivity label. + :vartype description: str + :ivar rank: The rank of the sensitivity label. Known values are: "None", "Low", "Medium", + "High", and "Critical". + :vartype rank: str or ~azure.mgmt.security.models.Rank + :ivar order: The order of the sensitivity label. + :vartype order: int + :ivar enabled: Indicates whether the label is enabled or not. + :vartype enabled: bool + """ + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "rank": {"key": "rank", "type": "str"}, + "order": {"key": "order", "type": "int"}, + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + rank: Optional[Union[str, "_models.Rank"]] = None, + order: Optional[int] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: The name of the sensitivity label. + :paramtype display_name: str + :keyword description: The description of the sensitivity label. + :paramtype description: str + :keyword rank: The rank of the sensitivity label. Known values are: "None", "Low", "Medium", + "High", and "Critical". + :paramtype rank: str or ~azure.mgmt.security.models.Rank + :keyword order: The order of the sensitivity label. + :paramtype order: int + :keyword enabled: Indicates whether the label is enabled or not. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.display_name = display_name + self.description = description + self.rank = rank + self.order = order + self.enabled = enabled + + +class ServerVulnerabilityAssessment(Resource): + """Describes the server vulnerability assessment details on a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar provisioning_state: The provisioningState of the vulnerability assessment capability on + the VM. Known values are: "Succeeded", "Failed", "Canceled", "Provisioning", and + "Deprovisioning". + :vartype provisioning_state: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentPropertiesProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provisioning_state: Optional[ + Union[str, "_models.ServerVulnerabilityAssessmentPropertiesProvisioningState"] + ] = None + + +class ServerVulnerabilityAssessmentsList(_serialization.Model): + """List of server vulnerability assessments. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.ServerVulnerabilityAssessment] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ServerVulnerabilityAssessment]"}, + } + + def __init__(self, *, value: Optional[List["_models.ServerVulnerabilityAssessment"]] = None, **kwargs: Any) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.security.models.ServerVulnerabilityAssessment] + """ + super().__init__(**kwargs) + self.value = value + + +class ServerVulnerabilityAssessmentsSettingsList(_serialization.Model): # pylint: disable=name-too-long + """A page of a server vulnerability assessments settings list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A collection of server vulnerability assessments settings in this page. + :vartype value: list[~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ServerVulnerabilityAssessmentsSetting]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.ServerVulnerabilityAssessmentsSetting"]] = None + self.next_link: Optional[str] = None + + +class ServerVulnerabilityProperties(AdditionalData): + """Additional context fields for server vulnerability assessment. + + 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 assessed_resource_type: Sub-assessment resource type. Required. Known values are: + "SqlServerVulnerability", "ContainerRegistryVulnerability", and "ServerVulnerability". + :vartype assessed_resource_type: str or ~azure.mgmt.security.models.AssessedResourceType + :ivar type: Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information + Gathered. + :vartype type: str + :ivar cvss: Dictionary from cvss version to cvss details object. + :vartype cvss: dict[str, ~azure.mgmt.security.models.CVSS] + :ivar patchable: Indicates whether a patch is available or not. + :vartype patchable: bool + :ivar cve: List of CVEs. + :vartype cve: list[~azure.mgmt.security.models.CVE] + :ivar threat: Threat name. + :vartype threat: str + :ivar published_time: Published time. + :vartype published_time: ~datetime.datetime + :ivar vendor_references: + :vartype vendor_references: list[~azure.mgmt.security.models.VendorReference] + """ + + _validation = { + "assessed_resource_type": {"required": True}, + "type": {"readonly": True}, + "cvss": {"readonly": True}, + "patchable": {"readonly": True}, + "cve": {"readonly": True}, + "threat": {"readonly": True}, + "published_time": {"readonly": True}, + "vendor_references": {"readonly": True}, + } + + _attribute_map = { + "assessed_resource_type": {"key": "assessedResourceType", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cvss": {"key": "cvss", "type": "{CVSS}"}, + "patchable": {"key": "patchable", "type": "bool"}, + "cve": {"key": "cve", "type": "[CVE]"}, + "threat": {"key": "threat", "type": "str"}, + "published_time": {"key": "publishedTime", "type": "iso-8601"}, + "vendor_references": {"key": "vendorReferences", "type": "[VendorReference]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.assessed_resource_type: str = "ServerVulnerabilityAssessment" + self.type: Optional[str] = None + self.cvss: Optional[Dict[str, "_models.CVSS"]] = None + self.patchable: Optional[bool] = None + self.cve: Optional[List["_models.CVE"]] = None + self.threat: Optional[str] = None + self.published_time: Optional[datetime.datetime] = None + self.vendor_references: Optional[List["_models.VendorReference"]] = None + + +class ServicePrincipalProperties(_serialization.Model): + """Details of the service principal. + + :ivar application_id: Application ID of service principal. + :vartype application_id: str + :ivar secret: A secret string that the application uses to prove its identity, also can be + referred to as application password (write only). + :vartype secret: str + """ + + _attribute_map = { + "application_id": {"key": "applicationId", "type": "str"}, + "secret": {"key": "secret", "type": "str"}, + } + + def __init__(self, *, application_id: Optional[str] = None, secret: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword application_id: Application ID of service principal. + :paramtype application_id: str + :keyword secret: A secret string that the application uses to prove its identity, also can be + referred to as application password (write only). + :paramtype secret: str + """ + super().__init__(**kwargs) + self.application_id = application_id + self.secret = secret + + +class SettingsList(_serialization.Model): + """Subscription settings list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The settings list. + :vartype value: list[~azure.mgmt.security.models.Setting] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Setting]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Setting"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The settings list. + :paramtype value: list[~azure.mgmt.security.models.Setting] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class Software(Resource): + """Represents a software data. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar device_id: Unique identifier for the virtual machine in the service. + :vartype device_id: str + :ivar os_platform: Platform of the operating system running on the device. + :vartype os_platform: str + :ivar vendor: Name of the software vendor. + :vartype vendor: str + :ivar software_name: Name of the software product. + :vartype software_name: str + :ivar version: Version number of the software product. + :vartype version: str + :ivar end_of_support_status: End of support status. Known values are: "None", + "noLongerSupported", "versionNoLongerSupported", "upcomingNoLongerSupported", and + "upcomingVersionNoLongerSupported". + :vartype end_of_support_status: str or ~azure.mgmt.security.models.EndOfSupportStatus + :ivar end_of_support_date: The end of support date in case the product is upcoming end of + support. + :vartype end_of_support_date: str + :ivar number_of_known_vulnerabilities: Number of weaknesses. + :vartype number_of_known_vulnerabilities: int + :ivar first_seen_at: First time that the software was seen in the device. + :vartype first_seen_at: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_id": {"key": "properties.deviceId", "type": "str"}, + "os_platform": {"key": "properties.osPlatform", "type": "str"}, + "vendor": {"key": "properties.vendor", "type": "str"}, + "software_name": {"key": "properties.softwareName", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "end_of_support_status": {"key": "properties.endOfSupportStatus", "type": "str"}, + "end_of_support_date": {"key": "properties.endOfSupportDate", "type": "str"}, + "number_of_known_vulnerabilities": {"key": "properties.numberOfKnownVulnerabilities", "type": "int"}, + "first_seen_at": {"key": "properties.firstSeenAt", "type": "str"}, + } + + def __init__( + self, + *, + device_id: Optional[str] = None, + os_platform: Optional[str] = None, + vendor: Optional[str] = None, + software_name: Optional[str] = None, + version: Optional[str] = None, + end_of_support_status: Optional[Union[str, "_models.EndOfSupportStatus"]] = None, + end_of_support_date: Optional[str] = None, + number_of_known_vulnerabilities: Optional[int] = None, + first_seen_at: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword device_id: Unique identifier for the virtual machine in the service. + :paramtype device_id: str + :keyword os_platform: Platform of the operating system running on the device. + :paramtype os_platform: str + :keyword vendor: Name of the software vendor. + :paramtype vendor: str + :keyword software_name: Name of the software product. + :paramtype software_name: str + :keyword version: Version number of the software product. + :paramtype version: str + :keyword end_of_support_status: End of support status. Known values are: "None", + "noLongerSupported", "versionNoLongerSupported", "upcomingNoLongerSupported", and + "upcomingVersionNoLongerSupported". + :paramtype end_of_support_status: str or ~azure.mgmt.security.models.EndOfSupportStatus + :keyword end_of_support_date: The end of support date in case the product is upcoming end of + support. + :paramtype end_of_support_date: str + :keyword number_of_known_vulnerabilities: Number of weaknesses. + :paramtype number_of_known_vulnerabilities: int + :keyword first_seen_at: First time that the software was seen in the device. + :paramtype first_seen_at: str + """ + super().__init__(**kwargs) + self.device_id = device_id + self.os_platform = os_platform + self.vendor = vendor + self.software_name = software_name + self.version = version + self.end_of_support_status = end_of_support_status + self.end_of_support_date = end_of_support_date + self.number_of_known_vulnerabilities = number_of_known_vulnerabilities + self.first_seen_at = first_seen_at + + +class SoftwaresList(_serialization.Model): + """Represents the software inventory of the virtual machine. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.Software] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Software]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Software"]] = None, **kwargs: Any) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.security.models.Software] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class SqlServerVulnerabilityProperties(AdditionalData): + """Details of the resource that was assessed. + + 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 assessed_resource_type: Sub-assessment resource type. Required. Known values are: + "SqlServerVulnerability", "ContainerRegistryVulnerability", and "ServerVulnerability". + :vartype assessed_resource_type: str or ~azure.mgmt.security.models.AssessedResourceType + :ivar type: The resource type the sub assessment refers to in its resource details. + :vartype type: str + :ivar query: The T-SQL query that runs on your SQL database to perform the particular check. + :vartype query: str + """ + + _validation = { + "assessed_resource_type": {"required": True}, + "type": {"readonly": True}, + "query": {"readonly": True}, + } + + _attribute_map = { + "assessed_resource_type": {"key": "assessedResourceType", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "query": {"key": "query", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.assessed_resource_type: str = "SqlServerVulnerability" + self.type: Optional[str] = None + self.query: Optional[str] = None + + +class StandardAssignment(Resource): + """Security Assignment on a resource group over a given scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: Display name of the standardAssignment. + :vartype display_name: str + :ivar description: Description of the standardAssignment. + :vartype description: str + :ivar assigned_standard: Standard item with key as applied to this standard assignment over the + given scope. + :vartype assigned_standard: ~azure.mgmt.security.models.AssignedStandardItem + :ivar effect: Expected effect of this assignment (Audit/Exempt/Attest). Known values are: + "Audit", "Exempt", and "Attest". + :vartype effect: str or ~azure.mgmt.security.models.Effect + :ivar excluded_scopes: Excluded scopes, filter out the descendants of the scope (on management + scopes). + :vartype excluded_scopes: list[str] + :ivar expires_on: Expiration date of this assignment as a full ISO date. + :vartype expires_on: ~datetime.datetime + :ivar exemption_data: Additional data about assignment that has Exempt effect. + :vartype exemption_data: ~azure.mgmt.security.models.StandardAssignmentPropertiesExemptionData + :ivar attestation_data: Additional data about assignment that has Attest effect. + :vartype attestation_data: + ~azure.mgmt.security.models.StandardAssignmentPropertiesAttestationData + :ivar metadata: The standard assignment metadata. + :vartype metadata: ~azure.mgmt.security.models.StandardAssignmentMetadata + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "assigned_standard": {"key": "properties.assignedStandard", "type": "AssignedStandardItem"}, + "effect": {"key": "properties.effect", "type": "str"}, + "excluded_scopes": {"key": "properties.excludedScopes", "type": "[str]"}, + "expires_on": {"key": "properties.expiresOn", "type": "iso-8601"}, + "exemption_data": {"key": "properties.exemptionData", "type": "StandardAssignmentPropertiesExemptionData"}, + "attestation_data": { + "key": "properties.attestationData", + "type": "StandardAssignmentPropertiesAttestationData", + }, + "metadata": {"key": "properties.metadata", "type": "StandardAssignmentMetadata"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + assigned_standard: Optional["_models.AssignedStandardItem"] = None, + effect: Optional[Union[str, "_models.Effect"]] = None, + excluded_scopes: Optional[List[str]] = None, + expires_on: Optional[datetime.datetime] = None, + exemption_data: Optional["_models.StandardAssignmentPropertiesExemptionData"] = None, + attestation_data: Optional["_models.StandardAssignmentPropertiesAttestationData"] = None, + metadata: Optional["_models.StandardAssignmentMetadata"] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: Display name of the standardAssignment. + :paramtype display_name: str + :keyword description: Description of the standardAssignment. + :paramtype description: str + :keyword assigned_standard: Standard item with key as applied to this standard assignment over + the given scope. + :paramtype assigned_standard: ~azure.mgmt.security.models.AssignedStandardItem + :keyword effect: Expected effect of this assignment (Audit/Exempt/Attest). Known values are: + "Audit", "Exempt", and "Attest". + :paramtype effect: str or ~azure.mgmt.security.models.Effect + :keyword excluded_scopes: Excluded scopes, filter out the descendants of the scope (on + management scopes). + :paramtype excluded_scopes: list[str] + :keyword expires_on: Expiration date of this assignment as a full ISO date. + :paramtype expires_on: ~datetime.datetime + :keyword exemption_data: Additional data about assignment that has Exempt effect. + :paramtype exemption_data: + ~azure.mgmt.security.models.StandardAssignmentPropertiesExemptionData + :keyword attestation_data: Additional data about assignment that has Attest effect. + :paramtype attestation_data: + ~azure.mgmt.security.models.StandardAssignmentPropertiesAttestationData + :keyword metadata: The standard assignment metadata. + :paramtype metadata: ~azure.mgmt.security.models.StandardAssignmentMetadata + """ + super().__init__(**kwargs) + self.display_name = display_name + self.description = description + self.assigned_standard = assigned_standard + self.effect = effect + self.excluded_scopes = excluded_scopes + self.expires_on = expires_on + self.exemption_data = exemption_data + self.attestation_data = attestation_data + self.metadata = metadata + + +class StandardAssignmentMetadata(_serialization.Model): + """The standard assignment metadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar created_by: Standard assignment Created by object id (GUID). + :vartype created_by: str + :ivar created_on: Standard assignment creation date. + :vartype created_on: ~datetime.datetime + :ivar last_updated_by: Standard assignment last updated by object id (GUID). + :vartype last_updated_by: str + :ivar last_updated_on: Standard assignment last update date. + :vartype last_updated_on: ~datetime.datetime + """ + + _validation = { + "created_by": {"readonly": True}, + "created_on": {"readonly": True}, + "last_updated_by": {"readonly": True}, + "last_updated_on": {"readonly": True}, + } + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_on": {"key": "createdOn", "type": "iso-8601"}, + "last_updated_by": {"key": "lastUpdatedBy", "type": "str"}, + "last_updated_on": {"key": "lastUpdatedOn", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.created_by: Optional[str] = None + self.created_on: Optional[datetime.datetime] = None + self.last_updated_by: Optional[str] = None + self.last_updated_on: Optional[datetime.datetime] = None + + +class StandardAssignmentPropertiesAttestationData(_serialization.Model): # pylint: disable=name-too-long + """Additional data about assignment that has Attest effect. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar compliance_state: Attest category of this assignment. Known values are: "unknown", + "compliant", and "nonCompliant". + :vartype compliance_state: str or ~azure.mgmt.security.models.AttestationComplianceState + :ivar assigned_assessment: Component item with key as applied to this standard assignment over + the given scope. + :vartype assigned_assessment: ~azure.mgmt.security.models.AssignedAssessmentItem + :ivar compliance_date: Attestation compliance date. + :vartype compliance_date: ~datetime.datetime + :ivar evidence: Array of links to attestation evidence. + :vartype evidence: list[~azure.mgmt.security.models.AttestationEvidence] + """ + + _validation = { + "compliance_date": {"readonly": True}, + } + + _attribute_map = { + "compliance_state": {"key": "complianceState", "type": "str"}, + "assigned_assessment": {"key": "assignedAssessment", "type": "AssignedAssessmentItem"}, + "compliance_date": {"key": "complianceDate", "type": "iso-8601"}, + "evidence": {"key": "evidence", "type": "[AttestationEvidence]"}, + } + + def __init__( + self, + *, + compliance_state: Optional[Union[str, "_models.AttestationComplianceState"]] = None, + assigned_assessment: Optional["_models.AssignedAssessmentItem"] = None, + evidence: Optional[List["_models.AttestationEvidence"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword compliance_state: Attest category of this assignment. Known values are: "unknown", + "compliant", and "nonCompliant". + :paramtype compliance_state: str or ~azure.mgmt.security.models.AttestationComplianceState + :keyword assigned_assessment: Component item with key as applied to this standard assignment + over the given scope. + :paramtype assigned_assessment: ~azure.mgmt.security.models.AssignedAssessmentItem + :keyword evidence: Array of links to attestation evidence. + :paramtype evidence: list[~azure.mgmt.security.models.AttestationEvidence] + """ + super().__init__(**kwargs) + self.compliance_state = compliance_state + self.assigned_assessment = assigned_assessment + self.compliance_date: Optional[datetime.datetime] = None + self.evidence = evidence + + +class StandardAssignmentPropertiesExemptionData(_serialization.Model): # pylint: disable=name-too-long + """Additional data about assignment that has Exempt effect. + + :ivar exemption_category: Exemption category of this assignment. Known values are: "waiver" and + "mitigated". + :vartype exemption_category: str or ~azure.mgmt.security.models.ExemptionCategory + :ivar assigned_assessment: Component item with key as applied to this standard assignment over + the given scope. + :vartype assigned_assessment: ~azure.mgmt.security.models.AssignedAssessmentItem + """ + + _attribute_map = { + "exemption_category": {"key": "exemptionCategory", "type": "str"}, + "assigned_assessment": {"key": "assignedAssessment", "type": "AssignedAssessmentItem"}, + } + + def __init__( + self, + *, + exemption_category: Optional[Union[str, "_models.ExemptionCategory"]] = None, + assigned_assessment: Optional["_models.AssignedAssessmentItem"] = None, + **kwargs: Any + ) -> None: + """ + :keyword exemption_category: Exemption category of this assignment. Known values are: "waiver" + and "mitigated". + :paramtype exemption_category: str or ~azure.mgmt.security.models.ExemptionCategory + :keyword assigned_assessment: Component item with key as applied to this standard assignment + over the given scope. + :paramtype assigned_assessment: ~azure.mgmt.security.models.AssignedAssessmentItem + """ + super().__init__(**kwargs) + self.exemption_category = exemption_category + self.assigned_assessment = assigned_assessment + + +class StandardAssignmentsList(_serialization.Model): + """Page of a standard assignment list. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: Collection of standardAssignments in this page. Required. + :vartype value: list[~azure.mgmt.security.models.StandardAssignment] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True, "readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[StandardAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.StandardAssignment"]] = None + self.next_link: Optional[str] = None + + +class StandardMetadata(_serialization.Model): + """The standard metadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar created_by: Standard Created by object id (GUID). + :vartype created_by: str + :ivar created_on: Standard creation date. + :vartype created_on: ~datetime.datetime + :ivar last_updated_by: Standard last updated by object id (GUID). + :vartype last_updated_by: str + :ivar last_updated_on: Standard last update date. + :vartype last_updated_on: ~datetime.datetime + """ + + _validation = { + "created_by": {"readonly": True}, + "created_on": {"readonly": True}, + "last_updated_by": {"readonly": True}, + "last_updated_on": {"readonly": True}, + } + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_on": {"key": "createdOn", "type": "iso-8601"}, + "last_updated_by": {"key": "lastUpdatedBy", "type": "str"}, + "last_updated_on": {"key": "lastUpdatedOn", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.created_by: Optional[str] = None + self.created_on: Optional[datetime.datetime] = None + self.last_updated_by: Optional[str] = None + self.last_updated_on: Optional[datetime.datetime] = None + + +class StatusAutoGenerated(_serialization.Model): + """The status of the health report. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The status of the health report. Known values are: "Healthy", "NotHealthy", and + "NotApplicable". + :vartype code: str or ~azure.mgmt.security.models.StatusName + :ivar reason: The reason of the given status. + :vartype reason: str + :ivar last_scanned_date: The date of when the resource was scanned in the last time. + :vartype last_scanned_date: ~datetime.datetime + :ivar status_change_date: The date of when the status of the health report was changed in the + last time. + :vartype status_change_date: ~datetime.datetime + :ivar first_evaluation_date: The date of when the resource of the health report was scanned in + the first time. + :vartype first_evaluation_date: ~datetime.datetime + """ + + _validation = { + "reason": {"readonly": True}, + "last_scanned_date": {"readonly": True}, + "status_change_date": {"readonly": True}, + "first_evaluation_date": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "last_scanned_date": {"key": "lastScannedDate", "type": "iso-8601"}, + "status_change_date": {"key": "statusChangeDate", "type": "iso-8601"}, + "first_evaluation_date": {"key": "firstEvaluationDate", "type": "iso-8601"}, + } + + def __init__(self, *, code: Optional[Union[str, "_models.StatusName"]] = None, **kwargs: Any) -> None: + """ + :keyword code: The status of the health report. Known values are: "Healthy", "NotHealthy", and + "NotApplicable". + :paramtype code: str or ~azure.mgmt.security.models.StatusName + """ + super().__init__(**kwargs) + self.code = code + self.reason: Optional[str] = None + self.last_scanned_date: Optional[datetime.datetime] = None + self.status_change_date: Optional[datetime.datetime] = None + self.first_evaluation_date: Optional[datetime.datetime] = None + + +class SubAssessmentStatus(_serialization.Model): + """Status of the sub-assessment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Programmatic code for the status of the assessment. Known values are: "Healthy", + "Unhealthy", and "NotApplicable". + :vartype code: str or ~azure.mgmt.security.models.SubAssessmentStatusCode + :ivar cause: Programmatic code for the cause of the assessment status. + :vartype cause: str + :ivar description: Human readable description of the assessment status. + :vartype description: str + :ivar severity: The sub-assessment severity level. Known values are: "Low", "Medium", and + "High". + :vartype severity: str or ~azure.mgmt.security.models.Severity + """ + + _validation = { + "code": {"readonly": True}, + "cause": {"readonly": True}, + "description": {"readonly": True}, + "severity": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "cause": {"key": "cause", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[Union[str, "_models.SubAssessmentStatusCode"]] = None + self.cause: Optional[str] = None + self.description: Optional[str] = None + self.severity: Optional[Union[str, "_models.Severity"]] = None + + +class SuppressionAlertsScope(_serialization.Model): + """SuppressionAlertsScope. + + All required parameters must be populated in order to send to server. + + :ivar all_of: All the conditions inside need to be true in order to suppress the alert. + Required. + :vartype all_of: list[~azure.mgmt.security.models.ScopeElement] + """ + + _validation = { + "all_of": {"required": True}, + } + + _attribute_map = { + "all_of": {"key": "allOf", "type": "[ScopeElement]"}, + } + + def __init__(self, *, all_of: List["_models.ScopeElement"], **kwargs: Any) -> None: + """ + :keyword all_of: All the conditions inside need to be true in order to suppress the alert. + Required. + :paramtype all_of: list[~azure.mgmt.security.models.ScopeElement] + """ + super().__init__(**kwargs) + self.all_of = all_of + + +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.security.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.security.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.security.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.security.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 TargetBranchConfiguration(_serialization.Model): + """Repository branch configuration for PR Annotations. + + :ivar branch_names: Gets or sets branches that should have annotations. + :vartype branch_names: list[str] + :ivar annotate_default_branch: Configuration of PR Annotations on default branch. + + Enabled - PR Annotations are enabled on the resource's default branch. + Disabled - PR Annotations are disabled on the resource's default branch. Known values are: + "Disabled" and "Enabled". + :vartype annotate_default_branch: str or ~azure.mgmt.security.models.AnnotateDefaultBranchState + """ + + _attribute_map = { + "branch_names": {"key": "branchNames", "type": "[str]"}, + "annotate_default_branch": {"key": "annotateDefaultBranch", "type": "str"}, + } + + def __init__( + self, + *, + branch_names: Optional[List[str]] = None, + annotate_default_branch: Optional[Union[str, "_models.AnnotateDefaultBranchState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword branch_names: Gets or sets branches that should have annotations. + :paramtype branch_names: list[str] + :keyword annotate_default_branch: Configuration of PR Annotations on default branch. + + Enabled - PR Annotations are enabled on the resource's default branch. + Disabled - PR Annotations are disabled on the resource's default branch. Known values are: + "Disabled" and "Enabled". + :paramtype annotate_default_branch: str or + ~azure.mgmt.security.models.AnnotateDefaultBranchState + """ + super().__init__(**kwargs) + self.branch_names = branch_names + self.annotate_default_branch = annotate_default_branch + + +class TopologyList(_serialization.Model): + """TopologyList. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.security.models.TopologyResource] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[TopologyResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.TopologyResource"]] = None + self.next_link: Optional[str] = None + + +class TopologyResource(Resource, Location): + """TopologyResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar calculated_date_time: The UTC time on which the topology was calculated. + :vartype calculated_date_time: ~datetime.datetime + :ivar topology_resources: Azure resources which are part of this topology resource. + :vartype topology_resources: list[~azure.mgmt.security.models.TopologySingleResource] + """ + + _validation = { + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "calculated_date_time": {"readonly": True}, + "topology_resources": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "calculated_date_time": {"key": "properties.calculatedDateTime", "type": "iso-8601"}, + "topology_resources": {"key": "properties.topologyResources", "type": "[TopologySingleResource]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.location: Optional[str] = None + self.calculated_date_time: Optional[datetime.datetime] = None + self.topology_resources: Optional[List["_models.TopologySingleResource"]] = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class TopologySingleResource(_serialization.Model): + """TopologySingleResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_id: Azure resource id. + :vartype resource_id: str + :ivar severity: The security severity of the resource. + :vartype severity: str + :ivar recommendations_exist: Indicates if the resource has security recommendations. + :vartype recommendations_exist: bool + :ivar network_zones: Indicates the resource connectivity level to the Internet (InternetFacing, + Internal ,etc.). + :vartype network_zones: str + :ivar topology_score: Score of the resource based on its security severity. + :vartype topology_score: int + :ivar location: The location of this resource. + :vartype location: str + :ivar parents: Azure resources connected to this resource which are in higher level in the + topology view. + :vartype parents: list[~azure.mgmt.security.models.TopologySingleResourceParent] + :ivar children: Azure resources connected to this resource which are in lower level in the + topology view. + :vartype children: list[~azure.mgmt.security.models.TopologySingleResourceChild] + """ + + _validation = { + "resource_id": {"readonly": True}, + "severity": {"readonly": True}, + "recommendations_exist": {"readonly": True}, + "network_zones": {"readonly": True}, + "topology_score": {"readonly": True}, + "location": {"readonly": True}, + "parents": {"readonly": True}, + "children": {"readonly": True}, + } + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "recommendations_exist": {"key": "recommendationsExist", "type": "bool"}, + "network_zones": {"key": "networkZones", "type": "str"}, + "topology_score": {"key": "topologyScore", "type": "int"}, + "location": {"key": "location", "type": "str"}, + "parents": {"key": "parents", "type": "[TopologySingleResourceParent]"}, + "children": {"key": "children", "type": "[TopologySingleResourceChild]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.resource_id: Optional[str] = None + self.severity: Optional[str] = None + self.recommendations_exist: Optional[bool] = None + self.network_zones: Optional[str] = None + self.topology_score: Optional[int] = None + self.location: Optional[str] = None + self.parents: Optional[List["_models.TopologySingleResourceParent"]] = None + self.children: Optional[List["_models.TopologySingleResourceChild"]] = None + + +class TopologySingleResourceChild(_serialization.Model): + """TopologySingleResourceChild. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_id: Azure resource id which serves as child resource in topology view. + :vartype resource_id: str + """ + + _validation = { + "resource_id": {"readonly": True}, + } + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.resource_id: Optional[str] = None + + +class TopologySingleResourceParent(_serialization.Model): + """TopologySingleResourceParent. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_id: Azure resource id which serves as parent resource in topology view. + :vartype resource_id: str + """ + + _validation = { + "resource_id": {"readonly": True}, + } + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.resource_id: Optional[str] = None + + +class TwinUpdatesNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of twin updates is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "TwinUpdatesNotInAllowedRange" + + +class UnauthorizedOperationsNotInAllowedRange(TimeWindowCustomAlertRule): + """Number of unauthorized operations is not in allowed range. + + 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 display_name: The display name of the custom alert. + :vartype display_name: str + :ivar description: The description of the custom alert. + :vartype description: str + :ivar is_enabled: Status of the custom alert. Required. + :vartype is_enabled: bool + :ivar rule_type: The type of the custom alert rule. Required. + :vartype rule_type: str + :ivar min_threshold: The minimum threshold. Required. + :vartype min_threshold: int + :ivar max_threshold: The maximum threshold. Required. + :vartype max_threshold: int + :ivar time_window_size: The time window size in iso8601 format. Required. + :vartype time_window_size: ~datetime.timedelta + """ + + _validation = { + "display_name": {"readonly": True}, + "description": {"readonly": True}, + "is_enabled": {"required": True}, + "rule_type": {"required": True}, + "min_threshold": {"required": True}, + "max_threshold": {"required": True}, + "time_window_size": {"required": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "min_threshold": {"key": "minThreshold", "type": "int"}, + "max_threshold": {"key": "maxThreshold", "type": "int"}, + "time_window_size": {"key": "timeWindowSize", "type": "duration"}, + } + + def __init__( + self, + *, + is_enabled: bool, + min_threshold: int, + max_threshold: int, + time_window_size: datetime.timedelta, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + :keyword min_threshold: The minimum threshold. Required. + :paramtype min_threshold: int + :keyword max_threshold: The maximum threshold. Required. + :paramtype max_threshold: int + :keyword time_window_size: The time window size in iso8601 format. Required. + :paramtype time_window_size: ~datetime.timedelta + """ + super().__init__( + is_enabled=is_enabled, + min_threshold=min_threshold, + max_threshold=max_threshold, + time_window_size=time_window_size, + **kwargs + ) + self.rule_type: str = "UnauthorizedOperationsNotInAllowedRange" + + +class UpdateIotSecuritySolutionData(TagsResource): + """UpdateIotSecuritySolutionData. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar user_defined_resources: Properties of the IoT Security solution's user defined resources. + :vartype user_defined_resources: ~azure.mgmt.security.models.UserDefinedResourcesProperties + :ivar recommendations_configuration: List of the configuration status for each recommendation + type. + :vartype recommendations_configuration: + list[~azure.mgmt.security.models.RecommendationConfigurationProperties] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "user_defined_resources": {"key": "properties.userDefinedResources", "type": "UserDefinedResourcesProperties"}, + "recommendations_configuration": { + "key": "properties.recommendationsConfiguration", + "type": "[RecommendationConfigurationProperties]", + }, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + user_defined_resources: Optional["_models.UserDefinedResourcesProperties"] = None, + recommendations_configuration: Optional[List["_models.RecommendationConfigurationProperties"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword user_defined_resources: Properties of the IoT Security solution's user defined + resources. + :paramtype user_defined_resources: ~azure.mgmt.security.models.UserDefinedResourcesProperties + :keyword recommendations_configuration: List of the configuration status for each + recommendation type. + :paramtype recommendations_configuration: + list[~azure.mgmt.security.models.RecommendationConfigurationProperties] + """ + super().__init__(tags=tags, **kwargs) + self.user_defined_resources = user_defined_resources + self.recommendations_configuration = recommendations_configuration + + +class UpdateSensitivitySettingsRequest(_serialization.Model): + """Request to update data sensitivity settings for sensitive data discovery. + + All required parameters must be populated in order to send to server. + + :ivar sensitive_info_types_ids: List of selected sensitive info types' IDs. Required. + :vartype sensitive_info_types_ids: list[str] + :ivar sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any + label at or above this order will be considered sensitive. If set to -1, sensitivity by labels + is turned off. + :vartype sensitivity_threshold_label_order: float + :ivar sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label at + or above this rank will be considered sensitive. + :vartype sensitivity_threshold_label_id: str + """ + + _validation = { + "sensitive_info_types_ids": {"required": True}, + } + + _attribute_map = { + "sensitive_info_types_ids": {"key": "sensitiveInfoTypesIds", "type": "[str]"}, + "sensitivity_threshold_label_order": {"key": "sensitivityThresholdLabelOrder", "type": "float"}, + "sensitivity_threshold_label_id": {"key": "sensitivityThresholdLabelId", "type": "str"}, + } + + def __init__( + self, + *, + sensitive_info_types_ids: List[str], + sensitivity_threshold_label_order: Optional[float] = None, + sensitivity_threshold_label_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword sensitive_info_types_ids: List of selected sensitive info types' IDs. Required. + :paramtype sensitive_info_types_ids: list[str] + :keyword sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any + label at or above this order will be considered sensitive. If set to -1, sensitivity by labels + is turned off. + :paramtype sensitivity_threshold_label_order: float + :keyword sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label + at or above this rank will be considered sensitive. + :paramtype sensitivity_threshold_label_id: str + """ + super().__init__(**kwargs) + self.sensitive_info_types_ids = sensitive_info_types_ids + self.sensitivity_threshold_label_order = sensitivity_threshold_label_order + self.sensitivity_threshold_label_id = sensitivity_threshold_label_id + + +class UserDefinedResourcesProperties(_serialization.Model): + """Properties of the IoT Security solution's user defined resources. + + All required parameters must be populated in order to send to server. + + :ivar query: Azure Resource Graph query which represents the security solution's user defined + resources. Required to start with "where type != "Microsoft.Devices/IotHubs"". Required. + :vartype query: str + :ivar query_subscriptions: List of Azure subscription ids on which the user defined resources + query should be executed. Required. + :vartype query_subscriptions: list[str] + """ + + _validation = { + "query": {"required": True}, + "query_subscriptions": {"required": True}, + } + + _attribute_map = { + "query": {"key": "query", "type": "str"}, + "query_subscriptions": {"key": "querySubscriptions", "type": "[str]"}, + } + + def __init__(self, *, query: str, query_subscriptions: List[str], **kwargs: Any) -> None: + """ + :keyword query: Azure Resource Graph query which represents the security solution's user + defined resources. Required to start with "where type != "Microsoft.Devices/IotHubs"". + Required. + :paramtype query: str + :keyword query_subscriptions: List of Azure subscription ids on which the user defined + resources query should be executed. Required. + :paramtype query_subscriptions: list[str] + """ + super().__init__(**kwargs) + self.query = query + self.query_subscriptions = query_subscriptions + + +class VaRule(_serialization.Model): + """vulnerability assessment rule metadata details. + + :ivar rule_id: The rule Id. + :vartype rule_id: str + :ivar severity: The rule severity. Known values are: "High", "Medium", "Low", "Informational", + and "Obsolete". + :vartype severity: str or ~azure.mgmt.security.models.RuleSeverity + :ivar category: The rule category. + :vartype category: str + :ivar rule_type: The rule type. Known values are: "Binary", "BaselineExpected", "PositiveList", + and "NegativeList". + :vartype rule_type: str or ~azure.mgmt.security.models.RuleType + :ivar title: The rule title. + :vartype title: str + :ivar description: The rule description. + :vartype description: str + :ivar rationale: The rule rationale. + :vartype rationale: str + :ivar query_check: The rule query details. + :vartype query_check: ~azure.mgmt.security.models.QueryCheck + :ivar benchmark_references: The benchmark references. + :vartype benchmark_references: list[~azure.mgmt.security.models.BenchmarkReference] + """ + + _attribute_map = { + "rule_id": {"key": "ruleId", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "rationale": {"key": "rationale", "type": "str"}, + "query_check": {"key": "queryCheck", "type": "QueryCheck"}, + "benchmark_references": {"key": "benchmarkReferences", "type": "[BenchmarkReference]"}, + } + + def __init__( + self, + *, + rule_id: Optional[str] = None, + severity: Optional[Union[str, "_models.RuleSeverity"]] = None, + category: Optional[str] = None, + rule_type: Optional[Union[str, "_models.RuleType"]] = None, + title: Optional[str] = None, + description: Optional[str] = None, + rationale: Optional[str] = None, + query_check: Optional["_models.QueryCheck"] = None, + benchmark_references: Optional[List["_models.BenchmarkReference"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword rule_id: The rule Id. + :paramtype rule_id: str + :keyword severity: The rule severity. Known values are: "High", "Medium", "Low", + "Informational", and "Obsolete". + :paramtype severity: str or ~azure.mgmt.security.models.RuleSeverity + :keyword category: The rule category. + :paramtype category: str + :keyword rule_type: The rule type. Known values are: "Binary", "BaselineExpected", + "PositiveList", and "NegativeList". + :paramtype rule_type: str or ~azure.mgmt.security.models.RuleType + :keyword title: The rule title. + :paramtype title: str + :keyword description: The rule description. + :paramtype description: str + :keyword rationale: The rule rationale. + :paramtype rationale: str + :keyword query_check: The rule query details. + :paramtype query_check: ~azure.mgmt.security.models.QueryCheck + :keyword benchmark_references: The benchmark references. + :paramtype benchmark_references: list[~azure.mgmt.security.models.BenchmarkReference] + """ + super().__init__(**kwargs) + self.rule_id = rule_id + self.severity = severity + self.category = category + self.rule_type = rule_type + self.title = title + self.description = description + self.rationale = rationale + self.query_check = query_check + self.benchmark_references = benchmark_references + + +class VendorReference(_serialization.Model): + """Vendor reference. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar title: Link title. + :vartype title: str + :ivar link: Link url. + :vartype link: str + """ + + _validation = { + "title": {"readonly": True}, + "link": {"readonly": True}, + } + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "link": {"key": "link", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.title: Optional[str] = None + self.link: Optional[str] = None + + +class VmScannersBaseConfiguration(_serialization.Model): + """Configuration for VM scanning. + + :ivar scanning_mode: The scanning mode for the VM scan. "Default" + :vartype scanning_mode: str or ~azure.mgmt.security.models.ScanningMode + :ivar exclusion_tags: Tags that indicates that a resource should not be scanned. + :vartype exclusion_tags: dict[str, str] + """ + + _attribute_map = { + "scanning_mode": {"key": "scanningMode", "type": "str"}, + "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, + } + + def __init__( + self, + *, + scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, + exclusion_tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword scanning_mode: The scanning mode for the VM scan. "Default" + :paramtype scanning_mode: str or ~azure.mgmt.security.models.ScanningMode + :keyword exclusion_tags: Tags that indicates that a resource should not be scanned. + :paramtype exclusion_tags: dict[str, str] + """ + super().__init__(**kwargs) + self.scanning_mode = scanning_mode + self.exclusion_tags = exclusion_tags + + +class WorkspaceSetting(Resource): + """Configures where to store the OMS agent data for workspaces under a scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar workspace_id: The full Azure ID of the workspace to save the data in. + :vartype workspace_id: str + :ivar scope: All the VMs in this scope will send their security data to the mentioned workspace + unless overridden by a setting with more specific scope. + :vartype scope: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + } + + def __init__(self, *, workspace_id: Optional[str] = None, scope: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword workspace_id: The full Azure ID of the workspace to save the data in. + :paramtype workspace_id: str + :keyword scope: All the VMs in this scope will send their security data to the mentioned + workspace unless overridden by a setting with more specific scope. + :paramtype scope: str + """ + super().__init__(**kwargs) + self.workspace_id = workspace_id + self.scope = scope + + +class WorkspaceSettingList(_serialization.Model): + """List of workspace settings response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar value: List of workspace settings. Required. + :vartype value: list[~azure.mgmt.security.models.WorkspaceSetting] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[WorkspaceSetting]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.WorkspaceSetting"], **kwargs: Any) -> None: + """ + :keyword value: List of workspace settings. Required. + :paramtype value: list[~azure.mgmt.security.models.WorkspaceSetting] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_patch.py @@ -0,0 +1,21 @@ +# 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 + + +def patch_sdk(): + """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/security/azure-mgmt-security/azure/mgmt/security/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_security_center_enums.py new file mode 100644 index 000000000000..f6962ed8d90d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_security_center_enums.py @@ -0,0 +1,1442 @@ +# 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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AadConnectivityStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The connectivity state of the external AAD solution.""" + + DISCOVERED = "Discovered" + NOT_LICENSED = "NotLicensed" + CONNECTED = "Connected" + + +class ActionableRemediationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ActionableRemediation Setting. + None - the setting was never set. + Enabled - ActionableRemediation is enabled. + Disabled - ActionableRemediation is disabled. + """ + + NONE = "None" + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + LOGIC_APP = "LogicApp" + EVENT_HUB = "EventHub" + WORKSPACE = "Workspace" + + +class AdditionalWorkspaceDataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data types sent to workspace.""" + + ALERTS = "Alerts" + RAW_EVENTS = "RawEvents" + + +class AdditionalWorkspaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Workspace type.""" + + SENTINEL = "Sentinel" + + +class AgentlessEnablement(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Agentless Enablement states.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + NOT_APPLICABLE = "NotApplicable" + + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The risk level of the threat that was detected. Learn more: + https://docs.microsoft.com/en-us/azure/security-center/security-center-alerts-overview#how-are-alerts-classified. + """ + + INFORMATIONAL = "Informational" + """Informational""" + LOW = "Low" + """Low""" + MEDIUM = "Medium" + """Medium""" + HIGH = "High" + """High""" + + +class AlertStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The life cycle status of the alert.""" + + ACTIVE = "Active" + """An alert which doesn't specify a value is assigned the status 'Active'""" + IN_PROGRESS = "InProgress" + """An alert which is in handling state""" + RESOLVED = "Resolved" + """Alert closed after handling""" + DISMISSED = "Dismissed" + """Alert dismissed as false positive""" + + +class AnnotateDefaultBranchState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Configuration of PR Annotations on default branch. + + Enabled - PR Annotations are enabled on the resource's default branch. + Disabled - PR Annotations are disabled on the resource's default branch. + """ + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class ApplicationConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The application Condition's Operator, for example Contains for id or In for list of possible + IDs, see examples. + """ + + CONTAINS = "Contains" + """Checks that the string value of the data defined in Property contains the given value""" + EQUALS = "Equals" + """Checks that the string value of the data defined in Property equals the given value""" + IN = "In" + """Checks that the string value of the data defined in Property equals any of the given values + (exact fit)""" + IN_ENUM = "In" + """Checks that the string value of the data defined in Property equals any of the given values + (exact fit)""" + + +class ApplicationSourceResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The application source, what it affects, e.g. Assessments.""" + + ASSESSMENTS = "Assessments" + """The source of the application is assessments""" + + +class AssessedResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sub-assessment resource type.""" + + SQL_SERVER_VULNERABILITY = "SqlServerVulnerability" + CONTAINER_REGISTRY_VULNERABILITY = "ContainerRegistryVulnerability" + SERVER_VULNERABILITY = "ServerVulnerability" + + +class AssessmentStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Programmatic code for the status of the assessment.""" + + HEALTHY = "Healthy" + """The resource is healthy""" + UNHEALTHY = "Unhealthy" + """The resource has a security issue that needs to be addressed""" + NOT_APPLICABLE = "NotApplicable" + """Assessment for this resource did not happen""" + + +class AssessmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BuiltIn if the assessment based on built-in Azure Policy definition, Custom if the assessment + based on custom Azure Policy definition. + """ + + BUILT_IN = "BuiltIn" + """Microsoft Defender for Cloud managed assessments""" + CUSTOM_POLICY = "CustomPolicy" + """User defined policies that are automatically ingested from Azure Policy to Microsoft Defender + for Cloud""" + CUSTOMER_MANAGED = "CustomerManaged" + """User assessments pushed directly by the user or other third party to Microsoft Defender for + Cloud""" + BUILT_IN_POLICY = "BuiltInPolicy" + """Microsoft Defender for Cloud managed policies""" + VERIFIED_PARTNER = "VerifiedPartner" + """Third party assessments that are verified by Microsoft Defender for Cloud""" + MANUAL_BUILT_IN_POLICY = "ManualBuiltInPolicy" + """Microsoft Defender for Cloud managed policies that are manually created by the user""" + MANUAL_BUILT_IN = "ManualBuiltIn" + """Microsoft Defender for Cloud managed assessments that are manually created by the user""" + MANUAL_CUSTOM_POLICY = "ManualCustomPolicy" + """User defined policies that are manually created by the user""" + DYNAMIC_BUILT_IN = "DynamicBuiltIn" + """Microsoft Defender for Cloud managed assessments that are dynamically created by the system""" + + +class AttestationComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Attest category of this assignment.""" + + UNKNOWN = "unknown" + COMPLIANT = "compliant" + NON_COMPLIANT = "nonCompliant" + + +class AuthenticationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the multi-cloud connector.""" + + VALID = "Valid" + """Valid connector""" + INVALID = "Invalid" + """Invalid connector""" + EXPIRED = "Expired" + """the connection has expired""" + INCORRECT_POLICY = "IncorrectPolicy" + """Incorrect policy of the connector""" + + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Connect to your cloud account, for AWS use either account credentials or role-based + authentication. For GCP use account organization credentials. + """ + + AWS_CREDS = "awsCreds" + """AWS cloud account connector user credentials authentication""" + AWS_ASSUME_ROLE = "awsAssumeRole" + """AWS account connector assume role authentication""" + GCP_CREDENTIALS = "gcpCredentials" + """GCP account connector service to service authentication""" + + +class AutoDiscovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AutoDiscovery states.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + NOT_APPLICABLE = "NotApplicable" + + +class AutoProvision(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes what kind of security agent provisioning action to take.""" + + ON = "On" + """Install missing security agent on VMs automatically""" + OFF = "Off" + """Do not install security agent on the VMs automatically""" + + +class BlobScanResultsOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Optional. Write scan result on blobIndexTags by default.""" + + BLOB_INDEX_TAGS = "blobIndexTags" + """Write scan results on the blobs index tags.""" + NONE = "None" + """Do not write scan results on the blobs index tags.""" + + +class BundleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Alert Simulator supported bundles.""" + + APP_SERVICES = "AppServices" + DNS = "DNS" + KEY_VAULTS = "KeyVaults" + KUBERNETES_SERVICE = "KubernetesService" + RESOURCE_MANAGER = "ResourceManager" + SQL_SERVERS = "SqlServers" + STORAGE_ACCOUNTS = "StorageAccounts" + VIRTUAL_MACHINES = "VirtualMachines" + COSMOS_DBS = "CosmosDbs" + + +class Categories(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The categories of resource that is at risk when the assessment is unhealthy.""" + + COMPUTE = "Compute" + NETWORKING = "Networking" + DATA = "Data" + IDENTITY_AND_ACCESS = "IdentityAndAccess" + IO_T = "IoT" + CONTAINER = "Container" + APP_SERVICES = "AppServices" + + +class CloudName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The multi cloud resource's cloud name.""" + + AZURE = "Azure" + AWS = "AWS" + GCP = "GCP" + GITHUB = "Github" + AZURE_DEV_OPS = "AzureDevOps" + GIT_LAB = "GitLab" + DOCKER_HUB = "DockerHub" + J_FROG = "JFrog" + + +class Code(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operation status code.""" + + SUCCEEDED = "Succeeded" + """Extension was created/updated successfully.""" + FAILED = "Failed" + """Extension was not created/updated successfully. See operation status message for more details.""" + + +class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ConnectionType.""" + + INTERNAL = "Internal" + EXTERNAL = "External" + + +class ControlType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of security control (for example, BuiltIn).""" + + BUILT_IN = "BuiltIn" + """Microsoft Defender for Cloud managed assessments""" + CUSTOM = "Custom" + """Non Microsoft Defender for Cloud managed assessments""" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DataSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DataSource.""" + + TWIN_DATA = "TwinData" + """Devices twin data""" + + +class DesiredOnboardingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Onboarding states.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class DevOpsProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + PENDING = "Pending" + PENDING_DELETION = "PendingDeletion" + DELETION_SUCCESS = "DeletionSuccess" + DELETION_FAILURE = "DeletionFailure" + + +class Effect(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Expected effect of this assignment (Audit/Exempt/Attest).""" + + AUDIT = "Audit" + EXEMPT = "Exempt" + ATTEST = "Attest" + + +class EndOfSupportStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """End of support status.""" + + NONE = "None" + NO_LONGER_SUPPORTED = "noLongerSupported" + VERSION_NO_LONGER_SUPPORTED = "versionNoLongerSupported" + UPCOMING_NO_LONGER_SUPPORTED = "upcomingNoLongerSupported" + UPCOMING_VERSION_NO_LONGER_SUPPORTED = "upcomingVersionNoLongerSupported" + + +class Enforce(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """If set to "False", it allows the descendants of this scope to override the pricing + configuration set on this scope (allows setting inherited="False"). If set to "True", it + prevents overrides and forces this pricing configuration on all the descendants of this scope. + This field is only available for subscription-level pricing. + """ + + FALSE = "False" + """Allows the descendants of this scope to override the pricing configuration set on this scope + (allows setting inherited="False")""" + TRUE = "True" + """Prevents overrides and forces the current scope's pricing configuration to all descendants""" + + +class EnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the environment data.""" + + AWS_ACCOUNT = "AwsAccount" + GCP_PROJECT = "GcpProject" + GITHUB_SCOPE = "GithubScope" + AZURE_DEV_OPS_SCOPE = "AzureDevOpsScope" + GITLAB_SCOPE = "GitlabScope" + DOCKER_HUB_ORGANIZATION = "DockerHubOrganization" + J_FROG_ARTIFACTORY = "JFrogArtifactory" + + +class EventSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A valid event source type.""" + + ASSESSMENTS = "Assessments" + ASSESSMENTS_SNAPSHOT = "AssessmentsSnapshot" + SUB_ASSESSMENTS = "SubAssessments" + SUB_ASSESSMENTS_SNAPSHOT = "SubAssessmentsSnapshot" + ALERTS = "Alerts" + SECURE_SCORES = "SecureScores" + SECURE_SCORES_SNAPSHOT = "SecureScoresSnapshot" + SECURE_SCORE_CONTROLS = "SecureScoreControls" + SECURE_SCORE_CONTROLS_SNAPSHOT = "SecureScoreControlsSnapshot" + REGULATORY_COMPLIANCE_ASSESSMENT = "RegulatoryComplianceAssessment" + REGULATORY_COMPLIANCE_ASSESSMENT_SNAPSHOT = "RegulatoryComplianceAssessmentSnapshot" + ATTACK_PATHS = "AttackPaths" + ATTACK_PATHS_SNAPSHOT = "AttackPathsSnapshot" + + +class ExemptionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Exemption category of this assignment.""" + + WAIVER = "waiver" + MITIGATED = "mitigated" + + +class ExpandControlsEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExpandControlsEnum.""" + + DEFINITION = "definition" + """Add definition object for each control""" + + +class ExpandEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExpandEnum.""" + + LINKS = "links" + """All links associated with an assessment""" + METADATA = "metadata" + """Assessment metadata""" + + +class ExportData(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExportData.""" + + RAW_EVENTS = "RawEvents" + """Agent raw events""" + + +class ExternalSecuritySolutionKindEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of the external solution.""" + + CEF = "CEF" + ATA = "ATA" + AAD = "AAD" + + +class GovernanceRuleConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The governance rule Condition's Operator, for example Equals for severity or In for list of + assessments, see examples. + """ + + EQUALS = "Equals" + """Checks that the string value of the data defined in Property equals the given value - exact fit""" + IN = "In" + """Checks that the string value of the data defined in Property equals any of the given values + (exact fit)""" + IN_ENUM = "In" + """Checks that the string value of the data defined in Property equals any of the given values + (exact fit)""" + + +class GovernanceRuleOwnerSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The owner type for the governance rule owner source.""" + + BY_TAG = "ByTag" + """The rule source type defined using resource tag""" + MANUALLY = "Manually" + """The rule source type defined manually""" + + +class GovernanceRuleSourceResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The governance rule source, what the rule affects, e.g. Assessments.""" + + ASSESSMENTS = "Assessments" + """The source of the governance rule is assessments""" + + +class GovernanceRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The rule type of the governance rule, defines the source of the rule e.g. Integrated.""" + + INTEGRATED = "Integrated" + """The source of the rule type definition is integrated""" + SERVICE_NOW = "ServiceNow" + """The source of the rule type definition is ServiceNow""" + + +class HybridComputeProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the service principal and its secret.""" + + VALID = "Valid" + """Valid service principal details.""" + INVALID = "Invalid" + """Invalid service principal details.""" + EXPIRED = "Expired" + """the service principal details are expired""" + + +class ImplementationEffort(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The implementation effort required to remediate this assessment.""" + + LOW = "Low" + MODERATE = "Moderate" + HIGH = "High" + + +class InformationProtectionPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """InformationProtectionPolicyName.""" + + EFFECTIVE = "effective" + CUSTOM = "custom" + + +class Inherited(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ "inherited" = "True" indicates that the current scope inherits its pricing configuration from + its parent. The ID of the parent scope that provides the inherited configuration is displayed + in the "inheritedFrom" field. On the other hand, "inherited" = "False" indicates that the + current scope has its own pricing configuration explicitly set, and does not inherit from its + parent. This field is read only and available only for resource-level pricing. + """ + + TRUE = "True" + """Indicates that the current scope is inheriting its pricing configuration from its parent""" + FALSE = "False" + """Indicates that the current scope sets its own pricing configuration and does not inherit it + from its parent""" + + +class InheritFromParentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Update Settings. + + Enabled - Resource should inherit configurations from parent. + Disabled - Resource should not inherit configurations from parent. + """ + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class Intent(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kill chain related intent behind the alert. For list of supported values, and explanations + of Azure Security Center's supported kill chain intents. + """ + + UNKNOWN = "Unknown" + """Unknown""" + PRE_ATTACK = "PreAttack" + """PreAttack could be either an attempt to access a certain resource regardless of a malicious + intent, or a failed attempt to gain access to a target system to gather information prior to + exploitation. This step is usually detected as an attempt, originating from outside the + network, to scan the target system and find a way in. Further details on the PreAttack stage + can be read in `MITRE Pre-Att&ck matrix `_.""" + INITIAL_ACCESS = "InitialAccess" + """InitialAccess is the stage where an attacker manages to get foothold on the attacked resource.""" + PERSISTENCE = "Persistence" + """Persistence is any access, action, or configuration change to a system that gives a threat + actor a persistent presence on that system.""" + PRIVILEGE_ESCALATION = "PrivilegeEscalation" + """Privilege escalation is the result of actions that allow an adversary to obtain a higher level + of permissions on a system or network.""" + DEFENSE_EVASION = "DefenseEvasion" + """Defense evasion consists of techniques an adversary may use to evade detection or avoid other + defenses.""" + CREDENTIAL_ACCESS = "CredentialAccess" + """Credential access represents techniques resulting in access to or control over system, domain, + or service credentials that are used within an enterprise environment.""" + DISCOVERY = "Discovery" + """Discovery consists of techniques that allow the adversary to gain knowledge about the system + and internal network.""" + LATERAL_MOVEMENT = "LateralMovement" + """Lateral movement consists of techniques that enable an adversary to access and control remote + systems on a network and could, but does not necessarily, include execution of tools on remote + systems.""" + EXECUTION = "Execution" + """The execution tactic represents techniques that result in execution of adversary-controlled + code on a local or remote system.""" + COLLECTION = "Collection" + """Collection consists of techniques used to identify and gather information, such as sensitive + files, from a target network prior to exfiltration.""" + EXFILTRATION = "Exfiltration" + """Exfiltration refers to techniques and attributes that result or aid in the adversary removing + files and information from a target network.""" + COMMAND_AND_CONTROL = "CommandAndControl" + """The command and control tactic represents how adversaries communicate with systems under their + control within a target network.""" + IMPACT = "Impact" + """Impact events primarily try to directly reduce the availability or integrity of a system, + service, or network; including manipulation of data to impact a business or operational + process.""" + PROBING = "Probing" + """Probing could be either an attempt to access a certain resource regardless of a malicious + intent, or a failed attempt to gain access to a target system to gather information prior to + exploitation.""" + EXPLOITATION = "Exploitation" + """Exploitation is the stage where an attacker manages to get a foothold on the attacked resource. + This stage is relevant for compute hosts and resources such as user accounts, certificates etc.""" + + +class InventoryKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Types for inventory kind.""" + + AZURE_DEV_OPS_ORGANIZATION = "AzureDevOpsOrganization" + AZURE_DEV_OPS_PROJECT = "AzureDevOpsProject" + AZURE_DEV_OPS_REPOSITORY = "AzureDevOpsRepository" + GIT_HUB_OWNER = "GitHubOwner" + GIT_HUB_REPOSITORY = "GitHubRepository" + + +class InventoryListKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Types for inventory list.""" + + INCLUSION = "Inclusion" + EXCLUSION = "Exclusion" + + +class IsEnabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether the extension is enabled.""" + + TRUE = "True" + """Indicates the extension is enabled""" + FALSE = "False" + """Indicates the extension is disabled""" + + +class KindEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of alert simulation.""" + + BUNDLES = "Bundles" + """Simulate alerts according to bundles""" + + +class MinimalRiskLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the minimal attack path risk level which will be sent as email notifications.""" + + CRITICAL = "Critical" + """Get notifications on new attack paths with Critical risk level""" + HIGH = "High" + """Get notifications on new attack paths with High or Critical risk level""" + MEDIUM = "Medium" + """Get notifications on new attach paths with Medium, High or Critical risk level""" + LOW = "Low" + """Get notifications on new attach paths with Low, Medium, High or Critical risk level""" + + +class MinimalSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the minimal alert severity which will be sent as email notifications.""" + + HIGH = "High" + """Get notifications on new alerts with High severity""" + MEDIUM = "Medium" + """Get notifications on new alerts with Medium or High severity""" + LOW = "Low" + """Get notifications on new alerts with Low, Medium or High severity""" + + +class MipIntegrationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Microsoft information protection integration status.""" + + OK = "Ok" + NO_CONSENT = "noConsent" + NO_AUTO_LABELING_RULES = "noAutoLabelingRules" + NO_MIP_LABELS = "noMipLabels" + + +class OfferingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the security offering.""" + + CSPM_MONITOR_AWS = "CspmMonitorAws" + DEFENDER_FOR_CONTAINERS_AWS = "DefenderForContainersAws" + DEFENDER_FOR_SERVERS_AWS = "DefenderForServersAws" + DEFENDER_FOR_DATABASES_AWS = "DefenderForDatabasesAws" + CSPM_MONITOR_GCP = "CspmMonitorGcp" + CSPM_MONITOR_GITHUB = "CspmMonitorGithub" + CSPM_MONITOR_AZURE_DEV_OPS = "CspmMonitorAzureDevOps" + DEFENDER_FOR_SERVERS_GCP = "DefenderForServersGcp" + DEFENDER_FOR_CONTAINERS_GCP = "DefenderForContainersGcp" + DEFENDER_FOR_DATABASES_GCP = "DefenderForDatabasesGcp" + DEFENDER_CSPM_AWS = "DefenderCspmAws" + DEFENDER_CSPM_GCP = "DefenderCspmGcp" + CSPM_MONITOR_GIT_LAB = "CspmMonitorGitLab" + CSPM_MONITOR_DOCKER_HUB = "CspmMonitorDockerHub" + DEFENDER_FOR_CONTAINERS_DOCKER_HUB = "DefenderForContainersDockerHub" + DEFENDER_CSPM_DOCKER_HUB = "DefenderCspmDockerHub" + CSPM_MONITOR_J_FROG = "CspmMonitorJFrog" + DEFENDER_FOR_CONTAINERS_J_FROG = "DefenderForContainersJFrog" + DEFENDER_CSPM_J_FROG = "DefenderCspmJFrog" + + +class OnboardingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. + """ + + NOT_APPLICABLE = "NotApplicable" + ONBOARDED_BY_OTHER_CONNECTOR = "OnboardedByOtherConnector" + ONBOARDED = "Onboarded" + NOT_ONBOARDED = "NotOnboarded" + + +class OperationResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the long run operation result of governance rule.""" + + SUCCEEDED = "Succeeded" + """The operation succeeded""" + FAILED = "Failed" + """The operation failed""" + CANCELED = "Canceled" + """The operation canceled""" + + +class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A valid comparer operator to use. A case-insensitive comparison will be applied for String + PropertyType. + """ + + EQUALS = "Equals" + """Applies for decimal and non-decimal operands""" + GREATER_THAN = "GreaterThan" + """Applies only for decimal operands""" + GREATER_THAN_OR_EQUAL_TO = "GreaterThanOrEqualTo" + """Applies only for decimal operands""" + LESSER_THAN = "LesserThan" + """Applies only for decimal operands""" + LESSER_THAN_OR_EQUAL_TO = "LesserThanOrEqualTo" + """Applies only for decimal operands""" + NOT_EQUALS = "NotEquals" + """Applies for decimal and non-decimal operands""" + CONTAINS = "Contains" + """Applies only for non-decimal operands""" + STARTS_WITH = "StartsWith" + """Applies only for non-decimal operands""" + ENDS_WITH = "EndsWith" + """Applies only for non-decimal operands""" + + +class OrganizationMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The multi cloud account's membership type in the organization.""" + + MEMBER = "Member" + ORGANIZATION = "Organization" + + +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 PermissionProperty(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A permission detected in the cloud account.""" + + AWS_AWS_SECURITY_HUB_READ_ONLY_ACCESS = "AWS::AWSSecurityHubReadOnlyAccess" + """This permission provides read only access to AWS Security Hub resources.""" + AWS_SECURITY_AUDIT = "AWS::SecurityAudit" + """This permission grants access to read security configuration metadata.""" + AWS_AMAZON_SSM_AUTOMATION_ROLE = "AWS::AmazonSSMAutomationRole" + """The permission provides for EC2 Automation service to execute activities defined within + Automation documents.""" + GCP_SECURITY_CENTER_ADMIN_VIEWER = "GCP::Security Center Admin Viewer" + """This permission provides read only access to GCP Security Command Center.""" + + +class PricingTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether the Defender plan is enabled on the selected scope. Microsoft Defender for + Cloud is provided in two pricing tiers: free and standard. The standard tier offers advanced + security capabilities, while the free tier offers basic security features. + """ + + FREE = "Free" + """Get free Microsoft Defender for Cloud experience with basic security features""" + STANDARD = "Standard" + """Get the standard Microsoft Defender for Cloud experience with advanced security features""" + + +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current provisioning state.""" + + SUCCEEDED = "Succeeded" + CREATING = "Creating" + DELETING = "Deleting" + FAILED = "Failed" + + +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + + +class PropertyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data type of the compared operands (string, integer, floating point number or a boolean + [true/false]]. + """ + + STRING = "String" + INTEGER = "Integer" + NUMBER = "Number" + BOOLEAN = "Boolean" + + +class ProtocolEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ProtocolEnum.""" + + TCP = "TCP" + UDP = "UDP" + ALL = "*" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The security family provisioning State.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + UPDATING = "Updating" + + +class Rank(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The rank of the sensitivity label.""" + + NONE = "None" + LOW = "Low" + MEDIUM = "Medium" + HIGH = "High" + CRITICAL = "Critical" + + +class RecommendationConfigStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Recommendation status. When the recommendation status is disabled recommendations are not + generated. + """ + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class RecommendationSupportedClouds(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The cloud that the recommendation is supported on.""" + + AZURE = "Azure" + AWS = "AWS" + GCP = "GCP" + + +class RecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of IoT Security recommendation.""" + + IO_T_ACRAUTHENTICATION = "IoT_ACRAuthentication" + """Authentication schema used for pull an edge module from an ACR repository does not use Service + Principal Authentication.""" + IO_T_AGENT_SENDS_UNUTILIZED_MESSAGES = "IoT_AgentSendsUnutilizedMessages" + """IoT agent message size capacity is currently underutilized, causing an increase in the number + of sent messages. Adjust message intervals for better utilization.""" + IO_T_BASELINE = "IoT_Baseline" + """Identified security related system configuration issues.""" + IO_T_EDGE_HUB_MEM_OPTIMIZE = "IoT_EdgeHubMemOptimize" + """You can optimize Edge Hub memory usage by turning off protocol heads for any protocols not used + by Edge modules in your solution.""" + IO_T_EDGE_LOGGING_OPTIONS = "IoT_EdgeLoggingOptions" + """Logging is disabled for this edge module.""" + IO_T_INCONSISTENT_MODULE_SETTINGS = "IoT_InconsistentModuleSettings" + """A minority within a device security group has inconsistent Edge Module settings with the rest + of their group.""" + IO_T_INSTALL_AGENT = "IoT_InstallAgent" + """Install the Azure Security of Things Agent.""" + IO_T_IPFILTER_DENY_ALL = "IoT_IPFilter_DenyAll" + """IP Filter Configuration should have rules defined for allowed traffic and should deny all other + traffic by default.""" + IO_T_IPFILTER_PERMISSIVE_RULE = "IoT_IPFilter_PermissiveRule" + """An Allow IP Filter rules source IP range is too large. Overly permissive rules might expose + your IoT hub to malicious intenders.""" + IO_T_OPEN_PORTS = "IoT_OpenPorts" + """A listening endpoint was found on the device.""" + IO_T_PERMISSIVE_FIREWALL_POLICY = "IoT_PermissiveFirewallPolicy" + """An Allowed firewall policy was found (INPUT/OUTPUT). The policy should Deny all traffic by + default and define rules to allow necessary communication to/from the device.""" + IO_T_PERMISSIVE_INPUT_FIREWALL_RULES = "IoT_PermissiveInputFirewallRules" + """A rule in the firewall has been found that contains a permissive pattern for a wide range of IP + addresses or Ports.""" + IO_T_PERMISSIVE_OUTPUT_FIREWALL_RULES = "IoT_PermissiveOutputFirewallRules" + """A rule in the firewall has been found that contains a permissive pattern for a wide range of IP + addresses or Ports.""" + IO_T_PRIVILEGED_DOCKER_OPTIONS = "IoT_PrivilegedDockerOptions" + """Edge module is configured to run in privileged mode, with extensive Linux capabilities or with + host-level network access (send/receive data to host machine).""" + IO_T_SHARED_CREDENTIALS = "IoT_SharedCredentials" + """Same authentication credentials to the IoT Hub used by multiple devices. This could indicate an + illegitimate device impersonating a legitimate device. It also exposes the risk of device + impersonation by an attacker.""" + IO_T_VULNERABLE_TLS_CIPHER_SUITE = "IoT_VulnerableTLSCipherSuite" + """Insecure TLS configurations detected. Immediate upgrade recommended.""" + + +class ReportedSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Assessed alert severity.""" + + INFORMATIONAL = "Informational" + LOW = "Low" + MEDIUM = "Medium" + HIGH = "High" + + +class ResourceIdentifierType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """There can be multiple identifiers of different type per alert, this field specify the + identifier type. + """ + + AZURE_RESOURCE = "AzureResource" + LOG_ANALYTICS = "LogAnalytics" + + +class ResourcesCoverageStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This field is available for subscription-level only, and reflects the coverage status of the + resources under the subscription. Please note: The "pricingTier" field reflects the plan status + of the subscription. However, since the plan status can also be defined at the resource level, + there might be misalignment between the subscription's plan status and the resource status. + This field helps indicate the coverage status of the resources. + """ + + FULLY_COVERED = "FullyCovered" + """This value indicates that all resources associated with the subscription have the Defender plan + enabled.""" + PARTIALLY_COVERED = "PartiallyCovered" + """This value indicates that some resources under the subscription have the Defender plan enabled, + while others have it disabled. There is a mixed coverage status among resources.""" + NOT_COVERED = "NotCovered" + """This value indicates that the Defender plan is disabled for all resources under the + subscription. None of the resources are protected by the Defender plan.""" + + +class ResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the resource regarding a single assessment.""" + + HEALTHY = "Healthy" + """This assessment on the resource is healthy""" + NOT_APPLICABLE = "NotApplicable" + """This assessment is not applicable to this resource""" + OFF_BY_POLICY = "OffByPolicy" + """This assessment is turned off by policy on this subscription""" + NOT_HEALTHY = "NotHealthy" + """This assessment on the resource is not healthy""" + + +class RiskLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The risk level.""" + + LOW = "Low" + MEDIUM = "Medium" + HIGH = "High" + + +class RuleCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Rule categories. + Code - code scanning results. + Artifact scanning results. + Dependencies scanning results. + IaC results. + Secrets scanning results. + Container scanning results. + """ + + CODE = "Code" + ARTIFACTS = "Artifacts" + DEPENDENCIES = "Dependencies" + SECRETS = "Secrets" + IA_C = "IaC" + CONTAINERS = "Containers" + + +class RuleSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The rule severity.""" + + HIGH = "High" + """High""" + MEDIUM = "Medium" + """Medium""" + LOW = "Low" + """Low""" + INFORMATIONAL = "Informational" + """Informational""" + OBSOLETE = "Obsolete" + """Obsolete""" + + +class RuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Possible states of the rule.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + EXPIRED = "Expired" + + +class RuleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The rule result status.""" + + NON_FINDING = "NonFinding" + """NonFinding""" + FINDING = "Finding" + """Finding""" + INTERNAL_ERROR = "InternalError" + """InternalError""" + + +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The rule type.""" + + BINARY = "Binary" + """Binary""" + BASELINE_EXPECTED = "BaselineExpected" + """BaselineExpected""" + POSITIVE_LIST = "PositiveList" + """PositiveList""" + NEGATIVE_LIST = "NegativeList" + """NegativeList""" + + +class ScanningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scanning mode for the VM scan.""" + + DEFAULT = "Default" + + +class ScanState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scan status.""" + + FAILED = "Failed" + """Failed""" + FAILED_TO_RUN = "FailedToRun" + """FailedToRun""" + IN_PROGRESS = "InProgress" + """InProgress""" + PASSED = "Passed" + """Passed""" + + +class ScanTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scan trigger type.""" + + ON_DEMAND = "OnDemand" + """OnDemand""" + RECURRING = "Recurring" + """Recurring""" + + +class SecurityContactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SecurityContactName.""" + + DEFAULT = "default" + """The single applicable name of the security contact object""" + + +class SecurityContactRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A possible role to configure sending security notification alerts to.""" + + ACCOUNT_ADMIN = "AccountAdmin" + """If enabled, send notification on new alerts to the account admins""" + SERVICE_ADMIN = "ServiceAdmin" + """If enabled, send notification on new alerts to the service admins""" + OWNER = "Owner" + """If enabled, send notification on new alerts to the subscription owners""" + CONTRIBUTOR = "Contributor" + """If enabled, send notification on new alerts to the subscription contributors""" + + +class SecurityFamily(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The security family of the discovered solution.""" + + WAF = "Waf" + NGFW = "Ngfw" + SAAS_WAF = "SaasWaf" + VA = "Va" + + +class SecurityIssue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The severity to relate to the assessments generated by this Recommendation.""" + + VULNERABILITY = "Vulnerability" + EXCESSIVE_PERMISSIONS = "ExcessivePermissions" + ANONYMOUS_ACCESS = "AnonymousAccess" + NETWORK_EXPOSURE = "NetworkExposure" + TRAFFIC_ENCRYPTION = "TrafficEncryption" + BEST_PRACTICES = "BestPractices" + + +class SecuritySolutionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the IoT Security solution.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ServerVulnerabilityAssessmentPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioningState of the vulnerability assessment capability on the VM.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + PROVISIONING = "Provisioning" + DEPROVISIONING = "Deprovisioning" + + +class ServerVulnerabilityAssessmentsAzureSettingSelectedProvider(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The selected vulnerability assessments provider on Azure servers in the defined scope.""" + + MDE_TVM = "MdeTvm" + """Microsoft Defender for Endpoints threat and vulnerability management.""" + + +class ServerVulnerabilityAssessmentsSettingKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of the server vulnerability assessments setting.""" + + AZURE_SERVERS_SETTING = "AzureServersSetting" + + +class ServerVulnerabilityAssessmentsSettingKindName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ServerVulnerabilityAssessmentsSettingKindName.""" + + AZURE_SERVERS_SETTING = "azureServersSetting" + + +class SettingKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the kind of the settings string.""" + + DATA_EXPORT_SETTINGS = "DataExportSettings" + ALERT_SUPPRESSION_SETTING = "AlertSuppressionSetting" + ALERT_SYNC_SETTINGS = "AlertSyncSettings" + + +class SettingName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SettingName.""" + + CURRENT = "current" + """Name of the Defender for Storage Settings name.""" + + +class SettingNameAutoGenerated(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SettingNameAutoGenerated.""" + + MCAS = "MCAS" + WDATP = "WDATP" + WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW = "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW" + WDATP_UNIFIED_SOLUTION = "WDATP_UNIFIED_SOLUTION" + SENTINEL = "Sentinel" + + +class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sub-assessment severity level.""" + + LOW = "Low" + MEDIUM = "Medium" + HIGH = "High" + + +class SeverityEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The severity to relate to the assessments generated by this assessment automation.""" + + HIGH = "High" + MEDIUM = "Medium" + LOW = "Low" + + +class Source(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The platform where the assessed resource resides.""" + + AZURE = "Azure" + """Resource is in Azure""" + ON_PREMISE = "OnPremise" + """Resource in an on premise machine connected to Azure cloud""" + ON_PREMISE_SQL = "OnPremiseSql" + """SQL Resource in an on premise machine connected to Azure cloud""" + + +class SourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source type that will trigger the notification.""" + + ALERT = "Alert" + ATTACK_PATH = "AttackPath" + + +class StandardSupportedCloud(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The cloud that the standard is supported on.""" + + AZURE = "Azure" + AWS = "AWS" + GCP = "GCP" + + +class StandardType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Standard type (Custom or Default or Compliance only currently).""" + + CUSTOM = "Custom" + DEFAULT = "Default" + COMPLIANCE = "Compliance" + + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Aggregative state based on the standard's supported controls states.""" + + PASSED = "Passed" + """All supported regulatory compliance controls in the given standard have a passed state""" + FAILED = "Failed" + """At least one supported regulatory compliance control in the given standard has a state of + failed""" + SKIPPED = "Skipped" + """All supported regulatory compliance controls in the given standard have a state of skipped""" + UNSUPPORTED = "Unsupported" + """No supported regulatory compliance data for the given standard""" + + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the port.""" + + REVOKED = "Revoked" + INITIATED = "Initiated" + + +class StatusName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the health report.""" + + HEALTHY = "Healthy" + NOT_HEALTHY = "NotHealthy" + NOT_APPLICABLE = "NotApplicable" + + +class StatusReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A description of why the ``status`` has its value.""" + + EXPIRED = "Expired" + USER_REQUESTED = "UserRequested" + NEWER_REQUEST_INITIATED = "NewerRequestInitiated" + + +class SubAssessmentStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Programmatic code for the status of the assessment.""" + + HEALTHY = "Healthy" + """The resource is healthy""" + UNHEALTHY = "Unhealthy" + """The resource has a security issue that needs to be addressed""" + NOT_APPLICABLE = "NotApplicable" + """Assessment for this resource did not happen""" + + +class SubPlan(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The available sub plans.""" + + P1 = "P1" + P2 = "P2" + + +class SupportedCloudEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Relevant cloud for the custom assessment automation.""" + + AWS = "AWS" + GCP = "GCP" + + +class Tactics(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Tactic of the assessment.""" + + RECONNAISSANCE = "Reconnaissance" + RESOURCE_DEVELOPMENT = "Resource Development" + INITIAL_ACCESS = "Initial Access" + EXECUTION = "Execution" + PERSISTENCE = "Persistence" + PRIVILEGE_ESCALATION = "Privilege Escalation" + DEFENSE_EVASION = "Defense Evasion" + CREDENTIAL_ACCESS = "Credential Access" + DISCOVERY = "Discovery" + LATERAL_MOVEMENT = "Lateral Movement" + COLLECTION = "Collection" + COMMAND_AND_CONTROL = "Command and Control" + EXFILTRATION = "Exfiltration" + IMPACT = "Impact" + + +class TaskUpdateActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TaskUpdateActionType.""" + + ACTIVATE = "Activate" + DISMISS = "Dismiss" + START = "Start" + RESOLVE = "Resolve" + CLOSE = "Close" + + +class Techniques(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Techniques of the assessment.""" + + ABUSE_ELEVATION_CONTROL_MECHANISM = "Abuse Elevation Control Mechanism" + ACCESS_TOKEN_MANIPULATION = "Access Token Manipulation" + ACCOUNT_DISCOVERY = "Account Discovery" + ACCOUNT_MANIPULATION = "Account Manipulation" + ACTIVE_SCANNING = "Active Scanning" + APPLICATION_LAYER_PROTOCOL = "Application Layer Protocol" + AUDIO_CAPTURE = "Audio Capture" + BOOT_OR_LOGON_AUTOSTART_EXECUTION = "Boot or Logon Autostart Execution" + BOOT_OR_LOGON_INITIALIZATION_SCRIPTS = "Boot or Logon Initialization Scripts" + BRUTE_FORCE = "Brute Force" + CLOUD_INFRASTRUCTURE_DISCOVERY = "Cloud Infrastructure Discovery" + CLOUD_SERVICE_DASHBOARD = "Cloud Service Dashboard" + CLOUD_SERVICE_DISCOVERY = "Cloud Service Discovery" + COMMAND_AND_SCRIPTING_INTERPRETER = "Command and Scripting Interpreter" + COMPROMISE_CLIENT_SOFTWARE_BINARY = "Compromise Client Software Binary" + COMPROMISE_INFRASTRUCTURE = "Compromise Infrastructure" + CONTAINER_AND_RESOURCE_DISCOVERY = "Container and Resource Discovery" + CREATE_ACCOUNT = "Create Account" + CREATE_OR_MODIFY_SYSTEM_PROCESS = "Create or Modify System Process" + CREDENTIALS_FROM_PASSWORD_STORES = "Credentials from Password Stores" + DATA_DESTRUCTION = "Data Destruction" + DATA_ENCRYPTED_FOR_IMPACT = "Data Encrypted for Impact" + DATA_FROM_CLOUD_STORAGE_OBJECT = "Data from Cloud Storage Object" + DATA_FROM_CONFIGURATION_REPOSITORY = "Data from Configuration Repository" + DATA_FROM_INFORMATION_REPOSITORIES = "Data from Information Repositories" + DATA_FROM_LOCAL_SYSTEM = "Data from Local System" + DATA_MANIPULATION = "Data Manipulation" + DATA_STAGED = "Data Staged" + DEFACEMENT = "Defacement" + DEOBFUSCATE_DECODE_FILES_OR_INFORMATION = "Deobfuscate/Decode Files or Information" + DISK_WIPE = "Disk Wipe" + DOMAIN_TRUST_DISCOVERY = "Domain Trust Discovery" + DRIVE_BY_COMPROMISE = "Drive-by Compromise" + DYNAMIC_RESOLUTION = "Dynamic Resolution" + ENDPOINT_DENIAL_OF_SERVICE = "Endpoint Denial of Service" + EVENT_TRIGGERED_EXECUTION = "Event Triggered Execution" + EXFILTRATION_OVER_ALTERNATIVE_PROTOCOL = "Exfiltration Over Alternative Protocol" + EXPLOIT_PUBLIC_FACING_APPLICATION = "Exploit Public-Facing Application" + EXPLOITATION_FOR_CLIENT_EXECUTION = "Exploitation for Client Execution" + EXPLOITATION_FOR_CREDENTIAL_ACCESS = "Exploitation for Credential Access" + EXPLOITATION_FOR_DEFENSE_EVASION = "Exploitation for Defense Evasion" + EXPLOITATION_FOR_PRIVILEGE_ESCALATION = "Exploitation for Privilege Escalation" + EXPLOITATION_OF_REMOTE_SERVICES = "Exploitation of Remote Services" + EXTERNAL_REMOTE_SERVICES = "External Remote Services" + FALLBACK_CHANNELS = "Fallback Channels" + FILE_AND_DIRECTORY_DISCOVERY = "File and Directory Discovery" + GATHER_VICTIM_NETWORK_INFORMATION = "Gather Victim Network Information" + HIDE_ARTIFACTS = "Hide Artifacts" + HIJACK_EXECUTION_FLOW = "Hijack Execution Flow" + IMPAIR_DEFENSES = "Impair Defenses" + IMPLANT_CONTAINER_IMAGE = "Implant Container Image" + INDICATOR_REMOVAL_ON_HOST = "Indicator Removal on Host" + INDIRECT_COMMAND_EXECUTION = "Indirect Command Execution" + INGRESS_TOOL_TRANSFER = "Ingress Tool Transfer" + INPUT_CAPTURE = "Input Capture" + INTER_PROCESS_COMMUNICATION = "Inter-Process Communication" + LATERAL_TOOL_TRANSFER = "Lateral Tool Transfer" + MAN_IN_THE_MIDDLE = "Man-in-the-Middle" + MASQUERADING = "Masquerading" + MODIFY_AUTHENTICATION_PROCESS = "Modify Authentication Process" + MODIFY_REGISTRY = "Modify Registry" + NETWORK_DENIAL_OF_SERVICE = "Network Denial of Service" + NETWORK_SERVICE_SCANNING = "Network Service Scanning" + NETWORK_SNIFFING = "Network Sniffing" + NON_APPLICATION_LAYER_PROTOCOL = "Non-Application Layer Protocol" + NON_STANDARD_PORT = "Non-Standard Port" + OBTAIN_CAPABILITIES = "Obtain Capabilities" + OBFUSCATED_FILES_OR_INFORMATION = "Obfuscated Files or Information" + OFFICE_APPLICATION_STARTUP = "Office Application Startup" + OS_CREDENTIAL_DUMPING = "OS Credential Dumping" + PERMISSION_GROUPS_DISCOVERY = "Permission Groups Discovery" + PHISHING = "Phishing" + PRE_OS_BOOT = "Pre-OS Boot" + PROCESS_DISCOVERY = "Process Discovery" + PROCESS_INJECTION = "Process Injection" + PROTOCOL_TUNNELING = "Protocol Tunneling" + PROXY = "Proxy" + QUERY_REGISTRY = "Query Registry" + REMOTE_ACCESS_SOFTWARE = "Remote Access Software" + REMOTE_SERVICE_SESSION_HIJACKING = "Remote Service Session Hijacking" + REMOTE_SERVICES = "Remote Services" + REMOTE_SYSTEM_DISCOVERY = "Remote System Discovery" + RESOURCE_HIJACKING = "Resource Hijacking" + SCHEDULED_TASK_JOB = "Scheduled Task/Job" + SCREEN_CAPTURE = "Screen Capture" + SEARCH_VICTIM_OWNED_WEBSITES = "Search Victim-Owned Websites" + SERVER_SOFTWARE_COMPONENT = "Server Software Component" + SERVICE_STOP = "Service Stop" + SIGNED_BINARY_PROXY_EXECUTION = "Signed Binary Proxy Execution" + SOFTWARE_DEPLOYMENT_TOOLS = "Software Deployment Tools" + SQL_STORED_PROCEDURES = "SQL Stored Procedures" + STEAL_OR_FORGE_KERBEROS_TICKETS = "Steal or Forge Kerberos Tickets" + SUBVERT_TRUST_CONTROLS = "Subvert Trust Controls" + SUPPLY_CHAIN_COMPROMISE = "Supply Chain Compromise" + SYSTEM_INFORMATION_DISCOVERY = "System Information Discovery" + TAINT_SHARED_CONTENT = "Taint Shared Content" + TRAFFIC_SIGNALING = "Traffic Signaling" + TRANSFER_DATA_TO_CLOUD_ACCOUNT = "Transfer Data to Cloud Account" + TRUSTED_RELATIONSHIP = "Trusted Relationship" + UNSECURED_CREDENTIALS = "Unsecured Credentials" + USER_EXECUTION = "User Execution" + VALID_ACCOUNTS = "Valid Accounts" + WINDOWS_MANAGEMENT_INSTRUMENTATION = "Windows Management Instrumentation" + FILE_AND_DIRECTORY_PERMISSIONS_MODIFICATION = "File and Directory Permissions Modification" + + +class Threats(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Threats impact of the assessment.""" + + ACCOUNT_BREACH = "accountBreach" + DATA_EXFILTRATION = "dataExfiltration" + DATA_SPILLAGE = "dataSpillage" + MALICIOUS_INSIDER = "maliciousInsider" + ELEVATION_OF_PRIVILEGE = "elevationOfPrivilege" + THREAT_RESISTANCE = "threatResistance" + MISSING_COVERAGE = "missingCoverage" + DENIAL_OF_SERVICE = "denialOfService" + + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or 'Qualys'.""" + + QUALYS = "Qualys" + TVM = "TVM" + + +class UnmaskedIpLoggingStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Unmasked IP address logging status.""" + + DISABLED = "Disabled" + """Unmasked IP logging is disabled""" + ENABLED = "Enabled" + """Unmasked IP logging is enabled""" + + +class UserImpact(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The user impact of the assessment.""" + + LOW = "Low" + MODERATE = "Moderate" + HIGH = "High" + + +class ValueType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value type of the items in the list.""" + + IP_CIDR = "IpCidr" + """An IP range in CIDR format (e.g. '192.168.0.1/8').""" + STRING = "String" + """Any string value.""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/__init__.py new file mode 100644 index 000000000000..7cefa0cf68cd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/__init__.py @@ -0,0 +1,172 @@ +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._locations_operations import LocationsOperations # type: ignore +from ._tasks_operations import TasksOperations # type: ignore +from ._auto_provisioning_settings_operations import AutoProvisioningSettingsOperations # type: ignore +from ._compliances_operations import CompliancesOperations # type: ignore +from ._information_protection_policies_operations import InformationProtectionPoliciesOperations # type: ignore +from ._workspace_settings_operations import WorkspaceSettingsOperations # type: ignore +from ._alerts_suppression_rules_operations import AlertsSuppressionRulesOperations # type: ignore +from ._regulatory_compliance_standards_operations import RegulatoryComplianceStandardsOperations # type: ignore +from ._regulatory_compliance_controls_operations import RegulatoryComplianceControlsOperations # type: ignore +from ._regulatory_compliance_assessments_operations import RegulatoryComplianceAssessmentsOperations # type: ignore +from ._sub_assessments_operations import SubAssessmentsOperations # type: ignore +from ._connectors_operations import ConnectorsOperations # type: ignore +from ._software_inventories_operations import SoftwareInventoriesOperations # type: ignore +from ._custom_assessment_automations_operations import CustomAssessmentAutomationsOperations # type: ignore +from ._custom_entity_store_assignments_operations import CustomEntityStoreAssignmentsOperations # type: ignore +from ._mde_onboardings_operations import MdeOnboardingsOperations # type: ignore +from ._governance_assignments_operations import GovernanceAssignmentsOperations # type: ignore +from ._governance_rules_operations import GovernanceRulesOperations # type: ignore +from ._applications_operations import ApplicationsOperations # type: ignore +from ._application_operations import ApplicationOperations # type: ignore +from ._security_connector_applications_operations import SecurityConnectorApplicationsOperations # type: ignore +from ._security_connector_application_operations import SecurityConnectorApplicationOperations # type: ignore +from ._security_operators_operations import SecurityOperatorsOperations # type: ignore +from ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations # type: ignore +from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations # type: ignore +from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations # type: ignore +from ._sensitivity_settings_operations import SensitivitySettingsOperations # type: ignore +from ._health_reports_operations import HealthReportsOperations # type: ignore +from ._automations_operations import AutomationsOperations # type: ignore +from ._security_contacts_operations import SecurityContactsOperations # type: ignore +from ._security_connectors_operations import SecurityConnectorsOperations # type: ignore +from ._defender_for_storage_operations import DefenderForStorageOperations # type: ignore +from ._operations import Operations # type: ignore +from ._assessments_metadata_operations import AssessmentsMetadataOperations # type: ignore +from ._assessments_operations import AssessmentsOperations # type: ignore +from ._private_links_operations import PrivateLinksOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._compliance_results_operations import ComplianceResultsOperations # type: ignore +from ._advanced_threat_protection_operations import AdvancedThreatProtectionOperations # type: ignore +from ._device_security_groups_operations import DeviceSecurityGroupsOperations # type: ignore +from ._iot_security_solution_analytics_operations import IotSecuritySolutionAnalyticsOperations # type: ignore +from ._iot_security_solutions_analytics_aggregated_alert_operations import IotSecuritySolutionsAnalyticsAggregatedAlertOperations # type: ignore +from ._iot_security_solutions_analytics_recommendation_operations import IotSecuritySolutionsAnalyticsRecommendationOperations # type: ignore +from ._iot_security_solution_operations import IotSecuritySolutionOperations # type: ignore +from ._allowed_connections_operations import AllowedConnectionsOperations # type: ignore +from ._discovered_security_solutions_operations import DiscoveredSecuritySolutionsOperations # type: ignore +from ._external_security_solutions_operations import ExternalSecuritySolutionsOperations # type: ignore +from ._jit_network_access_policies_operations import JitNetworkAccessPoliciesOperations # type: ignore +from ._secure_scores_operations import SecureScoresOperations # type: ignore +from ._secure_score_controls_operations import SecureScoreControlsOperations # type: ignore +from ._secure_score_control_definitions_operations import SecureScoreControlDefinitionsOperations # type: ignore +from ._security_solutions_operations import SecuritySolutionsOperations # type: ignore +from ._security_solutions_reference_data_operations import SecuritySolutionsReferenceDataOperations # type: ignore +from ._server_vulnerability_assessment_operations import ServerVulnerabilityAssessmentOperations # type: ignore +from ._topology_operations import TopologyOperations # type: ignore +from ._alerts_operations import AlertsOperations # type: ignore +from ._settings_operations import SettingsOperations # type: ignore +from ._server_vulnerability_assessments_settings_operations import ServerVulnerabilityAssessmentsSettingsOperations # type: ignore +from ._api_collections_operations import APICollectionsOperations # type: ignore +from ._pricings_operations import PricingsOperations # type: ignore +from ._security_standards_operations import SecurityStandardsOperations # type: ignore +from ._standard_assignments_operations import StandardAssignmentsOperations # type: ignore +from ._custom_recommendations_operations import CustomRecommendationsOperations # type: ignore +from ._azure_dev_ops_orgs_operations import AzureDevOpsOrgsOperations # type: ignore +from ._azure_dev_ops_projects_operations import AzureDevOpsProjectsOperations # type: ignore +from ._azure_dev_ops_repos_operations import AzureDevOpsReposOperations # type: ignore +from ._dev_ops_configurations_operations import DevOpsConfigurationsOperations # type: ignore +from ._git_hub_owners_operations import GitHubOwnersOperations # type: ignore +from ._git_hub_repos_operations import GitHubReposOperations # type: ignore +from ._git_lab_groups_operations import GitLabGroupsOperations # type: ignore +from ._git_lab_subgroups_operations import GitLabSubgroupsOperations # type: ignore +from ._git_lab_projects_operations import GitLabProjectsOperations # type: ignore +from ._dev_ops_operation_results_operations import DevOpsOperationResultsOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "LocationsOperations", + "TasksOperations", + "AutoProvisioningSettingsOperations", + "CompliancesOperations", + "InformationProtectionPoliciesOperations", + "WorkspaceSettingsOperations", + "AlertsSuppressionRulesOperations", + "RegulatoryComplianceStandardsOperations", + "RegulatoryComplianceControlsOperations", + "RegulatoryComplianceAssessmentsOperations", + "SubAssessmentsOperations", + "ConnectorsOperations", + "SoftwareInventoriesOperations", + "CustomAssessmentAutomationsOperations", + "CustomEntityStoreAssignmentsOperations", + "MdeOnboardingsOperations", + "GovernanceAssignmentsOperations", + "GovernanceRulesOperations", + "ApplicationsOperations", + "ApplicationOperations", + "SecurityConnectorApplicationsOperations", + "SecurityConnectorApplicationOperations", + "SecurityOperatorsOperations", + "SqlVulnerabilityAssessmentBaselineRulesOperations", + "SqlVulnerabilityAssessmentScansOperations", + "SqlVulnerabilityAssessmentScanResultsOperations", + "SensitivitySettingsOperations", + "HealthReportsOperations", + "AutomationsOperations", + "SecurityContactsOperations", + "SecurityConnectorsOperations", + "DefenderForStorageOperations", + "Operations", + "AssessmentsMetadataOperations", + "AssessmentsOperations", + "PrivateLinksOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", + "ComplianceResultsOperations", + "AdvancedThreatProtectionOperations", + "DeviceSecurityGroupsOperations", + "IotSecuritySolutionAnalyticsOperations", + "IotSecuritySolutionsAnalyticsAggregatedAlertOperations", + "IotSecuritySolutionsAnalyticsRecommendationOperations", + "IotSecuritySolutionOperations", + "AllowedConnectionsOperations", + "DiscoveredSecuritySolutionsOperations", + "ExternalSecuritySolutionsOperations", + "JitNetworkAccessPoliciesOperations", + "SecureScoresOperations", + "SecureScoreControlsOperations", + "SecureScoreControlDefinitionsOperations", + "SecuritySolutionsOperations", + "SecuritySolutionsReferenceDataOperations", + "ServerVulnerabilityAssessmentOperations", + "TopologyOperations", + "AlertsOperations", + "SettingsOperations", + "ServerVulnerabilityAssessmentsSettingsOperations", + "APICollectionsOperations", + "PricingsOperations", + "SecurityStandardsOperations", + "StandardAssignmentsOperations", + "CustomRecommendationsOperations", + "AzureDevOpsOrgsOperations", + "AzureDevOpsProjectsOperations", + "AzureDevOpsReposOperations", + "DevOpsConfigurationsOperations", + "GitHubOwnersOperations", + "GitHubReposOperations", + "GitLabGroupsOperations", + "GitLabSubgroupsOperations", + "GitLabProjectsOperations", + "DevOpsOperationResultsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_advanced_threat_protection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_advanced_threat_protection_operations.py new file mode 100644 index 000000000000..d1474023c0c2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_advanced_threat_protection_operations.py @@ -0,0 +1,286 @@ +# 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, Literal, Optional, TypeVar, Union, overload + +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 SecurityCenterConfiguration +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(resource_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", "2019-01-01")) + setting_name: Literal["current"] = kwargs.pop("setting_name", "current") + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request(resource_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", "2019-01-01")) + setting_name: Literal["current"] = kwargs.pop("setting_name", "current") + 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", "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "settingName": _SERIALIZER.url("setting_name", setting_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) + + +class AdvancedThreatProtectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`advanced_threat_protection` 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: SecurityCenterConfiguration = 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_id: str, **kwargs: Any) -> _models.AdvancedThreatProtectionSetting: + """Gets the Advanced Threat Protection settings for the specified resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :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", "2019-01-01")) + setting_name: Literal["current"] = kwargs.pop("setting_name", "current") + cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + api_version=api_version, + setting_name=setting_name, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvancedThreatProtectionSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_id: str, + advanced_threat_protection_setting: _models.AdvancedThreatProtectionSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AdvancedThreatProtectionSetting: + """Creates or updates the Advanced Threat Protection settings on a specified resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Required. + :type advanced_threat_protection_setting: + ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_id: str, + advanced_threat_protection_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AdvancedThreatProtectionSetting: + """Creates or updates the Advanced Threat Protection settings on a specified resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Required. + :type advanced_threat_protection_setting: 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: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_id: str, + advanced_threat_protection_setting: Union[_models.AdvancedThreatProtectionSetting, IO[bytes]], + **kwargs: Any + ) -> _models.AdvancedThreatProtectionSetting: + """Creates or updates the Advanced Threat Protection settings on a specified resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Is either a + AdvancedThreatProtectionSetting type or a IO[bytes] type. Required. + :type advanced_threat_protection_setting: + ~azure.mgmt.security.models.AdvancedThreatProtectionSetting or IO[bytes] + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting + :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", "2019-01-01")) + setting_name: Literal["current"] = kwargs.pop("setting_name", "current") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(advanced_threat_protection_setting, (IOBase, bytes)): + _content = advanced_threat_protection_setting + else: + _json = self._serialize.body(advanced_threat_protection_setting, "AdvancedThreatProtectionSetting") + + _request = build_create_request( + resource_id=resource_id, + api_version=api_version, + setting_name=setting_name, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvancedThreatProtectionSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_alerts_operations.py new file mode 100644 index 000000000000..753d03d2e169 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_alerts_operations.py @@ -0,0 +1,1567 @@ +# 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 + +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 SecurityCenterConfiguration +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(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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_subscription_level_by_region_request( # pylint: disable=name-too-long + asc_location: 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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_resource_group_level_by_region_request( # pylint: disable=name-too-long + asc_location: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _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_subscription_level_request( + asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_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_get_resource_group_level_request( + resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_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_update_subscription_level_state_to_dismiss_request( # pylint: disable=name-too-long + asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_subscription_level_state_to_resolve_request( # pylint: disable=name-too-long + asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_subscription_level_state_to_activate_request( # pylint: disable=name-too-long + asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_subscription_level_state_to_in_progress_request( # pylint: disable=name-too-long + asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/inProgress", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_resource_group_level_state_to_resolve_request( # pylint: disable=name-too-long + resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_resource_group_level_state_to_dismiss_request( # pylint: disable=name-too-long + resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_resource_group_level_state_to_activate_request( # pylint: disable=name-too-long + resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_resource_group_level_state_to_in_progress_request( # pylint: disable=name-too-long + resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/inProgress", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_simulate_request(asc_location: 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", "2022-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}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`alerts` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.Alert"]: + """List all the alerts that are associated with the subscription. + + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Alert] + :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", "2022-01-01")) + cls: ClsType[_models.AlertList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Alert"]: + """List all the alerts that are associated with the resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Alert] + :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", "2022-01-01")) + cls: ClsType[_models.AlertList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> ItemPaged["_models.Alert"]: + """List all the alerts that are associated with the subscription that are stored in a specific + location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Alert] + :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", "2022-01-01")) + cls: ClsType[_models.AlertList] = 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_subscription_level_by_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_resource_group_level_by_region( + self, asc_location: str, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.Alert"]: + """List all the alerts that are associated with the resource group that are stored in a specific + location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Alert] + :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", "2022-01-01")) + cls: ClsType[_models.AlertList] = 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_resource_group_level_by_region_request( + asc_location=asc_location, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: Any) -> _models.Alert: + """Get an alert that is associated with a subscription. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_name: str + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Alert + :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", "2022-01-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + _request = build_get_subscription_level_request( + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Alert", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_resource_group_level( + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> _models.Alert: + """Get an alert that is associated a resource group or a resource in a resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_name: str + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Alert + :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", "2022-01-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + _request = build_get_resource_group_level_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Alert", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long + self, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_state_to_dismiss_request( + asc_location=asc_location, + alert_name=alert_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long + self, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_state_to_resolve_request( + asc_location=asc_location, + alert_name=alert_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def update_subscription_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long + self, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_state_to_activate_request( + asc_location=asc_location, + alert_name=alert_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def update_subscription_level_state_to_in_progress( # pylint: disable=inconsistent-return-statements,name-too-long + self, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_state_to_in_progress_request( + asc_location=asc_location, + alert_name=alert_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def update_resource_group_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_state_to_resolve_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_state_to_dismiss_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def update_resource_group_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_state_to_activate_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def update_resource_group_level_state_to_in_progress( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any + ) -> None: + """Update the alert's state. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_name: Name of the alert object. Required. + :type alert_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", "2022-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_state_to_in_progress_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + alert_name=alert_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + def _simulate_initial( + self, + asc_location: str, + alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, 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", "2022-01-01")) + 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(alert_simulator_request_body, (IOBase, bytes)): + _content = alert_simulator_request_body + else: + _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") + + _request = build_simulate_request( + asc_location=asc_location, + 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 [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_simulate( + self, + asc_location: str, + alert_simulator_request_body: _models.AlertSimulatorRequestBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Simulate security alerts. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_simulator_request_body: Alert Simulator Request Properties. Required. + :type alert_simulator_request_body: ~azure.mgmt.security.models.AlertSimulatorRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_simulate( + self, + asc_location: str, + alert_simulator_request_body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Simulate security alerts. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_simulator_request_body: Alert Simulator Request Properties. Required. + :type alert_simulator_request_body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_simulate( + self, + asc_location: str, + alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Simulate security alerts. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param alert_simulator_request_body: Alert Simulator Request Properties. Is either a + AlertSimulatorRequestBody type or a IO[bytes] type. Required. + :type alert_simulator_request_body: ~azure.mgmt.security.models.AlertSimulatorRequestBody or + IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._simulate_initial( + asc_location=asc_location, + alert_simulator_request_body=alert_simulator_request_body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # 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": "original-uri"}, **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/security/azure-mgmt-security/azure/mgmt/security/operations/_alerts_suppression_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_alerts_suppression_rules_operations.py new file mode 100644 index 000000000000..ccf79009b08e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_alerts_suppression_rules_operations.py @@ -0,0 +1,470 @@ +# 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 + +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 SecurityCenterConfiguration +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(subscription_id: str, *, alert_type: 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", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if alert_type is not None: + _params["AlertType"] = _SERIALIZER.query("alert_type", alert_type, "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(alerts_suppression_rule_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", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "alertsSuppressionRuleName": _SERIALIZER.url( + "alerts_suppression_rule_name", alerts_suppression_rule_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_update_request(alerts_suppression_rule_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", "2019-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "alertsSuppressionRuleName": _SERIALIZER.url( + "alerts_suppression_rule_name", alerts_suppression_rule_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_delete_request(alerts_suppression_rule_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", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "alertsSuppressionRuleName": _SERIALIZER.url( + "alerts_suppression_rule_name", alerts_suppression_rule_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class AlertsSuppressionRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`alerts_suppression_rules` 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: SecurityCenterConfiguration = 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, alert_type: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.AlertsSuppressionRule"]: + """List of all the dismiss rules for the given subscription. + + :param alert_type: Type of the alert to get rules for. Default value is None. + :type alert_type: str + :return: An iterator like instance of either AlertsSuppressionRule or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AlertsSuppressionRule] + :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", "2019-01-01-preview")) + cls: ClsType[_models.AlertsSuppressionRulesList] = 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( + subscription_id=self._config.subscription_id, + alert_type=alert_type, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertsSuppressionRulesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, alerts_suppression_rule_name: str, **kwargs: Any) -> _models.AlertsSuppressionRule: + """Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_name: str + :return: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule + :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", "2019-01-01-preview")) + cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) + + _request = build_get_request( + alerts_suppression_rule_name=alerts_suppression_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AlertsSuppressionRule", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + alerts_suppression_rule_name: str, + alerts_suppression_rule: _models.AlertsSuppressionRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertsSuppressionRule: + """Update existing rule or create new rule if it doesn't exist. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_name: str + :param alerts_suppression_rule: Suppression rule object. Required. + :type alerts_suppression_rule: ~azure.mgmt.security.models.AlertsSuppressionRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + alerts_suppression_rule_name: str, + alerts_suppression_rule: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertsSuppressionRule: + """Update existing rule or create new rule if it doesn't exist. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_name: str + :param alerts_suppression_rule: Suppression rule object. Required. + :type alerts_suppression_rule: 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: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + alerts_suppression_rule_name: str, + alerts_suppression_rule: Union[_models.AlertsSuppressionRule, IO[bytes]], + **kwargs: Any + ) -> _models.AlertsSuppressionRule: + """Update existing rule or create new rule if it doesn't exist. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_name: str + :param alerts_suppression_rule: Suppression rule object. Is either a AlertsSuppressionRule type + or a IO[bytes] type. Required. + :type alerts_suppression_rule: ~azure.mgmt.security.models.AlertsSuppressionRule or IO[bytes] + :return: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule + :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", "2019-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alerts_suppression_rule, (IOBase, bytes)): + _content = alerts_suppression_rule + else: + _json = self._serialize.body(alerts_suppression_rule, "AlertsSuppressionRule") + + _request = build_update_request( + alerts_suppression_rule_name=alerts_suppression_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AlertsSuppressionRule", 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, alerts_suppression_rule_name: str, **kwargs: Any + ) -> None: + """Delete dismiss alert rule for this subscription. + + :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. + :type alerts_suppression_rule_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", "2019-01-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + alerts_suppression_rule_name=alerts_suppression_rule_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_allowed_connections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_allowed_connections_operations.py new file mode 100644 index 000000000000..acbd49cd2867 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_allowed_connections_operations.py @@ -0,0 +1,351 @@ +# 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, Union + +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 SecurityCenterConfiguration +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(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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( + resource_group_name: str, + asc_location: str, + connection_type: Union[str, _models.ConnectionType], + 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "connectionType": _SERIALIZER.url("connection_type", connection_type, "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) + + +class AllowedConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`allowed_connections` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.AllowedConnectionsResource"]: + """Gets the list of all possible traffic between resources for the subscription. + + :return: An iterator like instance of either AllowedConnectionsResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AllowedConnectionsResource] + :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", "2020-01-01")) + cls: ClsType[_models.AllowedConnectionsList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AllowedConnectionsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region(self, asc_location: str, **kwargs: Any) -> ItemPaged["_models.AllowedConnectionsResource"]: + """Gets the list of all possible traffic between resources for the subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either AllowedConnectionsResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AllowedConnectionsResource] + :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", "2020-01-01")) + cls: ClsType[_models.AllowedConnectionsList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AllowedConnectionsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + asc_location: str, + connection_type: Union[str, _models.ConnectionType], + **kwargs: Any + ) -> _models.AllowedConnectionsResource: + """Gets the list of all possible traffic between resources for the subscription and location, + based on connection type. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param connection_type: The type of allowed connections (Internal, External). Known values are: + "Internal" and "External". Required. + :type connection_type: str or ~azure.mgmt.security.models.ConnectionType + :return: AllowedConnectionsResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AllowedConnectionsResource + :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", "2020-01-01")) + cls: ClsType[_models.AllowedConnectionsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + connection_type=connection_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AllowedConnectionsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_api_collections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_api_collections_operations.py new file mode 100644 index 000000000000..4a6a3e1727ad --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_api_collections_operations.py @@ -0,0 +1,759 @@ +# 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, Iterator, Optional, TypeVar, Union, cast + +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 SecurityCenterConfiguration +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_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/apiCollections") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/apiCollections", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_azure_api_management_service_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[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_get_by_azure_api_management_service_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, api_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", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, 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_onboard_azure_api_management_api_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, api_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", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_offboard_azure_api_management_api_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, api_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", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, 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) + + +class APICollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`api_collections` 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: SecurityCenterConfiguration = 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_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.ApiCollection"]: + """Gets a list of API collections within a subscription. + + Gets a list of API collections within a subscription that have been onboarded to Microsoft + Defender for APIs. + + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ApiCollection] + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", 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_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.ApiCollection"]: + """Gets a list of API collections within a resource group. + + Gets a list of API collections within a resource group that have been onboarded to Microsoft + Defender for APIs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ApiCollection] + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", 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_by_azure_api_management_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> ItemPaged["_models.ApiCollection"]: + """Gets a list of onboarded Azure API Management APIs. + + Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for + APIs. If an Azure API Management API is onboarded to Microsoft Defender for APIs, the system + will monitor the operations within the Azure API Management API for intrusive behaviors and + provide alerts for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ApiCollection] + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = 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_by_azure_api_management_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", 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_by_azure_api_management_service( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> _models.ApiCollection: + """Gets an onboarded Azure API Management API. + + Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an + Azure API Management API is onboarded to Microsoft Defender for APIs, the system will monitor + the operations within the Azure API Management API for intrusive behaviors and provide alerts + for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: ApiCollection or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ApiCollection + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + + _request = build_get_by_azure_api_management_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_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("ApiCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _onboard_azure_api_management_api_initial( # pylint: disable=name-too-long + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_onboard_azure_api_management_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + 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 [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["Location"] = self._deserialize("str", response.headers.get("Location")) + + 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_onboard_azure_api_management_api( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> LROPoller[_models.ApiCollection]: + """Onboard an Azure API Management API to Microsoft Defender for APIs. + + Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start + monitoring the operations within the Azure Management API for intrusive behaviors and provide + alerts for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: An instance of LROPoller that returns either ApiCollection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.ApiCollection] + :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", "2023-11-15")) + cls: ClsType[_models.ApiCollection] = 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._onboard_azure_api_management_api_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApiCollection", 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.ApiCollection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiCollection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def offboard_azure_api_management_api( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> None: + """Offboard an Azure API Management API from Microsoft Defender for APIs. + + Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop + monitoring the operations within the Azure API Management API for intrusive behaviors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: 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", "2023-11-15")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_offboard_azure_api_management_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_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, 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/security/azure-mgmt-security/azure/mgmt/security/operations/_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_application_operations.py new file mode 100644 index 000000000000..031a0167d5ef --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_application_operations.py @@ -0,0 +1,351 @@ +# 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 + +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 SecurityCenterConfiguration +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(application_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", "2022-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applications/{applicationId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "applicationId": _SERIALIZER.url("application_id", application_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_create_or_update_request(application_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", "2022-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applications/{applicationId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "applicationId": _SERIALIZER.url("application_id", application_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 + 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(application_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", "2022-07-01-preview")) + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applications/{applicationId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "applicationId": _SERIALIZER.url("application_id", application_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="DELETE", url=_url, params=_params, **kwargs) + + +class ApplicationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`application` 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: SecurityCenterConfiguration = 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, application_id: str, **kwargs: Any) -> _models.Application: + """Get a specific application for the requested scope by applicationId. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :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", "2022-07-01-preview")) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + + _request = build_get_request( + application_id=application_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + application_id: str, + application: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Creates or update a security application on the given subscription. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Required. + :type application: ~azure.mgmt.security.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, application_id: str, application: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Application: + """Creates or update a security application on the given subscription. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Required. + :type application: 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: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, application_id: str, application: Union[_models.Application, IO[bytes]], **kwargs: Any + ) -> _models.Application: + """Creates or update a security application on the given subscription. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Is either a Application type or a + IO[bytes] type. Required. + :type application: ~azure.mgmt.security.models.Application or IO[bytes] + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :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", "2022-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application, (IOBase, bytes)): + _content = application + else: + _json = self._serialize.body(application, "Application") + + _request = build_create_or_update_request( + application_id=application_id, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, application_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete an Application over a given scope. + + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: 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", "2022-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + application_id=application_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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_applications_operations.py new file mode 100644 index 000000000000..22d32c33e039 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_applications_operations.py @@ -0,0 +1,144 @@ +# 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.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 SecurityCenterConfiguration +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(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", "2022-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) + + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`applications` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.Application"]: + """Get a list of all relevant applications over a subscription level scope. + + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + cls: ClsType[_models.ApplicationsList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_assessments_metadata_operations.py new file mode 100644 index 000000000000..cfddc6a9eae2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_assessments_metadata_operations.py @@ -0,0 +1,630 @@ +# 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 + +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 SecurityCenterConfiguration +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(**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-05-04-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/assessmentMetadata") + + # 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_request(assessment_metadata_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-04-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}") + path_format_arguments = { + "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_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_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-04-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_in_subscription_request( + assessment_metadata_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-05-04-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", + ) + path_format_arguments = { + "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_create_in_subscription_request( + assessment_metadata_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-05-04-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", + ) + path_format_arguments = { + "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + } + + _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_in_subscription_request( + assessment_metadata_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-05-04-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", + ) + path_format_arguments = { + "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class AssessmentsMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`assessments_metadata` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.SecurityAssessmentMetadataResponse"]: + """Get metadata information on all assessment types. + + :return: An iterator like instance of either SecurityAssessmentMetadataResponse or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityAssessmentMetadataResponse] + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = 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( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityAssessmentMetadataResponseList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityAssessmentMetadataResponse: + """Get metadata information on an assessment type. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + assessment_metadata_name=assessment_metadata_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.SecurityAssessmentMetadataResponse"]: + """Get metadata information on all assessment types in a specific subscription. + + :return: An iterator like instance of either SecurityAssessmentMetadataResponse or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityAssessmentMetadataResponse] + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityAssessmentMetadataResponseList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_in_subscription( + self, assessment_metadata_name: str, **kwargs: Any + ) -> _models.SecurityAssessmentMetadataResponse: + """Get metadata information on an assessment type in a specific subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) + + _request = build_get_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_in_subscription( + self, + assessment_metadata_name: str, + assessment_metadata: _models.SecurityAssessmentMetadataResponse, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityAssessmentMetadataResponse: + """Create metadata information on an assessment type in a specific subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :param assessment_metadata: AssessmentMetadata object. Required. + :type assessment_metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_in_subscription( + self, + assessment_metadata_name: str, + assessment_metadata: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityAssessmentMetadataResponse: + """Create metadata information on an assessment type in a specific subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :param assessment_metadata: AssessmentMetadata object. Required. + :type assessment_metadata: 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: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_in_subscription( + self, + assessment_metadata_name: str, + assessment_metadata: Union[_models.SecurityAssessmentMetadataResponse, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityAssessmentMetadataResponse: + """Create metadata information on an assessment type in a specific subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_name: str + :param assessment_metadata: AssessmentMetadata object. Is either a + SecurityAssessmentMetadataResponse type or a IO[bytes] type. Required. + :type assessment_metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse or + IO[bytes] + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadataResponse + :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", "2025-05-04-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment_metadata, (IOBase, bytes)): + _content = assessment_metadata + else: + _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadataResponse") + + _request = build_create_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_in_subscription( # pylint: disable=inconsistent-return-statements + self, assessment_metadata_name: str, **kwargs: Any + ) -> None: + """Delete metadata information on an assessment type in a specific subscription, will cause the + deletion of all the assessments of that type in that subscription. + + :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. + Required. + :type assessment_metadata_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", "2025-05-04-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_assessments_operations.py new file mode 100644 index 000000000000..a845f29eafd4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_assessments_operations.py @@ -0,0 +1,474 @@ +# 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 + +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 SecurityCenterConfiguration +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(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-04-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/assessments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_id: str, assessment_name: str, *, expand: Optional[Union[str, _models.ExpandEnum]] = 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-05-04-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}") + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(resource_id: str, assessment_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-04-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}") + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "assessmentName": _SERIALIZER.url("assessment_name", assessment_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_delete_request(resource_id: str, assessment_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-04-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}") + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class AssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`assessments` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> ItemPaged["_models.SecurityAssessmentResponse"]: + """Get security assessments on all your scanned resources inside a scope. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either SecurityAssessmentResponse or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityAssessmentResponse] + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityAssessmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_id: str, + assessment_name: str, + expand: Optional[Union[str, _models.ExpandEnum]] = None, + **kwargs: Any + ) -> _models.SecurityAssessmentResponse: + """Get a security assessment on your scanned resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param expand: OData expand. Optional. Known values are: "links" and "metadata". Default value + is None. + :type expand: str or ~azure.mgmt.security.models.ExpandEnum + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentResponse + :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", "2025-05-04-preview")) + cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + assessment_name=assessment_name, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_id: str, + assessment_name: str, + assessment: _models.SecurityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityAssessmentResponse: + """Create a security assessment on your resource. An assessment metadata that describes this + assessment must be predefined with the same name before inserting the assessment result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. + :type assessment: ~azure.mgmt.security.models.SecurityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_id: str, + assessment_name: str, + assessment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityAssessmentResponse: + """Create a security assessment on your resource. An assessment metadata that describes this + assessment must be predefined with the same name before inserting the assessment result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. + :type assessment: 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: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_id: str, + assessment_name: str, + assessment: Union[_models.SecurityAssessment, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityAssessmentResponse: + """Create a security assessment on your resource. An assessment metadata that describes this + assessment must be predefined with the same name before inserting the assessment result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param assessment: Calculated assessment on a pre-defined assessment metadata. Is either a + SecurityAssessment type or a IO[bytes] type. Required. + :type assessment: ~azure.mgmt.security.models.SecurityAssessment or IO[bytes] + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityAssessmentResponse + :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", "2025-05-04-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment, (IOBase, bytes)): + _content = assessment + else: + _json = self._serialize.body(assessment, "SecurityAssessment") + + _request = build_create_or_update_request( + resource_id=resource_id, + assessment_name=assessment_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityAssessmentResponse", 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_id: str, assessment_name: str, **kwargs: Any + ) -> None: + """Delete a security assessment on your resource. An assessment metadata that describes this + assessment must be predefined with the same name before inserting the assessment result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_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", "2025-05-04-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_id=resource_id, + assessment_name=assessment_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_auto_provisioning_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_auto_provisioning_settings_operations.py new file mode 100644 index 000000000000..53b1c2ac01df --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_auto_provisioning_settings_operations.py @@ -0,0 +1,371 @@ +# 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 + +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 SecurityCenterConfiguration +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(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", "2017-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(setting_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", "2017-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request(setting_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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "settingName": _SERIALIZER.url("setting_name", setting_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) + + +class AutoProvisioningSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`auto_provisioning_settings` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.AutoProvisioningSetting"]: + """Exposes the auto provisioning settings of the subscriptions. + + :return: An iterator like instance of either AutoProvisioningSetting or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AutoProvisioningSetting] + :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", "2017-08-01-preview")) + cls: ClsType[_models.AutoProvisioningSettingList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AutoProvisioningSettingList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, setting_name: str, **kwargs: Any) -> _models.AutoProvisioningSetting: + """Details of a specific setting. + + :param setting_name: Auto provisioning setting key. Required. + :type setting_name: str + :return: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting + :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", "2017-08-01-preview")) + cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoProvisioningSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + setting_name: str, + setting: _models.AutoProvisioningSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoProvisioningSetting: + """Details of a specific setting. + + :param setting_name: Auto provisioning setting key. Required. + :type setting_name: str + :param setting: Auto provisioning setting key. Required. + :type setting: ~azure.mgmt.security.models.AutoProvisioningSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, setting_name: str, setting: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AutoProvisioningSetting: + """Details of a specific setting. + + :param setting_name: Auto provisioning setting key. Required. + :type setting_name: str + :param setting: Auto provisioning setting key. Required. + :type setting: 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: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, setting_name: str, setting: Union[_models.AutoProvisioningSetting, IO[bytes]], **kwargs: Any + ) -> _models.AutoProvisioningSetting: + """Details of a specific setting. + + :param setting_name: Auto provisioning setting key. Required. + :type setting_name: str + :param setting: Auto provisioning setting key. Is either a AutoProvisioningSetting type or a + IO[bytes] type. Required. + :type setting: ~azure.mgmt.security.models.AutoProvisioningSetting or IO[bytes] + :return: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting + :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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IOBase, bytes)): + _content = setting + else: + _json = self._serialize.body(setting, "AutoProvisioningSetting") + + _request = build_create_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoProvisioningSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_automations_operations.py new file mode 100644 index 000000000000..626293d25c79 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_automations_operations.py @@ -0,0 +1,935 @@ +# 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 + +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 SecurityCenterConfiguration +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(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/automations") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _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_request( + resource_group_name: str, automation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, automation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + 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.Security/automations/{automationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, automation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + 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.Security/automations/{automationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, automation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, automation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + 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.Security/automations/{automationName}/validate", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class AutomationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`automations` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.Automation"]: + """Lists all the security automations in the specified subscription. Use the 'nextLink' property + in the response to get the next page of security automations for the specified subscription. + + :return: An iterator like instance of either Automation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Automation] + :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", "2023-12-01-preview")) + cls: ClsType[_models.AutomationList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AutomationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Automation"]: + """Lists all the security automations in the specified resource group. Use the 'nextLink' property + in the response to get the next page of security automations for the specified resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either Automation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Automation] + :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", "2023-12-01-preview")) + cls: ClsType[_models.AutomationList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AutomationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, automation_name: str, **kwargs: Any) -> _models.Automation: + """Retrieves information about the model of a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :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", "2023-12-01-preview")) + cls: ClsType[_models.Automation] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + automation_name=automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Automation", 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, + automation_name: str, + automation: _models.Automation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Automation: + """Creates or updates a security automation. If a security automation is already created and a + subsequent request is issued for the same automation id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Required. + :type automation: ~azure.mgmt.security.models.Automation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + automation_name: str, + automation: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Automation: + """Creates or updates a security automation. If a security automation is already created and a + subsequent request is issued for the same automation id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Required. + :type automation: 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: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + automation_name: str, + automation: Union[_models.Automation, IO[bytes]], + **kwargs: Any + ) -> _models.Automation: + """Creates or updates a security automation. If a security automation is already created and a + subsequent request is issued for the same automation id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Is either a Automation type or a IO[bytes] + type. Required. + :type automation: ~azure.mgmt.security.models.Automation or IO[bytes] + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :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", "2023-12-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Automation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IOBase, bytes)): + _content = automation + else: + _json = self._serialize.body(automation, "Automation") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_name=automation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Automation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + automation_name: str, + automation: _models.AutomationUpdateModel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Automation: + """Updates a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The update model of security automation resource. Required. + :type automation: ~azure.mgmt.security.models.AutomationUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + automation_name: str, + automation: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Automation: + """Updates a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The update model of security automation resource. Required. + :type automation: 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: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + automation_name: str, + automation: Union[_models.AutomationUpdateModel, IO[bytes]], + **kwargs: Any + ) -> _models.Automation: + """Updates a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The update model of security automation resource. Is either a + AutomationUpdateModel type or a IO[bytes] type. Required. + :type automation: ~azure.mgmt.security.models.AutomationUpdateModel or IO[bytes] + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Automation + :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", "2023-12-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Automation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IOBase, bytes)): + _content = automation + else: + _json = self._serialize.body(automation, "AutomationUpdateModel") + + _request = build_update_request( + resource_group_name=resource_group_name, + automation_name=automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Automation", 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, automation_name: str, **kwargs: Any + ) -> None: + """Deletes a security automation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_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", "2023-12-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + automation_name=automation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def validate( + self, + resource_group_name: str, + automation_name: str, + automation: _models.Automation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutomationValidationStatus: + """Validates the security automation model before create or update. Any validation errors are + returned to the client. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Required. + :type automation: ~azure.mgmt.security.models.Automation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AutomationValidationStatus or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutomationValidationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + automation_name: str, + automation: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutomationValidationStatus: + """Validates the security automation model before create or update. Any validation errors are + returned to the client. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Required. + :type automation: 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: AutomationValidationStatus or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutomationValidationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, + resource_group_name: str, + automation_name: str, + automation: Union[_models.Automation, IO[bytes]], + **kwargs: Any + ) -> _models.AutomationValidationStatus: + """Validates the security automation model before create or update. Any validation errors are + returned to the client. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param automation_name: The security automation name. Required. + :type automation_name: str + :param automation: The security automation resource. Is either a Automation type or a IO[bytes] + type. Required. + :type automation: ~azure.mgmt.security.models.Automation or IO[bytes] + :return: AutomationValidationStatus or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AutomationValidationStatus + :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", "2023-12-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutomationValidationStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IOBase, bytes)): + _content = automation + else: + _json = self._serialize.body(automation, "Automation") + + _request = build_validate_request( + resource_group_name=resource_group_name, + automation_name=automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutomationValidationStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_azure_dev_ops_orgs_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_azure_dev_ops_orgs_operations.py new file mode 100644 index 000000000000..d08ba6e55336 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_azure_dev_ops_orgs_operations.py @@ -0,0 +1,871 @@ +# 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, Iterator, Optional, TypeVar, Union, cast, overload + +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 SecurityCenterConfiguration +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_available_request( + resource_group_name: str, security_connector_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableAzureDevOpsOrgs", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, security_connector_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( + resource_group_name: str, security_connector_name: str, org_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, security_connector_name: str, org_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-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, security_connector_name: str, org_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-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_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) + + +class AzureDevOpsOrgsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`azure_dev_ops_orgs` 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: SecurityCenterConfiguration = 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_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.AzureDevOpsOrgListResponse: + """Returns a list of all Azure DevOps organizations accessible by the user token consumed by the + connector. + + Returns a list of all Azure DevOps organizations accessible by the user token consumed by the + connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: AzureDevOpsOrgListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AzureDevOpsOrgListResponse + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) + + _request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> ItemPaged["_models.AzureDevOpsOrg"]: + """Returns a list of Azure DevOps organizations onboarded to the connector. + + Returns a list of Azure DevOps organizations onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either AzureDevOpsOrg or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AzureDevOpsOrg] + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsOrgListResponse] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsOrgListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, org_name: str, **kwargs: Any + ) -> _models.AzureDevOpsOrg: + """Returns a monitored Azure DevOps organization resource. + + Returns a monitored Azure DevOps organization resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :return: AzureDevOpsOrg or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AzureDevOpsOrg + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsOrg", 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, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, 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", "2025-03-01")) + 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(azure_dev_ops_org, (IOBase, bytes)): + _content = azure_dev_ops_org + else: + _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: _models.AzureDevOpsOrg, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.models.AzureDevOpsOrg + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a + AzureDevOpsOrg type or a IO[bytes] type. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.models.AzureDevOpsOrg or IO[bytes] + :return: An instance of LROPoller that returns either AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + azure_dev_ops_org=azure_dev_ops_org, + 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("AzureDevOpsOrg", 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.AzureDevOpsOrg].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AzureDevOpsOrg]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, 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", "2025-03-01")) + 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(azure_dev_ops_org, (IOBase, bytes)): + _content = azure_dev_ops_org + else: + _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: _models.AzureDevOpsOrg, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.models.AzureDevOpsOrg + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a + AzureDevOpsOrg type or a IO[bytes] type. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.models.AzureDevOpsOrg or IO[bytes] + :return: An instance of LROPoller that returns either AzureDevOpsOrg or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsOrg] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + azure_dev_ops_org=azure_dev_ops_org, + 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("AzureDevOpsOrg", 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.AzureDevOpsOrg].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AzureDevOpsOrg]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_azure_dev_ops_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_azure_dev_ops_projects_operations.py new file mode 100644 index 000000000000..bf0c278e5f85 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_azure_dev_ops_projects_operations.py @@ -0,0 +1,823 @@ +# 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, Iterator, Optional, TypeVar, Union, cast, overload + +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 SecurityCenterConfiguration +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, security_connector_name: str, org_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_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_get_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_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-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_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-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_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) + + +class AzureDevOpsProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`azure_dev_ops_projects` 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: SecurityCenterConfiguration = 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, security_connector_name: str, org_name: str, **kwargs: Any + ) -> ItemPaged["_models.AzureDevOpsProject"]: + """Returns a list of Azure DevOps projects onboarded to the connector. + + Returns a list of Azure DevOps projects onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :return: An iterator like instance of either AzureDevOpsProject or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AzureDevOpsProject] + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsProjectListResponse] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsProjectListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any + ) -> _models.AzureDevOpsProject: + """Returns a monitored Azure DevOps project resource. + + Returns a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :return: AzureDevOpsProject or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AzureDevOpsProject + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsProject", 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, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, 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", "2025-03-01")) + 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(azure_dev_ops_project, (IOBase, bytes)): + _content = azure_dev_ops_project + else: + _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: _models.AzureDevOpsProject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.models.AzureDevOpsProject + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a + AzureDevOpsProject type or a IO[bytes] type. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.models.AzureDevOpsProject or IO[bytes] + :return: An instance of LROPoller that returns either AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + azure_dev_ops_project=azure_dev_ops_project, + 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("AzureDevOpsProject", 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.AzureDevOpsProject].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AzureDevOpsProject]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, 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", "2025-03-01")) + 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(azure_dev_ops_project, (IOBase, bytes)): + _content = azure_dev_ops_project + else: + _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: _models.AzureDevOpsProject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.models.AzureDevOpsProject + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a + AzureDevOpsProject type or a IO[bytes] type. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.models.AzureDevOpsProject or IO[bytes] + :return: An instance of LROPoller that returns either AzureDevOpsProject or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsProject] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + azure_dev_ops_project=azure_dev_ops_project, + 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("AzureDevOpsProject", 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.AzureDevOpsProject].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AzureDevOpsProject]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_azure_dev_ops_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_azure_dev_ops_repos_operations.py new file mode 100644 index 000000000000..a055464bf7c5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_azure_dev_ops_repos_operations.py @@ -0,0 +1,872 @@ +# 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, Iterator, Optional, TypeVar, Union, cast, overload + +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 SecurityCenterConfiguration +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, + security_connector_name: str, + org_name: str, + project_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_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_get_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_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-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_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-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "repoName": _SERIALIZER.url("repo_name", repo_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) + + +class AzureDevOpsReposOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`azure_dev_ops_repos` 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: SecurityCenterConfiguration = 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, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any + ) -> ItemPaged["_models.AzureDevOpsRepository"]: + """Returns a list of Azure DevOps repositories onboarded to the connector. + + Returns a list of Azure DevOps repositories onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :return: An iterator like instance of either AzureDevOpsRepository or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AzureDevOpsRepository] + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsRepositoryListResponse] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsRepositoryListResponse", 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.ErrorResponseAutoGenerated2, 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, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + **kwargs: Any + ) -> _models.AzureDevOpsRepository: + """Returns a monitored Azure DevOps repository resource. + + Returns a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :return: AzureDevOpsRepository or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AzureDevOpsRepository + :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", "2025-03-01")) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsRepository", 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, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, 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", "2025-03-01")) + 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(azure_dev_ops_repository, (IOBase, bytes)): + _content = azure_dev_ops_repository + else: + _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: _models.AzureDevOpsRepository, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: ~azure.mgmt.security.models.AzureDevOpsRepository + :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 AzureDevOpsRepository or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a + AzureDevOpsRepository type or a IO[bytes] type. Required. + :type azure_dev_ops_repository: ~azure.mgmt.security.models.AzureDevOpsRepository or IO[bytes] + :return: An instance of LROPoller that returns either AzureDevOpsRepository or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + azure_dev_ops_repository=azure_dev_ops_repository, + 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("AzureDevOpsRepository", 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.AzureDevOpsRepository].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AzureDevOpsRepository]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, 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", "2025-03-01")) + 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(azure_dev_ops_repository, (IOBase, bytes)): + _content = azure_dev_ops_repository + else: + _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: _models.AzureDevOpsRepository, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: ~azure.mgmt.security.models.AzureDevOpsRepository + :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 AzureDevOpsRepository or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a + AzureDevOpsRepository type or a IO[bytes] type. Required. + :type azure_dev_ops_repository: ~azure.mgmt.security.models.AzureDevOpsRepository or IO[bytes] + :return: An instance of LROPoller that returns either AzureDevOpsRepository or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.AzureDevOpsRepository] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = 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, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + azure_dev_ops_repository=azure_dev_ops_repository, + 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("AzureDevOpsRepository", 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.AzureDevOpsRepository].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AzureDevOpsRepository]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_compliance_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_compliance_results_operations.py new file mode 100644 index 000000000000..2129ac55de8b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_compliance_results_operations.py @@ -0,0 +1,226 @@ +# 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.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 SecurityCenterConfiguration +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(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/complianceResults") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_id: str, compliance_result_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/complianceResults/{complianceResultName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "complianceResultName": _SERIALIZER.url("compliance_result_name", compliance_result_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) + + +class ComplianceResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`compliance_results` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> ItemPaged["_models.ComplianceResult"]: + """Security compliance results in the subscription. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either ComplianceResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ComplianceResult] + :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", "2017-08-01")) + cls: ClsType[_models.ComplianceResultList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ComplianceResultList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_id: str, compliance_result_name: str, **kwargs: Any) -> _models.ComplianceResult: + """Security Compliance Result. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param compliance_result_name: name of the desired assessment compliance result. Required. + :type compliance_result_name: str + :return: ComplianceResult or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ComplianceResult + :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", "2017-08-01")) + cls: ClsType[_models.ComplianceResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + compliance_result_name=compliance_result_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComplianceResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_compliances_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_compliances_operations.py new file mode 100644 index 000000000000..02ed28ccc000 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_compliances_operations.py @@ -0,0 +1,226 @@ +# 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.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 SecurityCenterConfiguration +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(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/compliances") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(scope: str, compliance_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/compliances/{complianceName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "complianceName": _SERIALIZER.url("compliance_name", compliance_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) + + +class CompliancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`compliances` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> ItemPaged["_models.Compliance"]: + """The Compliance scores of the specific management group. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either Compliance or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Compliance] + :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", "2017-08-01-preview")) + cls: ClsType[_models.ComplianceList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ComplianceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, scope: str, compliance_name: str, **kwargs: Any) -> _models.Compliance: + """Details of a specific Compliance. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param compliance_name: name of the Compliance. Required. + :type compliance_name: str + :return: Compliance or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Compliance + :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", "2017-08-01-preview")) + cls: ClsType[_models.Compliance] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + compliance_name=compliance_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Compliance", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_connectors_operations.py new file mode 100644 index 000000000000..6588c04461ff --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_connectors_operations.py @@ -0,0 +1,453 @@ +# 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 + +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 SecurityCenterConfiguration +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(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", "2020-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(connector_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", "2020-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(connector_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", "2020-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "connectorName": _SERIALIZER.url("connector_name", connector_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_delete_request(connector_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", "2020-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConnectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`connectors` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.ConnectorSetting"]: + """Cloud accounts connectors of a subscription. + + :return: An iterator like instance of either ConnectorSetting or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ConnectorSetting] + :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", "2020-01-01-preview")) + cls: ClsType[_models.ConnectorSettingList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectorSettingList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, connector_name: str, **kwargs: Any) -> _models.ConnectorSetting: + """Details of a specific cloud account connector. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_name: str + :return: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ConnectorSetting + :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", "2020-01-01-preview")) + cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + connector_name=connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectorSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + connector_name: str, + connector_setting: _models.ConnectorSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectorSetting: + """Create a cloud account connector or update an existing one. Connect to your cloud account. For + AWS, use either account credentials or role-based authentication. For GCP, use account + organization credentials. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_name: str + :param connector_setting: Settings for the cloud account connector. Required. + :type connector_setting: ~azure.mgmt.security.models.ConnectorSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ConnectorSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + connector_name: str, + connector_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectorSetting: + """Create a cloud account connector or update an existing one. Connect to your cloud account. For + AWS, use either account credentials or role-based authentication. For GCP, use account + organization credentials. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_name: str + :param connector_setting: Settings for the cloud account connector. Required. + :type connector_setting: 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: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ConnectorSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, connector_name: str, connector_setting: Union[_models.ConnectorSetting, IO[bytes]], **kwargs: Any + ) -> _models.ConnectorSetting: + """Create a cloud account connector or update an existing one. Connect to your cloud account. For + AWS, use either account credentials or role-based authentication. For GCP, use account + organization credentials. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_name: str + :param connector_setting: Settings for the cloud account connector. Is either a + ConnectorSetting type or a IO[bytes] type. Required. + :type connector_setting: ~azure.mgmt.security.models.ConnectorSetting or IO[bytes] + :return: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ConnectorSetting + :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", "2020-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connector_setting, (IOBase, bytes)): + _content = connector_setting + else: + _json = self._serialize.body(connector_setting, "ConnectorSetting") + + _request = build_create_or_update_request( + connector_name=connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectorSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, connector_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete a cloud account connector from a subscription. + + :param connector_name: Name of the cloud account connector. Required. + :type connector_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", "2020-01-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + connector_name=connector_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_custom_assessment_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_custom_assessment_automations_operations.py new file mode 100644 index 000000000000..b83af4fb1caa --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_custom_assessment_automations_operations.py @@ -0,0 +1,625 @@ +# 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 + +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 SecurityCenterConfiguration +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( + resource_group_name: str, custom_assessment_automation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations/{customAssessmentAutomationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "customAssessmentAutomationName": _SERIALIZER.url( + "custom_assessment_automation_name", custom_assessment_automation_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, custom_assessment_automation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations/{customAssessmentAutomationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "customAssessmentAutomationName": _SERIALIZER.url( + "custom_assessment_automation_name", custom_assessment_automation_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_delete_request( + resource_group_name: str, custom_assessment_automation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations/{customAssessmentAutomationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "customAssessmentAutomationName": _SERIALIZER.url( + "custom_assessment_automation_name", custom_assessment_automation_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/customAssessmentAutomations" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) + + +class CustomAssessmentAutomationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`custom_assessment_automations` 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: SecurityCenterConfiguration = 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, custom_assessment_automation_name: str, **kwargs: Any + ) -> _models.CustomAssessmentAutomation: + """Gets a custom assessment automation. + + Gets a single custom assessment automation by name for the provided subscription and resource + group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_name: str + :return: CustomAssessmentAutomation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomAssessmentAutomation + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + custom_assessment_automation_name=custom_assessment_automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomAssessmentAutomation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + custom_assessment_automation_name: str, + custom_assessment_automation_body: _models.CustomAssessmentAutomationRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomAssessmentAutomation: + """Creates a custom assessment automation. + + Creates or updates a custom assessment automation for the provided subscription. Please note + that providing an existing custom assessment automation will replace the existing record. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_name: str + :param custom_assessment_automation_body: Custom Assessment Automation body. Required. + :type custom_assessment_automation_body: + ~azure.mgmt.security.models.CustomAssessmentAutomationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CustomAssessmentAutomation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomAssessmentAutomation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + custom_assessment_automation_name: str, + custom_assessment_automation_body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomAssessmentAutomation: + """Creates a custom assessment automation. + + Creates or updates a custom assessment automation for the provided subscription. Please note + that providing an existing custom assessment automation will replace the existing record. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_name: str + :param custom_assessment_automation_body: Custom Assessment Automation body. Required. + :type custom_assessment_automation_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: CustomAssessmentAutomation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomAssessmentAutomation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + custom_assessment_automation_name: str, + custom_assessment_automation_body: Union[_models.CustomAssessmentAutomationRequest, IO[bytes]], + **kwargs: Any + ) -> _models.CustomAssessmentAutomation: + """Creates a custom assessment automation. + + Creates or updates a custom assessment automation for the provided subscription. Please note + that providing an existing custom assessment automation will replace the existing record. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_name: str + :param custom_assessment_automation_body: Custom Assessment Automation body. Is either a + CustomAssessmentAutomationRequest type or a IO[bytes] type. Required. + :type custom_assessment_automation_body: + ~azure.mgmt.security.models.CustomAssessmentAutomationRequest or IO[bytes] + :return: CustomAssessmentAutomation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomAssessmentAutomation + :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", "2021-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(custom_assessment_automation_body, (IOBase, bytes)): + _content = custom_assessment_automation_body + else: + _json = self._serialize.body(custom_assessment_automation_body, "CustomAssessmentAutomationRequest") + + _request = build_create_request( + resource_group_name=resource_group_name, + custom_assessment_automation_name=custom_assessment_automation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomAssessmentAutomation", 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, custom_assessment_automation_name: str, **kwargs: Any + ) -> None: + """Deletes a custom assessment automation. + + Deletes a custom assessment automation by name for a provided subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. + :type custom_assessment_automation_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", "2021-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + custom_assessment_automation_name=custom_assessment_automation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.CustomAssessmentAutomation"]: + """List custom assessment automations in a subscription and a resource group. + + List custom assessment automations by provided subscription and resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either CustomAssessmentAutomation or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.CustomAssessmentAutomation] + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomAssessmentAutomationsListResult] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CustomAssessmentAutomationsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.CustomAssessmentAutomation"]: + """List custom assessment automations in a subscription. + + List custom assessment automations by provided subscription. + + :return: An iterator like instance of either CustomAssessmentAutomation or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.CustomAssessmentAutomation] + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomAssessmentAutomationsListResult] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CustomAssessmentAutomationsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_custom_entity_store_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_custom_entity_store_assignments_operations.py new file mode 100644 index 000000000000..058eb6062db6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_custom_entity_store_assignments_operations.py @@ -0,0 +1,631 @@ +# 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 + +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 SecurityCenterConfiguration +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( + resource_group_name: str, custom_entity_store_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments/{customEntityStoreAssignmentName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "customEntityStoreAssignmentName": _SERIALIZER.url( + "custom_entity_store_assignment_name", custom_entity_store_assignment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, custom_entity_store_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments/{customEntityStoreAssignmentName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "customEntityStoreAssignmentName": _SERIALIZER.url( + "custom_entity_store_assignment_name", custom_entity_store_assignment_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_delete_request( + resource_group_name: str, custom_entity_store_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments/{customEntityStoreAssignmentName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "customEntityStoreAssignmentName": _SERIALIZER.url( + "custom_entity_store_assignment_name", custom_entity_store_assignment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/customEntityStoreAssignments" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) + + +class CustomEntityStoreAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`custom_entity_store_assignments` 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: SecurityCenterConfiguration = 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, custom_entity_store_assignment_name: str, **kwargs: Any + ) -> _models.CustomEntityStoreAssignment: + """Gets a custom entity store assignment. + + Gets a single custom entity store assignment by name for the provided subscription and resource + group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_name: str + :return: CustomEntityStoreAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomEntityStoreAssignment + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + custom_entity_store_assignment_name=custom_entity_store_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomEntityStoreAssignment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + custom_entity_store_assignment_name: str, + custom_entity_store_assignment_request_body: _models.CustomEntityStoreAssignmentRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomEntityStoreAssignment: + """Creates a custom entity store assignment. + + Creates a custom entity store assignment for the provided subscription, if not already exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_name: str + :param custom_entity_store_assignment_request_body: Custom entity store assignment body. + Required. + :type custom_entity_store_assignment_request_body: + ~azure.mgmt.security.models.CustomEntityStoreAssignmentRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CustomEntityStoreAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomEntityStoreAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + custom_entity_store_assignment_name: str, + custom_entity_store_assignment_request_body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomEntityStoreAssignment: + """Creates a custom entity store assignment. + + Creates a custom entity store assignment for the provided subscription, if not already exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_name: str + :param custom_entity_store_assignment_request_body: Custom entity store assignment body. + Required. + :type custom_entity_store_assignment_request_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: CustomEntityStoreAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomEntityStoreAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + custom_entity_store_assignment_name: str, + custom_entity_store_assignment_request_body: Union[_models.CustomEntityStoreAssignmentRequest, IO[bytes]], + **kwargs: Any + ) -> _models.CustomEntityStoreAssignment: + """Creates a custom entity store assignment. + + Creates a custom entity store assignment for the provided subscription, if not already exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_name: str + :param custom_entity_store_assignment_request_body: Custom entity store assignment body. Is + either a CustomEntityStoreAssignmentRequest type or a IO[bytes] type. Required. + :type custom_entity_store_assignment_request_body: + ~azure.mgmt.security.models.CustomEntityStoreAssignmentRequest or IO[bytes] + :return: CustomEntityStoreAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomEntityStoreAssignment + :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", "2021-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(custom_entity_store_assignment_request_body, (IOBase, bytes)): + _content = custom_entity_store_assignment_request_body + else: + _json = self._serialize.body( + custom_entity_store_assignment_request_body, "CustomEntityStoreAssignmentRequest" + ) + + _request = build_create_request( + resource_group_name=resource_group_name, + custom_entity_store_assignment_name=custom_entity_store_assignment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CustomEntityStoreAssignment", 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, custom_entity_store_assignment_name: str, **kwargs: Any + ) -> None: + """Deleted a custom entity store assignment. + + Delete a custom entity store assignment by name for a provided subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param custom_entity_store_assignment_name: Name of the custom entity store assignment. + Generated name is GUID. Required. + :type custom_entity_store_assignment_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", "2021-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + custom_entity_store_assignment_name=custom_entity_store_assignment_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.CustomEntityStoreAssignment"]: + """List custom entity store assignments in a subscription and a resource group. + + List custom entity store assignments by a provided subscription and resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either CustomEntityStoreAssignment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.CustomEntityStoreAssignment] + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CustomEntityStoreAssignmentsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.CustomEntityStoreAssignment"]: + """List custom entity store assignments in a subscription. + + List custom entity store assignments by provided subscription. + + :return: An iterator like instance of either CustomEntityStoreAssignment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.CustomEntityStoreAssignment] + :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", "2021-07-01-preview")) + cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CustomEntityStoreAssignmentsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_custom_recommendations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_custom_recommendations_operations.py new file mode 100644 index 000000000000..55d3dce04ea7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_custom_recommendations_operations.py @@ -0,0 +1,504 @@ +# 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 + +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 SecurityCenterConfiguration +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(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/customRecommendations") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "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_get_request(scope: str, custom_recommendation_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}" + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "customRecommendationName": _SERIALIZER.url( + "custom_recommendation_name", + custom_recommendation_name, + "str", + pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{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_create_or_update_request(scope: str, custom_recommendation_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}" + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "customRecommendationName": _SERIALIZER.url( + "custom_recommendation_name", + custom_recommendation_name, + "str", + pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$", + ), + } + + _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(scope: str, custom_recommendation_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}" + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "customRecommendationName": _SERIALIZER.url( + "custom_recommendation_name", + custom_recommendation_name, + "str", + pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class CustomRecommendationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`custom_recommendations` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> ItemPaged["_models.CustomRecommendation"]: + """Get a list of all relevant custom recommendations over a scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :return: An iterator like instance of either CustomRecommendation or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.CustomRecommendation] + :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", "2024-08-01")) + cls: ClsType[_models.CustomRecommendationsList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CustomRecommendationsList", 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, scope: str, custom_recommendation_name: str, **kwargs: Any) -> _models.CustomRecommendation: + """Get a specific custom recommendation for the requested scope by customRecommendationName. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_name: str + :return: CustomRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomRecommendation + :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", "2024-08-01")) + cls: ClsType[_models.CustomRecommendation] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + custom_recommendation_name=custom_recommendation_name, + 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("CustomRecommendation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + scope: str, + custom_recommendation_name: str, + custom_recommendation_body: _models.CustomRecommendation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomRecommendation: + """Creates or updates a custom recommendation over a given scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_name: str + :param custom_recommendation_body: Custom Recommendation body. Required. + :type custom_recommendation_body: ~azure.mgmt.security.models.CustomRecommendation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CustomRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomRecommendation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + scope: str, + custom_recommendation_name: str, + custom_recommendation_body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CustomRecommendation: + """Creates or updates a custom recommendation over a given scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_name: str + :param custom_recommendation_body: Custom Recommendation body. Required. + :type custom_recommendation_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: CustomRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomRecommendation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + scope: str, + custom_recommendation_name: str, + custom_recommendation_body: Union[_models.CustomRecommendation, IO[bytes]], + **kwargs: Any + ) -> _models.CustomRecommendation: + """Creates or updates a custom recommendation over a given scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_name: str + :param custom_recommendation_body: Custom Recommendation body. Is either a CustomRecommendation + type or a IO[bytes] type. Required. + :type custom_recommendation_body: ~azure.mgmt.security.models.CustomRecommendation or IO[bytes] + :return: CustomRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.CustomRecommendation + :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", "2024-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomRecommendation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(custom_recommendation_body, (IOBase, bytes)): + _content = custom_recommendation_body + else: + _json = self._serialize.body(custom_recommendation_body, "CustomRecommendation") + + _request = build_create_or_update_request( + scope=scope, + custom_recommendation_name=custom_recommendation_name, + 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("CustomRecommendation", 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, scope: str, custom_recommendation_name: str, **kwargs: Any + ) -> None: + """Delete a custom recommendation over a given scope. + + :param scope: The scope of the custom recommendation. Valid scopes are: management group + (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription + (format: 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param custom_recommendation_name: Name of the Custom Recommendation. Required. + :type custom_recommendation_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", "2024-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope=scope, + custom_recommendation_name=custom_recommendation_name, + 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/security/azure-mgmt-security/azure/mgmt/security/operations/_defender_for_storage_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_defender_for_storage_operations.py new file mode 100644 index 000000000000..0d329765497d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_defender_for_storage_operations.py @@ -0,0 +1,568 @@ +# 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 + +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 SecurityCenterConfiguration +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(resource_id: str, setting_name: Union[str, _models.SettingName], **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-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request(resource_id: str, setting_name: Union[str, _models.SettingName], **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-02-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "settingName": _SERIALIZER.url("setting_name", setting_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_start_malware_scan_request( + resource_id: str, setting_name: Union[str, _models.SettingName], **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-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}/startMalwareScan", + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cancel_malware_scan_request( + resource_id: str, setting_name: Union[str, _models.SettingName], scan_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-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}/malwareScans/{scanId}/cancelMalwareScan", + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), + "scanId": _SERIALIZER.url( + "scan_id", + scan_id, + "str", + pattern=r"^(latest|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-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_get_malware_scan_request( + resource_id: str, setting_name: Union[str, _models.SettingName], scan_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-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}/malwareScans/{scanId}", + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), + "scanId": _SERIALIZER.url( + "scan_id", + scan_id, + "str", + pattern=r"^(latest|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-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) + + +class DefenderForStorageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`defender_for_storage` 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: SecurityCenterConfiguration = 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_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Gets the Defender for Storage settings for the specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DefenderForStorageSetting + :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", "2025-02-01-preview")) + cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + setting_name=setting_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: _models.DefenderForStorageSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Required. + :type defender_for_storage_setting: ~azure.mgmt.security.models.DefenderForStorageSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Required. + :type defender_for_storage_setting: 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: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: Union[_models.DefenderForStorageSetting, IO[bytes]], + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Is either a + DefenderForStorageSetting type or a IO[bytes] type. Required. + :type defender_for_storage_setting: ~azure.mgmt.security.models.DefenderForStorageSetting or + IO[bytes] + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DefenderForStorageSetting + :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", "2025-02-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(defender_for_storage_setting, (IOBase, bytes)): + _content = defender_for_storage_setting + else: + _json = self._serialize.body(defender_for_storage_setting, "DefenderForStorageSetting") + + _request = build_create_request( + resource_id=resource_id, + setting_name=setting_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def start_malware_scan( + self, resource_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any + ) -> _models.MalwareScan: + """Initiate a Defender for Storage malware scan for the specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :return: MalwareScan or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MalwareScan + :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", "2025-02-01-preview")) + cls: ClsType[_models.MalwareScan] = kwargs.pop("cls", None) + + _request = build_start_malware_scan_request( + resource_id=resource_id, + setting_name=setting_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MalwareScan", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def cancel_malware_scan( + self, resource_id: str, setting_name: Union[str, _models.SettingName], scan_id: str, **kwargs: Any + ) -> _models.MalwareScan: + """Cancels a Defender for Storage malware scan for the specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param scan_id: The identifier of the scan. Can be either 'latest' or a GUID. Required. + :type scan_id: str + :return: MalwareScan or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MalwareScan + :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", "2025-02-01-preview")) + cls: ClsType[_models.MalwareScan] = kwargs.pop("cls", None) + + _request = build_cancel_malware_scan_request( + resource_id=resource_id, + setting_name=setting_name, + scan_id=scan_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MalwareScan", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_malware_scan( + self, resource_id: str, setting_name: Union[str, _models.SettingName], scan_id: str, **kwargs: Any + ) -> _models.MalwareScan: + """Gets the Defender for Storage malware scan for the specified storage resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingName + :param scan_id: The identifier of the scan. Can be either 'latest' or a GUID. Required. + :type scan_id: str + :return: MalwareScan or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MalwareScan + :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", "2025-02-01-preview")) + cls: ClsType[_models.MalwareScan] = kwargs.pop("cls", None) + + _request = build_get_malware_scan_request( + resource_id=resource_id, + setting_name=setting_name, + scan_id=scan_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MalwareScan", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_dev_ops_configurations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_dev_ops_configurations_operations.py new file mode 100644 index 000000000000..0ec7e49f9348 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_dev_ops_configurations_operations.py @@ -0,0 +1,881 @@ +# 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, Iterator, Optional, TypeVar, Union, cast, overload + +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 SecurityCenterConfiguration +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, security_connector_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( + resource_group_name: str, security_connector_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, security_connector_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-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, security_connector_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-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, security_connector_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class DevOpsConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`dev_ops_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") + self._config: SecurityCenterConfiguration = 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, security_connector_name: str, **kwargs: Any + ) -> ItemPaged["_models.DevOpsConfiguration"]: + """List DevOps Configurations. + + List DevOps Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either DevOpsConfiguration or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.DevOpsConfiguration] + :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", "2025-03-01")) + cls: ClsType[_models.DevOpsConfigurationListResponse] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DevOpsConfigurationListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, **kwargs: Any) -> _models.DevOpsConfiguration: + """Gets a DevOps Configuration. + + Gets a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: DevOpsConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DevOpsConfiguration + :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", "2025-03-01")) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DevOpsConfiguration", 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, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, 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", "2025-03-01")) + 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(dev_ops_configuration, (IOBase, bytes)): + _content = dev_ops_configuration + else: + _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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, 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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: _models.DevOpsConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: ~azure.mgmt.security.models.DevOpsConfiguration + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: 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 DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Is either a + DevOpsConfiguration type or a IO[bytes] type. Required. + :type dev_ops_configuration: ~azure.mgmt.security.models.DevOpsConfiguration or IO[bytes] + :return: An instance of LROPoller that returns either DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = 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, + security_connector_name=security_connector_name, + dev_ops_configuration=dev_ops_configuration, + 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("DevOpsConfiguration", 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.DevOpsConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DevOpsConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, 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", "2025-03-01")) + 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(dev_ops_configuration, (IOBase, bytes)): + _content = dev_ops_configuration + else: + _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: _models.DevOpsConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: ~azure.mgmt.security.models.DevOpsConfiguration + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: 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 DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Is either a + DevOpsConfiguration type or a IO[bytes] type. Required. + :type dev_ops_configuration: ~azure.mgmt.security.models.DevOpsConfiguration or IO[bytes] + :return: An instance of LROPoller that returns either DevOpsConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.DevOpsConfiguration] + :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", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = 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, + security_connector_name=security_connector_name, + dev_ops_configuration=dev_ops_configuration, + 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("DevOpsConfiguration", 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.DevOpsConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DevOpsConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, security_connector_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", "2025-03-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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 [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a DevOps Connector. + + Deletes a DevOps Connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_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", "2025-03-01")) + 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, + security_connector_name=security_connector_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_dev_ops_operation_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_dev_ops_operation_results_operations.py new file mode 100644 index 000000000000..de51a6ad324a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_dev_ops_operation_results_operations.py @@ -0,0 +1,158 @@ +# 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 SecurityCenterConfiguration +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( + resource_group_name: str, + security_connector_name: str, + operation_result_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/operationResults/{operationResultId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "operationResultId": _SERIALIZER.url("operation_result_id", operation_result_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) + + +class DevOpsOperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`dev_ops_operation_results` 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: SecurityCenterConfiguration = 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, security_connector_name: str, operation_result_id: str, **kwargs: Any + ) -> _models.OperationStatusResult: + """Get devops long running operation result. + + Get devops long running operation result. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param operation_result_id: The operation result Id. Required. + :type operation_result_id: str + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.security.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", "2025-03-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + operation_result_id=operation_result_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.ErrorResponseAutoGenerated2, 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/security/azure-mgmt-security/azure/mgmt/security/operations/_device_security_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_device_security_groups_operations.py new file mode 100644 index 000000000000..2d4f10e65d92 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_device_security_groups_operations.py @@ -0,0 +1,467 @@ +# 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 + +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 SecurityCenterConfiguration +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_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", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups") + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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_id: str, device_security_group_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "deviceSecurityGroupName": _SERIALIZER.url("device_security_group_name", device_security_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(resource_id: str, device_security_group_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-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", "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "deviceSecurityGroupName": _SERIALIZER.url("device_security_group_name", device_security_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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_id: str, device_security_group_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "deviceSecurityGroupName": _SERIALIZER.url("device_security_group_name", device_security_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeviceSecurityGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`device_security_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SecurityCenterConfiguration = 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_id: str, **kwargs: Any) -> ItemPaged["_models.DeviceSecurityGroup"]: + """Use this method get the list of device security groups for the specified IoT Hub resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: An iterator like instance of either DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.DeviceSecurityGroup] + :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", "2019-08-01")) + cls: ClsType[_models.DeviceSecurityGroupList] = 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_id=resource_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeviceSecurityGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_id: str, device_security_group_name: str, **kwargs: Any) -> _models.DeviceSecurityGroup: + """Use this method to get the device security group for the specified IoT Hub resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_name: str + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup + :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", "2019-08-01")) + cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeviceSecurityGroup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_id: str, + device_security_group_name: str, + device_security_group: _models.DeviceSecurityGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeviceSecurityGroup: + """Use this method to creates or updates the device security group on a specified IoT Hub + resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_name: str + :param device_security_group: Security group object. Required. + :type device_security_group: ~azure.mgmt.security.models.DeviceSecurityGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_id: str, + device_security_group_name: str, + device_security_group: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeviceSecurityGroup: + """Use this method to creates or updates the device security group on a specified IoT Hub + resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_name: str + :param device_security_group: Security group object. Required. + :type device_security_group: 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: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_id: str, + device_security_group_name: str, + device_security_group: Union[_models.DeviceSecurityGroup, IO[bytes]], + **kwargs: Any + ) -> _models.DeviceSecurityGroup: + """Use this method to creates or updates the device security group on a specified IoT Hub + resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_name: str + :param device_security_group: Security group object. Is either a DeviceSecurityGroup type or a + IO[bytes] type. Required. + :type device_security_group: ~azure.mgmt.security.models.DeviceSecurityGroup or IO[bytes] + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup + :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", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(device_security_group, (IOBase, bytes)): + _content = device_security_group + else: + _json = self._serialize.body(device_security_group, "DeviceSecurityGroup") + + _request = build_create_or_update_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeviceSecurityGroup", 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_id: str, device_security_group_name: str, **kwargs: Any + ) -> None: + """User this method to deletes the device security group. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param device_security_group_name: The name of the device security group. Note that the name of + the device security group is case insensitive. Required. + :type device_security_group_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", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_discovered_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_discovered_security_solutions_operations.py new file mode 100644 index 000000000000..ffedd23b8e62 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_discovered_security_solutions_operations.py @@ -0,0 +1,349 @@ +# 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.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 SecurityCenterConfiguration +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(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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/discoveredSecuritySolutions" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( + resource_group_name: str, + asc_location: str, + discovered_security_solution_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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions/{discoveredSecuritySolutionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "discoveredSecuritySolutionName": _SERIALIZER.url( + "discovered_security_solution_name", discovered_security_solution_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) + + +class DiscoveredSecuritySolutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`discovered_security_solutions` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.DiscoveredSecuritySolution"]: + """Gets a list of discovered Security Solutions for the subscription. + + :return: An iterator like instance of either DiscoveredSecuritySolution or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.DiscoveredSecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.DiscoveredSecuritySolutionList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiscoveredSecuritySolutionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region(self, asc_location: str, **kwargs: Any) -> ItemPaged["_models.DiscoveredSecuritySolution"]: + """Gets a list of discovered Security Solutions for the subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either DiscoveredSecuritySolution or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.DiscoveredSecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.DiscoveredSecuritySolutionList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiscoveredSecuritySolutionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, asc_location: str, discovered_security_solution_name: str, **kwargs: Any + ) -> _models.DiscoveredSecuritySolution: + """Gets a specific discovered Security Solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param discovered_security_solution_name: Name of a discovered security solution. Required. + :type discovered_security_solution_name: str + :return: DiscoveredSecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.models.DiscoveredSecuritySolution + :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", "2020-01-01")) + cls: ClsType[_models.DiscoveredSecuritySolution] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + discovered_security_solution_name=discovered_security_solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiscoveredSecuritySolution", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_external_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_external_security_solutions_operations.py new file mode 100644 index 000000000000..13316d5b2e96 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_external_security_solutions_operations.py @@ -0,0 +1,349 @@ +# 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.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 SecurityCenterConfiguration +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(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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/externalSecuritySolutions" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( + resource_group_name: str, + asc_location: str, + external_security_solutions_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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions/{externalSecuritySolutionsName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "externalSecuritySolutionsName": _SERIALIZER.url( + "external_security_solutions_name", external_security_solutions_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) + + +class ExternalSecuritySolutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`external_security_solutions` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.ExternalSecuritySolution"]: + """Gets a list of external security solutions for the subscription. + + :return: An iterator like instance of either ExternalSecuritySolution or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ExternalSecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.ExternalSecuritySolutionList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ExternalSecuritySolutionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region(self, asc_location: str, **kwargs: Any) -> ItemPaged["_models.ExternalSecuritySolution"]: + """Gets a list of external Security Solutions for the subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either ExternalSecuritySolution or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ExternalSecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.ExternalSecuritySolutionList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ExternalSecuritySolutionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, asc_location: str, external_security_solutions_name: str, **kwargs: Any + ) -> _models.ExternalSecuritySolution: + """Gets a specific external Security Solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param external_security_solutions_name: Name of an external security solution. Required. + :type external_security_solutions_name: str + :return: ExternalSecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ExternalSecuritySolution + :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", "2020-01-01")) + cls: ClsType[_models.ExternalSecuritySolution] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + external_security_solutions_name=external_security_solutions_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ExternalSecuritySolution", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_hub_owners_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_hub_owners_operations.py new file mode 100644 index 000000000000..b2cd8e108b29 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_hub_owners_operations.py @@ -0,0 +1,360 @@ +# 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.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 SecurityCenterConfiguration +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_available_request( + resource_group_name: str, security_connector_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitHubOwners", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, security_connector_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( + resource_group_name: str, security_connector_name: str, owner_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "ownerName": _SERIALIZER.url("owner_name", owner_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) + + +class GitHubOwnersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`git_hub_owners` 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: SecurityCenterConfiguration = 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_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.GitHubOwnerListResponse: + """Returns a list of all GitHub owners accessible by the user token consumed by the connector. + + Returns a list of all GitHub owners accessible by the user token consumed by the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: GitHubOwnerListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitHubOwnerListResponse + :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", "2025-03-01")) + cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) + + _request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> ItemPaged["_models.GitHubOwner"]: + """Returns a list of GitHub owners onboarded to the connector. + + Returns a list of GitHub owners onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either GitHubOwner or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.GitHubOwner] + :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", "2025-03-01")) + cls: ClsType[_models.GitHubOwnerListResponse] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GitHubOwnerListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, owner_name: str, **kwargs: Any + ) -> _models.GitHubOwner: + """Returns a monitored GitHub owner. + + Returns a monitored GitHub owner. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :return: GitHubOwner or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitHubOwner + :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", "2025-03-01")) + cls: ClsType[_models.GitHubOwner] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubOwner", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_hub_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_hub_repos_operations.py new file mode 100644 index 000000000000..53602bf2552e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_hub_repos_operations.py @@ -0,0 +1,278 @@ +# 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.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 SecurityCenterConfiguration +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, security_connector_name: str, owner_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "ownerName": _SERIALIZER.url("owner_name", owner_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_get_request( + resource_group_name: str, + security_connector_name: str, + owner_name: str, + repo_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos/{repoName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "ownerName": _SERIALIZER.url("owner_name", owner_name, "str"), + "repoName": _SERIALIZER.url("repo_name", repo_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) + + +class GitHubReposOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`git_hub_repos` 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: SecurityCenterConfiguration = 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, security_connector_name: str, owner_name: str, **kwargs: Any + ) -> ItemPaged["_models.GitHubRepository"]: + """Returns a list of GitHub repositories onboarded to the connector. + + Returns a list of GitHub repositories onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :return: An iterator like instance of either GitHubRepository or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.GitHubRepository] + :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", "2025-03-01")) + cls: ClsType[_models.GitHubRepositoryListResponse] = 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, + security_connector_name=security_connector_name, + owner_name=owner_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GitHubRepositoryListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, owner_name: str, repo_name: str, **kwargs: Any + ) -> _models.GitHubRepository: + """Returns a monitored GitHub repository. + + Returns a monitored GitHub repository. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :return: GitHubRepository or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitHubRepository + :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", "2025-03-01")) + cls: ClsType[_models.GitHubRepository] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_name, + repo_name=repo_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubRepository", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_lab_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_lab_groups_operations.py new file mode 100644 index 000000000000..3900f45fd2f2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_lab_groups_operations.py @@ -0,0 +1,360 @@ +# 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.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 SecurityCenterConfiguration +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_available_request( + resource_group_name: str, security_connector_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitLabGroups", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, security_connector_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( + resource_group_name: str, security_connector_name: str, group_fq_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_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) + + +class GitLabGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`git_lab_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SecurityCenterConfiguration = 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_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.GitLabGroupListResponse: + """Returns a list of all GitLab groups accessible by the user token consumed by the connector. + + Returns a list of all GitLab groups accessible by the user token consumed by the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: GitLabGroupListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitLabGroupListResponse + :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", "2025-03-01")) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + _request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> ItemPaged["_models.GitLabGroup"]: + """Returns a list of GitLab groups onboarded to the connector. + + Returns a list of GitLab groups onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either GitLabGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.GitLabGroup] + :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", "2025-03-01")) + cls: ClsType[_models.GitLabGroupListResponse] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GitLabGroupListResponse", 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.ErrorResponseAutoGenerated2, 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, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> _models.GitLabGroup: + """Returns a monitored GitLab Group resource for a given fully-qualified name. + + Returns a monitored GitLab Group resource for a given fully-qualified name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :return: GitLabGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitLabGroup + :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", "2025-03-01")) + cls: ClsType[_models.GitLabGroup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_lab_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_lab_projects_operations.py new file mode 100644 index 000000000000..88e718089305 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_lab_projects_operations.py @@ -0,0 +1,287 @@ +# 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.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 SecurityCenterConfiguration +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, security_connector_name: str, group_fq_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_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_get_request( + resource_group_name: str, + security_connector_name: str, + group_fq_name: str, + project_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects/{projectName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_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) + + +class GitLabProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`git_lab_projects` 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: SecurityCenterConfiguration = 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, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> ItemPaged["_models.GitLabProject"]: + """Gets a list of GitLab projects that are directly owned by given group and onboarded to the + connector. + + Gets a list of GitLab projects that are directly owned by given group and onboarded to the + connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :return: An iterator like instance of either GitLabProject or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.GitLabProject] + :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", "2025-03-01")) + cls: ClsType[_models.GitLabProjectListResponse] = 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, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GitLabProjectListResponse", 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.ErrorResponseAutoGenerated2, 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, + security_connector_name: str, + group_fq_name: str, + project_name: str, + **kwargs: Any + ) -> _models.GitLabProject: + """Returns a monitored GitLab Project resource for a given fully-qualified group name and project + name. + + Returns a monitored GitLab Project resource for a given fully-qualified group name and project + name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :param project_name: The project name. Required. + :type project_name: str + :return: GitLabProject or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitLabProject + :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", "2025-03-01")) + cls: ClsType[_models.GitLabProject] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + project_name=project_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabProject", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_lab_subgroups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_lab_subgroups_operations.py new file mode 100644 index 000000000000..3f3c0a6ea86e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_git_lab_subgroups_operations.py @@ -0,0 +1,154 @@ +# 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 SecurityCenterConfiguration +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, security_connector_name: str, group_fq_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/listSubgroups", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class GitLabSubgroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`git_lab_subgroups` 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: SecurityCenterConfiguration = 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, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> _models.GitLabGroupListResponse: + """Gets nested subgroups of given GitLab Group which are onboarded to the connector. + + Gets nested subgroups of given GitLab Group which are onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :return: GitLabGroupListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GitLabGroupListResponse + :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", "2025-03-01")) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_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.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_governance_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_governance_assignments_operations.py new file mode 100644 index 000000000000..3aae237ea1a9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_governance_assignments_operations.py @@ -0,0 +1,506 @@ +# 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 + +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 SecurityCenterConfiguration +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(scope: str, assessment_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments" + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str", pattern=r"^[-\w\._\(\)]+$"), + } + + _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_request(scope: str, assessment_name: str, assignment_key: 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", "2022-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments/{assignmentKey}", + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str", pattern=r"^[-\w\._\(\)]+$"), + "assignmentKey": _SERIALIZER.url("assignment_key", assignment_key, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(scope: str, assessment_name: str, assignment_key: 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", "2022-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments/{assignmentKey}", + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str", pattern=r"^[-\w\._\(\)]+$"), + "assignmentKey": _SERIALIZER.url("assignment_key", assignment_key, "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_delete_request(scope: str, assessment_name: str, assignment_key: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments/{assignmentKey}", + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str", pattern=r"^[-\w\._\(\)]+$"), + "assignmentKey": _SERIALIZER.url("assignment_key", assignment_key, "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) + + +class GovernanceAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`governance_assignments` 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: SecurityCenterConfiguration = 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, scope: str, assessment_name: str, **kwargs: Any) -> ItemPaged["_models.GovernanceAssignment"]: + """Get governance assignments on all of your resources inside a scope. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :return: An iterator like instance of either GovernanceAssignment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.GovernanceAssignment] + :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", "2022-01-01-preview")) + cls: ClsType[_models.GovernanceAssignmentsList] = 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( + scope=scope, + assessment_name=assessment_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GovernanceAssignmentsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, scope: str, assessment_name: str, assignment_key: str, **kwargs: Any) -> _models.GovernanceAssignment: + """Get a specific governanceAssignment for the requested scope by AssignmentKey. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: str + :return: GovernanceAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceAssignment + :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", "2022-01-01-preview")) + cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + assessment_name=assessment_name, + assignment_key=assignment_key, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GovernanceAssignment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + scope: str, + assessment_name: str, + assignment_key: str, + governance_assignment: _models.GovernanceAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GovernanceAssignment: + """Creates or updates a governance assignment on the given subscription. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: str + :param governance_assignment: Governance assignment over a subscription scope. Required. + :type governance_assignment: ~azure.mgmt.security.models.GovernanceAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GovernanceAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + scope: str, + assessment_name: str, + assignment_key: str, + governance_assignment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GovernanceAssignment: + """Creates or updates a governance assignment on the given subscription. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: str + :param governance_assignment: Governance assignment over a subscription scope. Required. + :type governance_assignment: 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: GovernanceAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + scope: str, + assessment_name: str, + assignment_key: str, + governance_assignment: Union[_models.GovernanceAssignment, IO[bytes]], + **kwargs: Any + ) -> _models.GovernanceAssignment: + """Creates or updates a governance assignment on the given subscription. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: str + :param governance_assignment: Governance assignment over a subscription scope. Is either a + GovernanceAssignment type or a IO[bytes] type. Required. + :type governance_assignment: ~azure.mgmt.security.models.GovernanceAssignment or IO[bytes] + :return: GovernanceAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceAssignment + :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", "2022-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(governance_assignment, (IOBase, bytes)): + _content = governance_assignment + else: + _json = self._serialize.body(governance_assignment, "GovernanceAssignment") + + _request = build_create_or_update_request( + scope=scope, + assessment_name=assessment_name, + assignment_key=assignment_key, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GovernanceAssignment", 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, scope: str, assessment_name: str, assignment_key: str, **kwargs: Any + ) -> None: + """Delete a GovernanceAssignment over a given scope. + + :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. + :type assessment_name: str + :param assignment_key: The governance assignment key - the assessment key of the required + governance assignment. Required. + :type assignment_key: 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", "2022-01-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope=scope, + assessment_name=assessment_name, + assignment_key=assignment_key, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_governance_rules_operations.py new file mode 100644 index 000000000000..a0f88303071d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_governance_rules_operations.py @@ -0,0 +1,864 @@ +# 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, Iterator, Optional, TypeVar, Union, cast, overload + +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 SecurityCenterConfiguration +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(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "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_get_request(scope: str, rule_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", "2022-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_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_create_or_update_request(scope: str, rule_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", "2022-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_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 + 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(scope: str, rule_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_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="DELETE", url=_url, params=_params, **kwargs) + + +def build_execute_request(scope: str, rule_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", "2022-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}/execute") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_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 + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_operation_results_request(scope: str, rule_id: str, operation_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", "2022-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}/operationResults/{operationId}" + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "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) + + +class GovernanceRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`governance_rules` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> ItemPaged["_models.GovernanceRule"]: + """Get a list of all relevant governance rules over a scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :return: An iterator like instance of either GovernanceRule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.GovernanceRule] + :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", "2022-01-01-preview")) + cls: ClsType[_models.GovernanceRuleList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GovernanceRuleList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, scope: str, rule_id: str, **kwargs: Any) -> _models.GovernanceRule: + """Get a specific governance rule for the requested scope by ruleId. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :return: GovernanceRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceRule + :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", "2022-01-01-preview")) + cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + rule_id=rule_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GovernanceRule", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + scope: str, + rule_id: str, + governance_rule: _models.GovernanceRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GovernanceRule: + """Creates or updates a governance rule over a given scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param governance_rule: Governance rule over a given scope. Required. + :type governance_rule: ~azure.mgmt.security.models.GovernanceRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GovernanceRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + scope: str, + rule_id: str, + governance_rule: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GovernanceRule: + """Creates or updates a governance rule over a given scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param governance_rule: Governance rule over a given scope. Required. + :type governance_rule: 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: GovernanceRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, scope: str, rule_id: str, governance_rule: Union[_models.GovernanceRule, IO[bytes]], **kwargs: Any + ) -> _models.GovernanceRule: + """Creates or updates a governance rule over a given scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param governance_rule: Governance rule over a given scope. Is either a GovernanceRule type or + a IO[bytes] type. Required. + :type governance_rule: ~azure.mgmt.security.models.GovernanceRule or IO[bytes] + :return: GovernanceRule or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GovernanceRule + :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", "2022-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(governance_rule, (IOBase, bytes)): + _content = governance_rule + else: + _json = self._serialize.body(governance_rule, "GovernanceRule") + + _request = build_create_or_update_request( + scope=scope, + rule_id=rule_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GovernanceRule", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial(self, scope: str, rule_id: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope=scope, + rule_id=rule_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 [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, scope: str, rule_id: str, **kwargs: Any) -> LROPoller[None]: + """Delete a Governance rule over a given scope. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: 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", "2022-01-01-preview")) + 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( + scope=scope, + rule_id=rule_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, 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 _execute_initial( + self, + scope: str, + rule_id: str, + execute_governance_rule_params: Optional[Union[_models.ExecuteGovernanceRuleParams, 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + 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(execute_governance_rule_params, (IOBase, bytes)): + _content = execute_governance_rule_params + else: + if execute_governance_rule_params is not None: + _json = self._serialize.body(execute_governance_rule_params, "ExecuteGovernanceRuleParams") + else: + _json = None + + _request = build_execute_request( + scope=scope, + rule_id=rule_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 [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + 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_execute( + self, + scope: str, + rule_id: str, + execute_governance_rule_params: Optional[_models.ExecuteGovernanceRuleParams] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Execute a governance rule. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param execute_governance_rule_params: Execute governance rule over a given scope. Default + value is None. + :type execute_governance_rule_params: ~azure.mgmt.security.models.ExecuteGovernanceRuleParams + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_execute( + self, + scope: str, + rule_id: str, + execute_governance_rule_params: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Execute a governance rule. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param execute_governance_rule_params: Execute governance rule over a given scope. Default + value is None. + :type execute_governance_rule_params: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_execute( + self, + scope: str, + rule_id: str, + execute_governance_rule_params: Optional[Union[_models.ExecuteGovernanceRuleParams, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Execute a governance rule. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param execute_governance_rule_params: Execute governance rule over a given scope. Is either a + ExecuteGovernanceRuleParams type or a IO[bytes] type. Default value is None. + :type execute_governance_rule_params: ~azure.mgmt.security.models.ExecuteGovernanceRuleParams + or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._execute_initial( + scope=scope, + rule_id=rule_id, + execute_governance_rule_params=execute_governance_rule_params, + 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): # 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 operation_results( + self, scope: str, rule_id: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.OperationResultAutoGenerated]: + """Get governance rules long run operation result for the requested scope by ruleId and + operationId. + + :param scope: The scope of the Governance rules. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). + Required. + :type rule_id: str + :param operation_id: The governance rule long running operation unique key. Required. + :type operation_id: str + :return: OperationResultAutoGenerated or None or the result of cls(response) + :rtype: ~azure.mgmt.security.models.OperationResultAutoGenerated or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + cls: ClsType[Optional[_models.OperationResultAutoGenerated]] = kwargs.pop("cls", None) + + _request = build_operation_results_request( + scope=scope, + rule_id=rule_id, + operation_id=operation_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationResultAutoGenerated", pipeline_response.http_response) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_health_reports_operations.py new file mode 100644 index 000000000000..ada43865f2b7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_health_reports_operations.py @@ -0,0 +1,233 @@ +# 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.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 SecurityCenterConfiguration +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(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/healthReports") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_id: str, health_report_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/healthReports/{healthReportName}") + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "healthReportName": _SERIALIZER.url( + "health_report_name", + health_report_name, + "str", + pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{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) + + +class HealthReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`health_reports` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> ItemPaged["_models.HealthReport"]: + """Get a list of all health reports inside a scope. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + + :param scope: The scope at which the operation is performed. Required. + :type scope: str + :return: An iterator like instance of either HealthReport or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.HealthReport] + :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", "2023-05-01-preview")) + cls: ClsType[_models.HealthReportsList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("HealthReportsList", 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_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: + """Get health report of resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param health_report_name: The health report Key - Unique key for the health report type. + Required. + :type health_report_name: str + :return: HealthReport or the result of cls(response) + :rtype: ~azure.mgmt.security.models.HealthReport + :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", "2023-05-01-preview")) + cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + health_report_name=health_report_name, + 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("HealthReport", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_information_protection_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_information_protection_policies_operations.py new file mode 100644 index 000000000000..ad991e0f85e0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_information_protection_policies_operations.py @@ -0,0 +1,416 @@ +# 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 + +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 SecurityCenterConfiguration +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( + scope: str, information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], **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", "2017-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}", + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "informationProtectionPolicyName": _SERIALIZER.url( + "information_protection_policy_name", information_protection_policy_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + scope: str, information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], **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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}", + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "informationProtectionPolicyName": _SERIALIZER.url( + "information_protection_policy_name", information_protection_policy_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_list_request(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/informationProtectionPolicies") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class InformationProtectionPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`information_protection_policies` 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: SecurityCenterConfiguration = 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, + scope: str, + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], + **kwargs: Any + ) -> _models.InformationProtectionPolicy: + """Details of the information protection policy. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param information_protection_policy_name: Name of the information protection policy. Known + values are: "effective" and "custom". Required. + :type information_protection_policy_name: str or + ~azure.mgmt.security.models.InformationProtectionPolicyName + :return: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy + :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", "2017-08-01-preview")) + cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + information_protection_policy_name=information_protection_policy_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + scope: str, + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], + information_protection_policy: _models.InformationProtectionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.InformationProtectionPolicy: + """Details of the information protection policy. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param information_protection_policy_name: Name of the information protection policy. Known + values are: "effective" and "custom". Required. + :type information_protection_policy_name: str or + ~azure.mgmt.security.models.InformationProtectionPolicyName + :param information_protection_policy: Information protection policy. Required. + :type information_protection_policy: ~azure.mgmt.security.models.InformationProtectionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + scope: str, + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], + information_protection_policy: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.InformationProtectionPolicy: + """Details of the information protection policy. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param information_protection_policy_name: Name of the information protection policy. Known + values are: "effective" and "custom". Required. + :type information_protection_policy_name: str or + ~azure.mgmt.security.models.InformationProtectionPolicyName + :param information_protection_policy: Information protection policy. Required. + :type information_protection_policy: 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: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + scope: str, + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], + information_protection_policy: Union[_models.InformationProtectionPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.InformationProtectionPolicy: + """Details of the information protection policy. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param information_protection_policy_name: Name of the information protection policy. Known + values are: "effective" and "custom". Required. + :type information_protection_policy_name: str or + ~azure.mgmt.security.models.InformationProtectionPolicyName + :param information_protection_policy: Information protection policy. Is either a + InformationProtectionPolicy type or a IO[bytes] type. Required. + :type information_protection_policy: ~azure.mgmt.security.models.InformationProtectionPolicy or + IO[bytes] + :return: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy + :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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(information_protection_policy, (IOBase, bytes)): + _content = information_protection_policy + else: + _json = self._serialize.body(information_protection_policy, "InformationProtectionPolicy") + + _request = build_create_or_update_request( + scope=scope, + information_protection_policy_name=information_protection_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, scope: str, **kwargs: Any) -> ItemPaged["_models.InformationProtectionPolicy"]: + """Information protection policies of a specific management group. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either InformationProtectionPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.InformationProtectionPolicy] + :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", "2017-08-01-preview")) + cls: ClsType[_models.InformationProtectionPolicyList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("InformationProtectionPolicyList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solution_analytics_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solution_analytics_operations.py new file mode 100644 index 000000000000..d7dc20f03c15 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solution_analytics_operations.py @@ -0,0 +1,237 @@ +# 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 SecurityCenterConfiguration +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, solution_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", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_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_get_request(resource_group_name: str, solution_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", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_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) + + +class IotSecuritySolutionAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`iot_security_solution_analytics` 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: SecurityCenterConfiguration = 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, solution_name: str, **kwargs: Any + ) -> _models.IoTSecuritySolutionAnalyticsModelList: + """Use this method to get IoT security Analytics metrics in an array. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :return: IoTSecuritySolutionAnalyticsModelList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModelList + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionAnalyticsModelList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, solution_name: str, **kwargs: Any + ) -> _models.IoTSecuritySolutionAnalyticsModel: + """Use this method to get IoT Security Analytics metrics. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :return: IoTSecuritySolutionAnalyticsModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModel + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionAnalyticsModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionAnalyticsModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solution_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solution_operations.py new file mode 100644 index 000000000000..36aaca8537c2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solution_operations.py @@ -0,0 +1,787 @@ +# 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 + +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 SecurityCenterConfiguration +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_by_subscription_request( + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/iotSecuritySolutions" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, solution_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", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, solution_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", "2019-08-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.Security/iotSecuritySolutions/{solutionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, solution_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", "2019-08-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.Security/iotSecuritySolutions/{solutionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, solution_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", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotSecuritySolutionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`iot_security_solution` 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: SecurityCenterConfiguration = 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_by_subscription( + self, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.IoTSecuritySolutionModel"]: + """Use this method to get the list of IoT Security solutions by subscription. + + :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by + iotHubs. Default value is None. + :type filter: str + :return: An iterator like instance of either IoTSecuritySolutionModel or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.IoTSecuritySolutionModel] + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionsList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IoTSecuritySolutionsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.IoTSecuritySolutionModel"]: + """Use this method to get the list IoT Security solutions organized by resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by + iotHubs. Default value is None. + :type filter: str + :return: An iterator like instance of either IoTSecuritySolutionModel or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.IoTSecuritySolutionModel] + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionsList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IoTSecuritySolutionsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, solution_name: str, **kwargs: Any) -> _models.IoTSecuritySolutionModel: + """User this method to get details of a specific IoT Security solution based on solution name. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionModel", 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, + solution_name: str, + iot_security_solution_data: _models.IoTSecuritySolutionModel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to create or update yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param iot_security_solution_data: The security solution data. Required. + :type iot_security_solution_data: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + solution_name: str, + iot_security_solution_data: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to create or update yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param iot_security_solution_data: The security solution data. Required. + :type iot_security_solution_data: 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: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + solution_name: str, + iot_security_solution_data: Union[_models.IoTSecuritySolutionModel, IO[bytes]], + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to create or update yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param iot_security_solution_data: The security solution data. Is either a + IoTSecuritySolutionModel type or a IO[bytes] type. Required. + :type iot_security_solution_data: ~azure.mgmt.security.models.IoTSecuritySolutionModel or + IO[bytes] + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :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", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_security_solution_data, (IOBase, bytes)): + _content = iot_security_solution_data + else: + _json = self._serialize.body(iot_security_solution_data, "IoTSecuritySolutionModel") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + solution_name=solution_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + solution_name: str, + update_iot_security_solution_data: _models.UpdateIotSecuritySolutionData, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to update existing IoT Security solution tags or user defined resources. To + update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param update_iot_security_solution_data: The security solution data. Required. + :type update_iot_security_solution_data: + ~azure.mgmt.security.models.UpdateIotSecuritySolutionData + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + solution_name: str, + update_iot_security_solution_data: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to update existing IoT Security solution tags or user defined resources. To + update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param update_iot_security_solution_data: The security solution data. Required. + :type update_iot_security_solution_data: 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: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + solution_name: str, + update_iot_security_solution_data: Union[_models.UpdateIotSecuritySolutionData, IO[bytes]], + **kwargs: Any + ) -> _models.IoTSecuritySolutionModel: + """Use this method to update existing IoT Security solution tags or user defined resources. To + update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param update_iot_security_solution_data: The security solution data. Is either a + UpdateIotSecuritySolutionData type or a IO[bytes] type. Required. + :type update_iot_security_solution_data: + ~azure.mgmt.security.models.UpdateIotSecuritySolutionData or IO[bytes] + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel + :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", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_iot_security_solution_data, (IOBase, bytes)): + _content = update_iot_security_solution_data + else: + _json = self._serialize.body(update_iot_security_solution_data, "UpdateIotSecuritySolutionData") + + _request = build_update_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecuritySolutionModel", 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, solution_name: str, **kwargs: Any + ) -> None: + """Use this method to delete yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_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", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + solution_name=solution_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py new file mode 100644 index 000000000000..5127b86d5f89 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py @@ -0,0 +1,358 @@ +# 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.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 SecurityCenterConfiguration +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, solution_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, solution_name: str, aggregated_alert_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", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), + "aggregatedAlertName": _SERIALIZER.url("aggregated_alert_name", aggregated_alert_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_dismiss_request( + resource_group_name: str, solution_name: str, aggregated_alert_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", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}/dismiss", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), + "aggregatedAlertName": _SERIALIZER.url("aggregated_alert_name", aggregated_alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotSecuritySolutionsAnalyticsAggregatedAlertOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`iot_security_solutions_analytics_aggregated_alert` 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: SecurityCenterConfiguration = 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, solution_name: str, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.IoTSecurityAggregatedAlert"]: + """Use this method to get the aggregated alert list of yours IoT Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param top: Number of results to retrieve. Default value is None. + :type top: int + :return: An iterator like instance of either IoTSecurityAggregatedAlert or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.IoTSecurityAggregatedAlert] + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecurityAggregatedAlertList] = 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, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IoTSecurityAggregatedAlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, solution_name: str, aggregated_alert_name: str, **kwargs: Any + ) -> _models.IoTSecurityAggregatedAlert: + """Use this method to get a single the aggregated alert of yours IoT Security solution. This + aggregation is performed by alert name. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param aggregated_alert_name: Identifier of the aggregated alert. Required. + :type aggregated_alert_name: str + :return: IoTSecurityAggregatedAlert or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecurityAggregatedAlert + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecurityAggregatedAlert] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + aggregated_alert_name=aggregated_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecurityAggregatedAlert", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def dismiss( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, solution_name: str, aggregated_alert_name: str, **kwargs: Any + ) -> None: + """Use this method to dismiss an aggregated IoT Security Solution Alert. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param aggregated_alert_name: Identifier of the aggregated alert. Required. + :type aggregated_alert_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", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_dismiss_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + aggregated_alert_name=aggregated_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solutions_analytics_recommendation_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solutions_analytics_recommendation_operations.py new file mode 100644 index 000000000000..d73407370e76 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solutions_analytics_recommendation_operations.py @@ -0,0 +1,275 @@ +# 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.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 SecurityCenterConfiguration +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( + resource_group_name: str, + solution_name: str, + aggregated_recommendation_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", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations/{aggregatedRecommendationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), + "aggregatedRecommendationName": _SERIALIZER.url( + "aggregated_recommendation_name", aggregated_recommendation_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_list_request( + resource_group_name: str, solution_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotSecuritySolutionsAnalyticsRecommendationOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`iot_security_solutions_analytics_recommendation` 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: SecurityCenterConfiguration = 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, solution_name: str, aggregated_recommendation_name: str, **kwargs: Any + ) -> _models.IoTSecurityAggregatedRecommendation: + """Use this method to get the aggregated security analytics recommendation of yours IoT Security + solution. This aggregation is performed by recommendation name. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param aggregated_recommendation_name: Name of the recommendation aggregated for this query. + Required. + :type aggregated_recommendation_name: str + :return: IoTSecurityAggregatedRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.IoTSecurityAggregatedRecommendation + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecurityAggregatedRecommendation] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + aggregated_recommendation_name=aggregated_recommendation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IoTSecurityAggregatedRecommendation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, solution_name: str, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.IoTSecurityAggregatedRecommendation"]: + """Use this method to get the list of aggregated security analytics recommendations of yours IoT + Security solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param solution_name: The name of the IoT Security solution. Required. + :type solution_name: str + :param top: Number of results to retrieve. Default value is None. + :type top: int + :return: An iterator like instance of either IoTSecurityAggregatedRecommendation or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.IoTSecurityAggregatedRecommendation] + :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", "2019-08-01")) + cls: ClsType[_models.IoTSecurityAggregatedRecommendationList] = 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, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IoTSecurityAggregatedRecommendationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_jit_network_access_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_jit_network_access_policies_operations.py new file mode 100644 index 000000000000..ed5f4d04dca8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_jit_network_access_policies_operations.py @@ -0,0 +1,1057 @@ +# 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, Literal, Optional, TypeVar, Union, overload + +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 SecurityCenterConfiguration +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(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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/jitNetworkAccessPolicies" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_region_request(asc_location: 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/jitNetworkAccessPolicies", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_and_region_request( # pylint: disable=name-too-long + resource_group_name: str, asc_location: 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( + resource_group_name: str, + asc_location: str, + jit_network_access_policy_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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "jitNetworkAccessPolicyName": _SERIALIZER.url( + "jit_network_access_policy_name", jit_network_access_policy_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + asc_location: str, + jit_network_access_policy_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", "2020-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.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "jitNetworkAccessPolicyName": _SERIALIZER.url( + "jit_network_access_policy_name", jit_network_access_policy_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_delete_request( + resource_group_name: str, + asc_location: str, + jit_network_access_policy_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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "jitNetworkAccessPolicyName": _SERIALIZER.url( + "jit_network_access_policy_name", jit_network_access_policy_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_initiate_request( + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + jit_network_access_policy_initiate_type: Literal["initiate"] = kwargs.pop( + "jit_network_access_policy_initiate_type", "initiate" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-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.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}/{jitNetworkAccessPolicyInitiateType}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "jitNetworkAccessPolicyName": _SERIALIZER.url( + "jit_network_access_policy_name", jit_network_access_policy_name, "str" + ), + "jitNetworkAccessPolicyInitiateType": _SERIALIZER.url( + "jit_network_access_policy_initiate_type", jit_network_access_policy_initiate_type, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class JitNetworkAccessPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`jit_network_access_policies` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control. + + :return: An iterator like instance of either JitNetworkAccessPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.JitNetworkAccessPolicy] + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPoliciesList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("JitNetworkAccessPoliciesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_region(self, asc_location: str, **kwargs: Any) -> ItemPaged["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control for the subscription, + location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either JitNetworkAccessPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.JitNetworkAccessPolicy] + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPoliciesList] = 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_by_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("JitNetworkAccessPoliciesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control for the subscription, + location. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either JitNetworkAccessPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.JitNetworkAccessPolicy] + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPoliciesList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("JitNetworkAccessPoliciesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group_and_region( + self, resource_group_name: str, asc_location: str, **kwargs: Any + ) -> ItemPaged["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control for the subscription, + location. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either JitNetworkAccessPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.JitNetworkAccessPolicy] + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPoliciesList] = 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_by_resource_group_and_region_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("JitNetworkAccessPoliciesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any + ) -> _models.JitNetworkAccessPolicy: + """Policies for protecting resources using Just-in-Time access control for the subscription, + location. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :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", "2020-01-01")) + cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + jit_network_access_policy_name=jit_network_access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JitNetworkAccessPolicy", 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, + asc_location: str, + jit_network_access_policy_name: str, + body: _models.JitNetworkAccessPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitNetworkAccessPolicy: + """Create a policy for protecting resources using Just-in-Time access control. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Required. + :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitNetworkAccessPolicy: + """Create a policy for protecting resources using Just-in-Time access control. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: Union[_models.JitNetworkAccessPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.JitNetworkAccessPolicy: + """Create a policy for protecting resources using Just-in-Time access control. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Is either a JitNetworkAccessPolicy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicy or IO[bytes] + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy + :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", "2020-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "JitNetworkAccessPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + jit_network_access_policy_name=jit_network_access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JitNetworkAccessPolicy", 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, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any + ) -> None: + """Delete a Just-in-Time access control policy. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_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", "2020-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + jit_network_access_policy_name=jit_network_access_policy_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def initiate( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: _models.JitNetworkAccessPolicyInitiateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitNetworkAccessRequest: + """Initiate a JIT access from a specific Just-in-Time policy configuration. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Required. + :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JitNetworkAccessRequest or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessRequest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def initiate( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitNetworkAccessRequest: + """Initiate a JIT access from a specific Just-in-Time policy configuration. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JitNetworkAccessRequest or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessRequest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def initiate( + self, + resource_group_name: str, + asc_location: str, + jit_network_access_policy_name: str, + body: Union[_models.JitNetworkAccessPolicyInitiateRequest, IO[bytes]], + **kwargs: Any + ) -> _models.JitNetworkAccessRequest: + """Initiate a JIT access from a specific Just-in-Time policy configuration. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. + Required. + :type jit_network_access_policy_name: str + :param body: Is either a JitNetworkAccessPolicyInitiateRequest type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateRequest or IO[bytes] + :return: JitNetworkAccessRequest or the result of cls(response) + :rtype: ~azure.mgmt.security.models.JitNetworkAccessRequest + :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 {}) + + jit_network_access_policy_initiate_type: Literal["initiate"] = kwargs.pop( + "jit_network_access_policy_initiate_type", "initiate" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JitNetworkAccessRequest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "JitNetworkAccessPolicyInitiateRequest") + + _request = build_initiate_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + jit_network_access_policy_name=jit_network_access_policy_name, + subscription_id=self._config.subscription_id, + jit_network_access_policy_initiate_type=jit_network_access_policy_initiate_type, + 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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JitNetworkAccessRequest", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_locations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_locations_operations.py new file mode 100644 index 000000000000..9451451b1bed --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_locations_operations.py @@ -0,0 +1,227 @@ +# 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.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 SecurityCenterConfiguration +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(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", "2015-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(asc_location: 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", "2015-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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) + + +class LocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`locations` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.AscLocation"]: + """The location of the responsible ASC of the specific subscription (home region). For each + subscription there is only one responsible location. The location in the response should be + used to read or write other resources in ASC according to their ID. + + :return: An iterator like instance of either AscLocation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AscLocation] + :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", "2015-06-01-preview")) + cls: ClsType[_models.AscLocationList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AscLocationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, asc_location: str, **kwargs: Any) -> _models.AscLocation: + """Details of a specific location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: AscLocation or the result of cls(response) + :rtype: ~azure.mgmt.security.models.AscLocation + :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", "2015-06-01-preview")) + cls: ClsType[_models.AscLocation] = kwargs.pop("cls", None) + + _request = build_get_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AscLocation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_mde_onboardings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_mde_onboardings_operations.py new file mode 100644 index 000000000000..0fe618e2fcae --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_mde_onboardings_operations.py @@ -0,0 +1,204 @@ +# 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 SecurityCenterConfiguration +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(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/mdeOnboardings") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/mdeOnboardings/default" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) + + +class MdeOnboardingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`mde_onboardings` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> _models.MdeOnboardingDataList: + """The configuration or data needed to onboard the machine to MDE. + + :return: MdeOnboardingDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MdeOnboardingDataList + :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", "2021-10-01-preview")) + cls: ClsType[_models.MdeOnboardingDataList] = kwargs.pop("cls", None) + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MdeOnboardingDataList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, **kwargs: Any) -> _models.MdeOnboardingData: + """The default configuration or data needed to onboard the machine to MDE. + + :return: MdeOnboardingData or the result of cls(response) + :rtype: ~azure.mgmt.security.models.MdeOnboardingData + :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", "2021-10-01-preview")) + cls: ClsType[_models.MdeOnboardingData] = kwargs.pop("cls", None) + + _request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MdeOnboardingData", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_operations.py new file mode 100644 index 000000000000..f95bc2d80d33 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_operations.py @@ -0,0 +1,137 @@ +# 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.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 SecurityCenterConfiguration +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(**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-05-04-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """Exposes all available operations for discovery purposes. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-04-preview")) + cls: ClsType[_models.OperationListResult] = 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( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_patch.py @@ -0,0 +1,21 @@ +# 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 + + +def patch_sdk(): + """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/security/azure-mgmt-security/azure/mgmt/security/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_pricings_operations.py new file mode 100644 index 000000000000..a5d2896eb673 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_pricings_operations.py @@ -0,0 +1,470 @@ +# 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 + +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 SecurityCenterConfiguration +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(scope_id: str, pricing_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scopeId}/providers/Microsoft.Security/pricings/{pricingName}") + path_format_arguments = { + "scopeId": _SERIALIZER.url("scope_id", scope_id, "str", skip_quote=True), + "pricingName": _SERIALIZER.url("pricing_name", pricing_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_update_request(scope_id: str, pricing_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-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", "/{scopeId}/providers/Microsoft.Security/pricings/{pricingName}") + path_format_arguments = { + "scopeId": _SERIALIZER.url("scope_id", scope_id, "str", skip_quote=True), + "pricingName": _SERIALIZER.url("pricing_name", pricing_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_delete_request(scope_id: str, pricing_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scopeId}/providers/Microsoft.Security/pricings/{pricingName}") + path_format_arguments = { + "scopeId": _SERIALIZER.url("scope_id", scope_id, "str", skip_quote=True), + "pricingName": _SERIALIZER.url("pricing_name", pricing_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(scope_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scopeId}/providers/Microsoft.Security/pricings") + path_format_arguments = { + "scopeId": _SERIALIZER.url("scope_id", scope_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PricingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`pricings` 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: SecurityCenterConfiguration = 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, scope_id: str, pricing_name: str, **kwargs: Any) -> _models.Pricing: + """Get the Defender plans pricing configurations of the selected scope (valid scopes are resource + id or a subscription id). At the resource level, supported resource types are 'VirtualMachines, + VMSS and ARC Machines'. + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Pricing + :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", "2024-01-01")) + cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) + + _request = build_get_request( + scope_id=scope_id, + pricing_name=pricing_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Pricing", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + scope_id: str, + pricing_name: str, + pricing: _models.Pricing, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Pricing: + """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid + scopes are: subscription id or a specific resource id (Supported resources are: + 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param pricing: Pricing object. Required. + :type pricing: ~azure.mgmt.security.models.Pricing + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Pricing + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + scope_id: str, + pricing_name: str, + pricing: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Pricing: + """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid + scopes are: subscription id or a specific resource id (Supported resources are: + 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param pricing: Pricing object. Required. + :type pricing: 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: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Pricing + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, scope_id: str, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any + ) -> _models.Pricing: + """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid + scopes are: subscription id or a specific resource id (Supported resources are: + 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. + :type pricing: ~azure.mgmt.security.models.Pricing or IO[bytes] + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Pricing + :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", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pricing, (IOBase, bytes)): + _content = pricing + else: + _json = self._serialize.body(pricing, "Pricing") + + _request = build_update_request( + scope_id=scope_id, + pricing_name=pricing_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Pricing", 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, scope_id: str, pricing_name: str, **kwargs: Any + ) -> None: + """Deletes a provided Microsoft Defender for Cloud pricing configuration in a specific resource. + Valid only for resource scope (Supported resources are: 'VirtualMachines, VMSS and ARC + MachinesS'). + + :param scope_id: The identifier of the resource, (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}). + Required. + :type scope_id: str + :param pricing_name: name of the pricing configuration. Required. + :type pricing_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", "2024-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope_id=scope_id, + pricing_name=pricing_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, scope_id: str, filter: Optional[str] = None, **kwargs: Any) -> _models.PricingList: + """Lists Microsoft Defender for Cloud pricing configurations of the scopeId, that match the + optional given $filter. Valid scopes are: subscription id or a specific resource id (Supported + resources are: 'VirtualMachines, VMSS and ARC Machines'). Valid $filter is: 'name in + ({planName1},{planName2},...)'. If $filter is not provided, the unfiltered list will be + returned. If '$filter=name in (planName1,planName2)' is provided, the returned list includes + the pricings set for 'planName1' and 'planName2' only. + + :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or a specific resource (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) + - Supported resources are (VirtualMachines). Required. + :type scope_id: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: PricingList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PricingList + :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", "2024-01-01")) + cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) + + _request = build_list_request( + scope_id=scope_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PricingList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_private_endpoint_connections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..8f7b3006fe07 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,752 @@ +# 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, Iterator, Optional, TypeVar, Union, cast, overload + +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 SecurityCenterConfiguration +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, private_link_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-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}/privateEndpointConnections", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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_get_request( + resource_group_name: str, + private_link_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", "2025-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + "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_create_or_update_request( + resource_group_name: str, + private_link_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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + "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 + 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, + private_link_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", "2025-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + "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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`private_endpoint_connections` 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: SecurityCenterConfiguration = 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, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> ItemPaged["_models.PrivateEndpointConnection"]: + """Gets all private endpoint connections for a private link. Returns the list of private endpoints + that are connected or in the process of connecting to this private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.PrivateEndpointConnection] + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = 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: + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_list_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", 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.ErrorResponseAutoGenerated, 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, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the private link. Returns the + connection details, status, and configuration for a specific private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.security.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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-09-01-preview")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_get_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + private_endpoint_connection_name=private_endpoint_connection_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", 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, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, 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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + private_endpoint_connection_name=private_endpoint_connection_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the private link. + This operation is typically used to approve or reject pending private endpoint connections. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_endpoint_connection: The private endpoint connection resource. Required. + :type private_endpoint_connection: ~azure.mgmt.security.models.PrivateEndpointConnection + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_endpoint_connection: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the private link. + This operation is typically used to approve or reject pending private endpoint connections. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_endpoint_connection: The private endpoint connection resource. Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the private link. + This operation is typically used to approve or reject pending private endpoint connections. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_endpoint_connection: The private endpoint connection resource. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type private_endpoint_connection: ~azure.mgmt.security.models.PrivateEndpointConnection or + IO[bytes] + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.PrivateEndpointConnection] + :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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = 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_endpoint_connection_name=private_endpoint_connection_name, + private_link_parameters=private_link_parameters, + private_endpoint_connection=private_endpoint_connection, + 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("PrivateEndpointConnection", 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.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + **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", "2025-09-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_delete_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + private_endpoint_connection_name=private_endpoint_connection_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + 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, + private_endpoint_connection_name: str, + private_link_parameters: _models.PrivateLinkParameters, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified private endpoint connection associated with the private link. This + operation will disconnect the private endpoint and remove the connection configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :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", "2025-09-01-preview")) + 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_endpoint_connection_name=private_endpoint_connection_name, + private_link_parameters=private_link_parameters, + 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": "azure-async-operation"}, **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/security/azure-mgmt-security/azure/mgmt/security/operations/_private_link_resources_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..6521f97e383b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_private_link_resources_operations.py @@ -0,0 +1,288 @@ +# 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.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 SecurityCenterConfiguration +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, private_link_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-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}/privateLinkResources", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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_get_request( + resource_group_name: str, private_link_name: str, group_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-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}/privateLinkResources/{groupId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + "groupId": _SERIALIZER.url("group_id", group_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) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SecurityCenterConfiguration = 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, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> ItemPaged["_models.PrivateLinkResourceAutoGenerated"]: + """List all private link resources in a private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: An iterator like instance of either PrivateLinkResourceAutoGenerated or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.PrivateLinkResourceAutoGenerated] + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinkResourceListResult] = 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: + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_list_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", 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.ErrorResponseAutoGenerated, 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, + group_id: str, + private_link_parameters: _models.PrivateLinkParameters, + **kwargs: Any + ) -> _models.PrivateLinkResourceAutoGenerated: + """Get the specified private link resource associated with the private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param group_id: The group ID of the private link resource. Required. + :type group_id: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: PrivateLinkResourceAutoGenerated or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResourceAutoGenerated + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinkResourceAutoGenerated] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_get_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + group_id=group_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResourceAutoGenerated", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_private_links_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_private_links_operations.py new file mode 100644 index 000000000000..a00d88019a76 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_private_links_operations.py @@ -0,0 +1,1064 @@ +# 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 + +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 SecurityCenterConfiguration +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_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/privateLinks") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, private_link_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-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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_head_request( + resource_group_name: str, private_link_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-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, private_link_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-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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_update_request( + resource_group_name: str, private_link_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-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, private_link_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-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/privateLinks/{privateLinkName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateLinkName": _SERIALIZER.url( + "private_link_name", + private_link_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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 PrivateLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`private_links` 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: SecurityCenterConfiguration = 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_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.PrivateLinkResource"]: + """Lists all the private links in the specified subscription. private links enable secure, private + connectivity to Microsoft Defender for Cloud services without exposing traffic to the public + internet. Use the 'nextLink' property in the response to get the next page of private links for + the specified subscription. + + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.PrivateLinkResource] + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinksList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinksList", 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.ErrorResponseAutoGenerated, 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, **kwargs: Any) -> ItemPaged["_models.PrivateLinkResource"]: + """Lists all the private links in the specified resource group. private links enable secure, + private connectivity to Microsoft Defender for Cloud services without exposing traffic to the + public internet. Use the 'nextLink' property in the response to get the next page of private + links for the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.PrivateLinkResource] + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinksList] = 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinksList", 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.ErrorResponseAutoGenerated, 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, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Get a private link resource. Returns the configuration and status of private endpoint + connectivity for Microsoft Defender for Cloud services in the specified region. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResource + :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", "2025-09-01-preview")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_get_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def head( + self, resource_group_name: str, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> bool: + """Checks whether private link exists. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-09-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_head_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + def _create_initial( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: Union[_models.PrivateLinkResource, 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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link, (IOBase, bytes)): + _content = private_link + else: + _json = self._serialize.body(private_link, "PrivateLinkResource") + + _request = build_create_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: _models.PrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateLinkResource]: + """Create a private link resource. This operation creates the necessary infrastructure to enable + private endpoint connections to Microsoft Defender for Cloud services. For updates to existing + resources, use the PATCH operation. The operation is asynchronous and may take several minutes + to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: Private link request payload containing the resource information for + create operations. Required. + :type private_link: ~azure.mgmt.security.models.PrivateLinkResource + :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 PrivateLinkResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateLinkResource]: + """Create a private link resource. This operation creates the necessary infrastructure to enable + private endpoint connections to Microsoft Defender for Cloud services. For updates to existing + resources, use the PATCH operation. The operation is asynchronous and may take several minutes + to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: Private link request payload containing the resource information for + create operations. Required. + :type private_link: 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 PrivateLinkResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: Union[_models.PrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateLinkResource]: + """Create a private link resource. This operation creates the necessary infrastructure to enable + private endpoint connections to Microsoft Defender for Cloud services. For updates to existing + resources, use the PATCH operation. The operation is asynchronous and may take several minutes + to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: Private link request payload containing the resource information for + create operations. Is either a PrivateLinkResource type or a IO[bytes] type. Required. + :type private_link: ~azure.mgmt.security.models.PrivateLinkResource or IO[bytes] + :return: An instance of LROPoller that returns either PrivateLinkResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.models.PrivateLinkResource] + :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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateLinkResource] = 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_initial( + resource_group_name=resource_group_name, + private_link_parameters=private_link_parameters, + private_link=private_link, + 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("PrivateLinkResource", 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.PrivateLinkResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def update( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: _models.PrivateLinkUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkResource: + """Update specific properties of a private link resource. Use this operation to update mutable + properties like tags without affecting the entire resource configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: private link update payload containing only the properties to be updated. + Required. + :type private_link: ~azure.mgmt.security.models.PrivateLinkUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkResource: + """Update specific properties of a private link resource. Use this operation to update mutable + properties like tags without affecting the entire resource configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: private link update payload containing only the properties to be updated. + Required. + :type private_link: 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: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + private_link_parameters: _models.PrivateLinkParameters, + private_link: Union[_models.PrivateLinkUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateLinkResource: + """Update specific properties of a private link resource. Use this operation to update mutable + properties like tags without affecting the entire resource configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :param private_link: private link update payload containing only the properties to be updated. + Is either a PrivateLinkUpdate type or a IO[bytes] type. Required. + :type private_link: ~azure.mgmt.security.models.PrivateLinkUpdate or IO[bytes] + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.PrivateLinkResource + :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", "2025-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link, (IOBase, bytes)): + _content = private_link + else: + _json = self._serialize.body(private_link, "PrivateLinkUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, private_link_parameters: _models.PrivateLinkParameters, **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", "2025-09-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _private_link_name = None + if private_link_parameters is not None: + _private_link_name = private_link_parameters.private_link_name + + _request = build_delete_request( + resource_group_name=resource_group_name, + private_link_name=_private_link_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + 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, private_link_parameters: _models.PrivateLinkParameters, **kwargs: Any + ) -> LROPoller[None]: + """Delete a private link resource. This operation will remove the private link infrastructure and + disconnect all associated private endpoints. This operation is asynchronous and may take + several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_link_parameters: Parameter group. Required. + :type private_link_parameters: ~azure.mgmt.security.models.PrivateLinkParameters + :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", "2025-09-01-preview")) + 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_link_parameters=private_link_parameters, + 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": "azure-async-operation"}, **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/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_assessments_operations.py new file mode 100644 index 000000000000..dd7740f5bc62 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_assessments_operations.py @@ -0,0 +1,292 @@ +# 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.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 SecurityCenterConfiguration +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( + regulatory_compliance_standard_name: str, + regulatory_compliance_control_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "regulatoryComplianceStandardName": _SERIALIZER.url( + "regulatory_compliance_standard_name", regulatory_compliance_standard_name, "str" + ), + "regulatoryComplianceControlName": _SERIALIZER.url( + "regulatory_compliance_control_name", regulatory_compliance_control_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + regulatory_compliance_standard_name: str, + regulatory_compliance_control_name: str, + regulatory_compliance_assessment_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", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments/{regulatoryComplianceAssessmentName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "regulatoryComplianceStandardName": _SERIALIZER.url( + "regulatory_compliance_standard_name", regulatory_compliance_standard_name, "str" + ), + "regulatoryComplianceControlName": _SERIALIZER.url( + "regulatory_compliance_control_name", regulatory_compliance_control_name, "str" + ), + "regulatoryComplianceAssessmentName": _SERIALIZER.url( + "regulatory_compliance_assessment_name", regulatory_compliance_assessment_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) + + +class RegulatoryComplianceAssessmentsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`regulatory_compliance_assessments` 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: SecurityCenterConfiguration = 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, + regulatory_compliance_standard_name: str, + regulatory_compliance_control_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.RegulatoryComplianceAssessment"]: + """Details and state of assessments mapped to selected regulatory compliance control. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :param regulatory_compliance_control_name: Name of the regulatory compliance control object. + Required. + :type regulatory_compliance_control_name: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either RegulatoryComplianceAssessment or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.RegulatoryComplianceAssessment] + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceAssessmentList] = 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( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + regulatory_compliance_control_name=regulatory_compliance_control_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RegulatoryComplianceAssessmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + regulatory_compliance_standard_name: str, + regulatory_compliance_control_name: str, + regulatory_compliance_assessment_name: str, + **kwargs: Any + ) -> _models.RegulatoryComplianceAssessment: + """Supported regulatory compliance details and state for selected assessment. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :param regulatory_compliance_control_name: Name of the regulatory compliance control object. + Required. + :type regulatory_compliance_control_name: str + :param regulatory_compliance_assessment_name: Name of the regulatory compliance assessment + object. Required. + :type regulatory_compliance_assessment_name: str + :return: RegulatoryComplianceAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RegulatoryComplianceAssessment + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceAssessment] = kwargs.pop("cls", None) + + _request = build_get_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + regulatory_compliance_control_name=regulatory_compliance_control_name, + regulatory_compliance_assessment_name=regulatory_compliance_assessment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegulatoryComplianceAssessment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_controls_operations.py new file mode 100644 index 000000000000..e5a6b8880a57 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_controls_operations.py @@ -0,0 +1,263 @@ +# 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.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 SecurityCenterConfiguration +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( + regulatory_compliance_standard_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "regulatoryComplianceStandardName": _SERIALIZER.url( + "regulatory_compliance_standard_name", regulatory_compliance_standard_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + regulatory_compliance_standard_name: str, + regulatory_compliance_control_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", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "regulatoryComplianceStandardName": _SERIALIZER.url( + "regulatory_compliance_standard_name", regulatory_compliance_standard_name, "str" + ), + "regulatoryComplianceControlName": _SERIALIZER.url( + "regulatory_compliance_control_name", regulatory_compliance_control_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) + + +class RegulatoryComplianceControlsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`regulatory_compliance_controls` 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: SecurityCenterConfiguration = 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, regulatory_compliance_standard_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.RegulatoryComplianceControl"]: + """All supported regulatory compliance controls details and state for selected standard. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either RegulatoryComplianceControl or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.RegulatoryComplianceControl] + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceControlList] = 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( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RegulatoryComplianceControlList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, regulatory_compliance_standard_name: str, regulatory_compliance_control_name: str, **kwargs: Any + ) -> _models.RegulatoryComplianceControl: + """Selected regulatory compliance control details and state. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :param regulatory_compliance_control_name: Name of the regulatory compliance control object. + Required. + :type regulatory_compliance_control_name: str + :return: RegulatoryComplianceControl or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RegulatoryComplianceControl + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceControl] = kwargs.pop("cls", None) + + _request = build_get_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + regulatory_compliance_control_name=regulatory_compliance_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegulatoryComplianceControl", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_standards_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_standards_operations.py new file mode 100644 index 000000000000..763a9f30e893 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_standards_operations.py @@ -0,0 +1,237 @@ +# 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.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 SecurityCenterConfiguration +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(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(regulatory_compliance_standard_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", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "regulatoryComplianceStandardName": _SERIALIZER.url( + "regulatory_compliance_standard_name", regulatory_compliance_standard_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) + + +class RegulatoryComplianceStandardsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`regulatory_compliance_standards` 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: SecurityCenterConfiguration = 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, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.RegulatoryComplianceStandard"]: + """Supported regulatory compliance standards details and state. + + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either RegulatoryComplianceStandard or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.RegulatoryComplianceStandard] + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceStandardList] = 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( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RegulatoryComplianceStandardList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, regulatory_compliance_standard_name: str, **kwargs: Any) -> _models.RegulatoryComplianceStandard: + """Supported regulatory compliance details state for selected standard. + + :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. + Required. + :type regulatory_compliance_standard_name: str + :return: RegulatoryComplianceStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RegulatoryComplianceStandard + :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", "2019-01-01-preview")) + cls: ClsType[_models.RegulatoryComplianceStandard] = kwargs.pop("cls", None) + + _request = build_get_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegulatoryComplianceStandard", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_score_control_definitions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_score_control_definitions_operations.py new file mode 100644 index 000000000000..2f732c3f3050 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_score_control_definitions_operations.py @@ -0,0 +1,232 @@ +# 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.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 SecurityCenterConfiguration +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(**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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/secureScoreControlDefinitions") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) + + +class SecureScoreControlDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`secure_score_control_definitions` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.SecureScoreControlDefinitionItem"]: + """List the available security controls, their assessments, and the max score. + + :return: An iterator like instance of either SecureScoreControlDefinitionItem or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoreControlDefinitionItem] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreControlDefinitionList] = 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( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoreControlDefinitionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.SecureScoreControlDefinitionItem"]: + """For a specified subscription, list the available security controls, their assessments, and the + max score. + + :return: An iterator like instance of either SecureScoreControlDefinitionItem or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoreControlDefinitionItem] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreControlDefinitionList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoreControlDefinitionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_score_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_score_controls_operations.py new file mode 100644 index 000000000000..435eaaeb9543 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_score_controls_operations.py @@ -0,0 +1,268 @@ +# 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, Union + +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 SecurityCenterConfiguration +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_by_secure_score_request( + secure_score_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.ExpandControlsEnum]] = 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "secureScoreName": _SERIALIZER.url("secure_score_name", secure_score_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + subscription_id: str, *, expand: Optional[Union[str, _models.ExpandControlsEnum]] = 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControls" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecureScoreControlsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`secure_score_controls` 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: SecurityCenterConfiguration = 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_by_secure_score( + self, secure_score_name: str, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any + ) -> ItemPaged["_models.SecureScoreControlDetails"]: + """Get all security controls for a specific initiative within a scope. + + :param secure_score_name: The initiative name. For the ASC Default initiative, use 'ascScore' + as in the sample request below. Required. + :type secure_score_name: str + :param expand: OData expand. Optional. "definition" Default value is None. + :type expand: str or ~azure.mgmt.security.models.ExpandControlsEnum + :return: An iterator like instance of either SecureScoreControlDetails or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoreControlDetails] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreControlList] = 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_by_secure_score_request( + secure_score_name=secure_score_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoreControlList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list( + self, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any + ) -> ItemPaged["_models.SecureScoreControlDetails"]: + """Get all security controls within a scope. + + :param expand: OData expand. Optional. "definition" Default value is None. + :type expand: str or ~azure.mgmt.security.models.ExpandControlsEnum + :return: An iterator like instance of either SecureScoreControlDetails or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoreControlDetails] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreControlList] = 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( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoreControlList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_scores_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_scores_operations.py new file mode 100644 index 000000000000..791b42cea600 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_scores_operations.py @@ -0,0 +1,227 @@ +# 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.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 SecurityCenterConfiguration +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(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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(secure_score_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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "secureScoreName": _SERIALIZER.url("secure_score_name", secure_score_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) + + +class SecureScoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`secure_scores` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.SecureScoreItem"]: + """List secure scores for all your Microsoft Defender for Cloud initiatives within your current + scope. + + :return: An iterator like instance of either SecureScoreItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoreItem] + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoresList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecureScoresList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, secure_score_name: str, **kwargs: Any) -> _models.SecureScoreItem: + """Get secure score for a specific Microsoft Defender for Cloud initiative within your current + scope. For the ASC Default initiative, use 'ascScore'. + + :param secure_score_name: The initiative name. For the ASC Default initiative, use 'ascScore' + as in the sample request below. Required. + :type secure_score_name: str + :return: SecureScoreItem or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecureScoreItem + :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", "2020-01-01")) + cls: ClsType[_models.SecureScoreItem] = kwargs.pop("cls", None) + + _request = build_get_request( + secure_score_name=secure_score_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecureScoreItem", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_connector_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_connector_application_operations.py new file mode 100644 index 000000000000..c2ccaba7b9bd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_connector_application_operations.py @@ -0,0 +1,422 @@ +# 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 + +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 SecurityCenterConfiguration +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( + resource_group_name: str, security_connector_name: str, application_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", "2022-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/applications/{applicationId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "applicationId": _SERIALIZER.url("application_id", application_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_create_or_update_request( + resource_group_name: str, security_connector_name: str, application_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", "2022-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/applications/{applicationId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "applicationId": _SERIALIZER.url("application_id", application_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 + 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, security_connector_name: str, application_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", "2022-07-01-preview")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/applications/{applicationId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "applicationId": _SERIALIZER.url("application_id", application_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="DELETE", url=_url, params=_params, **kwargs) + + +class SecurityConnectorApplicationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`security_connector_application` 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: SecurityCenterConfiguration = 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, security_connector_name: str, application_id: str, **kwargs: Any + ) -> _models.Application: + """Get a specific application for the requested scope by applicationId. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :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", "2022-07-01-preview")) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + application_id=application_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", 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, + security_connector_name: str, + application_id: str, + application: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Creates or update a security Application on the given security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Required. + :type application: ~azure.mgmt.security.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + application_id: str, + application: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Creates or update a security Application on the given security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Required. + :type application: 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: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + application_id: str, + application: Union[_models.Application, IO[bytes]], + **kwargs: Any + ) -> _models.Application: + """Creates or update a security Application on the given security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: str + :param application: Application over a subscription scope. Is either a Application type or a + IO[bytes] type. Required. + :type application: ~azure.mgmt.security.models.Application or IO[bytes] + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Application + :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", "2022-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application, (IOBase, bytes)): + _content = application + else: + _json = self._serialize.body(application, "Application") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + application_id=application_id, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", 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, security_connector_name: str, application_id: str, **kwargs: Any + ) -> None: + """Delete an Application over a given scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param application_id: The security Application key - unique key for the standard application. + Required. + :type application_id: 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", "2022-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + application_id=application_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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_connector_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_connector_applications_operations.py new file mode 100644 index 000000000000..c8693119a90e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_connector_applications_operations.py @@ -0,0 +1,163 @@ +# 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.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 SecurityCenterConfiguration +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, security_connector_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", "2022-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/applications", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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) + + +class SecurityConnectorApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`security_connector_applications` 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: SecurityCenterConfiguration = 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, security_connector_name: str, **kwargs: Any + ) -> ItemPaged["_models.Application"]: + """Get a list of all relevant applications over a security connector level scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + cls: ClsType[_models.ApplicationsList] = 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, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_connectors_operations.py new file mode 100644 index 000000000000..2b842b52686b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_connectors_operations.py @@ -0,0 +1,764 @@ +# 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 + +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 SecurityCenterConfiguration +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(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _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_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecurityConnectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`security_connectors` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.SecurityConnector"]: + """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in + the response to get the next page of security connectors for the specified subscription. + + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityConnector] + :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", "2024-08-01-preview")) + cls: ClsType[_models.SecurityConnectorsList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.SecurityConnector"]: + """Lists all the security connectors in the specified resource group. Use the 'nextLink' property + in the response to get the next page of security connectors for the specified resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityConnector] + :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", "2024-08-01-preview")) + cls: ClsType[_models.SecurityConnectorsList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> _models.SecurityConnector: + """Retrieves details of a specific security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :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", "2024-08-01-preview")) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", 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, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.models.SecurityConnector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: 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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a SecurityConnector type + or a IO[bytes] type. Required. + :type security_connector: ~azure.mgmt.security.models.SecurityConnector or IO[bytes] + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :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", "2024-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IOBase, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.models.SecurityConnector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: 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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a SecurityConnector type + or a IO[bytes] type. Required. + :type security_connector: ~azure.mgmt.security.models.SecurityConnector or IO[bytes] + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityConnector + :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", "2024-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IOBase, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + _request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", 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, security_connector_name: str, **kwargs: Any + ) -> None: + """Deletes a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_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", "2024-08-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_contacts_operations.py new file mode 100644 index 000000000000..050606d65846 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_contacts_operations.py @@ -0,0 +1,463 @@ +# 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 + +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 SecurityCenterConfiguration +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(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request( + security_contact_name: Union[str, _models.SecurityContactName], subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + security_contact_name: Union[str, _models.SecurityContactName], subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + 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}/providers/Microsoft.Security/securityContacts/{securityContactName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_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_delete_request( + security_contact_name: Union[str, _models.SecurityContactName], subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecurityContactsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`security_contacts` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.SecurityContact"]: + """List all security contact configurations for the subscription. + + :return: An iterator like instance of either SecurityContact or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityContact] + :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", "2023-12-01-preview")) + cls: ClsType[_models.SecurityContactList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityContactList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, security_contact_name: Union[str, _models.SecurityContactName], **kwargs: Any + ) -> _models.SecurityContact: + """Get Default Security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityContact + :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", "2023-12-01-preview")) + cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) + + _request = build_get_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityContact", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + security_contact_name: Union[str, _models.SecurityContactName], + security_contact: _models.SecurityContact, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :param security_contact: Security contact object. Required. + :type security_contact: ~azure.mgmt.security.models.SecurityContact + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + security_contact_name: Union[str, _models.SecurityContactName], + security_contact: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :param security_contact: Security contact object. Required. + :type security_contact: 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: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + security_contact_name: Union[str, _models.SecurityContactName], + security_contact: Union[_models.SecurityContact, IO[bytes]], + **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :param security_contact: Security contact object. Is either a SecurityContact type or a + IO[bytes] type. Required. + :type security_contact: ~azure.mgmt.security.models.SecurityContact or IO[bytes] + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityContact + :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", "2023-12-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_contact, (IOBase, bytes)): + _content = security_contact + else: + _json = self._serialize.body(security_contact, "SecurityContact") + + _request = build_create_request( + security_contact_name=security_contact_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityContact", 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, security_contact_name: Union[str, _models.SecurityContactName], **kwargs: Any + ) -> None: + """Delete security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. "default" Required. + :type security_contact_name: str or ~azure.mgmt.security.models.SecurityContactName + :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", "2023-12-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + security_contact_name=security_contact_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_operators_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_operators_operations.py new file mode 100644 index 000000000000..7f1635799573 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_operators_operations.py @@ -0,0 +1,426 @@ +# 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 SecurityCenterConfiguration +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(pricing_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}/securityOperators", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "pricingName": _SERIALIZER.url( + "pricing_name", pricing_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z][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_get_request( + pricing_name: str, security_operator_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}/securityOperators/{securityOperatorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "pricingName": _SERIALIZER.url( + "pricing_name", pricing_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z][a-zA-Z0-9_]+$" + ), + "securityOperatorName": _SERIALIZER.url( + "security_operator_name", + security_operator_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][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( + pricing_name: str, security_operator_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}/securityOperators/{securityOperatorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "pricingName": _SERIALIZER.url( + "pricing_name", pricing_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z][a-zA-Z0-9_]+$" + ), + "securityOperatorName": _SERIALIZER.url( + "security_operator_name", + security_operator_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + pricing_name: str, security_operator_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}/securityOperators/{securityOperatorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "pricingName": _SERIALIZER.url( + "pricing_name", pricing_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z][a-zA-Z0-9_]+$" + ), + "securityOperatorName": _SERIALIZER.url( + "security_operator_name", + security_operator_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][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 SecurityOperatorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`security_operators` 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: SecurityCenterConfiguration = 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, pricing_name: str, **kwargs: Any) -> _models.SecurityOperatorList: + """Lists Microsoft Defender for Cloud securityOperators in the subscription. + + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :return: SecurityOperatorList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityOperatorList + :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", "2023-01-01-preview")) + cls: ClsType[_models.SecurityOperatorList] = kwargs.pop("cls", None) + + _request = build_list_request( + pricing_name=pricing_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityOperatorList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, pricing_name: str, security_operator_name: str, **kwargs: Any) -> _models.SecurityOperator: + """Get a specific security operator for the requested scope. + + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param security_operator_name: name of the securityOperator. Required. + :type security_operator_name: str + :return: SecurityOperator or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityOperator + :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", "2023-01-01-preview")) + cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) + + _request = build_get_request( + pricing_name=pricing_name, + security_operator_name=security_operator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityOperator", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def create_or_update( + self, pricing_name: str, security_operator_name: str, **kwargs: Any + ) -> _models.SecurityOperator: + """Creates Microsoft Defender for Cloud security operator on the given scope. + + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param security_operator_name: name of the securityOperator. Required. + :type security_operator_name: str + :return: SecurityOperator or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityOperator + :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", "2023-01-01-preview")) + cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + pricing_name=pricing_name, + security_operator_name=security_operator_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityOperator", 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, pricing_name: str, security_operator_name: str, **kwargs: Any + ) -> None: + """Delete Microsoft Defender for Cloud securityOperator in the subscription. + + :param pricing_name: name of the pricing configuration. Required. + :type pricing_name: str + :param security_operator_name: name of the securityOperator. Required. + :type security_operator_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", "2023-01-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + pricing_name=pricing_name, + security_operator_name=security_operator_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_solutions_operations.py new file mode 100644 index 000000000000..0df11458a571 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_solutions_operations.py @@ -0,0 +1,242 @@ +# 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.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 SecurityCenterConfiguration +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(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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request( + resource_group_name: str, asc_location: str, security_solution_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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "securitySolutionName": _SERIALIZER.url("security_solution_name", security_solution_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) + + +class SecuritySolutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`security_solutions` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.SecuritySolution"]: + """Gets a list of Security Solutions for the subscription. + + :return: An iterator like instance of either SecuritySolution or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecuritySolution] + :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", "2020-01-01")) + cls: ClsType[_models.SecuritySolutionList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecuritySolutionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, asc_location: str, security_solution_name: str, **kwargs: Any + ) -> _models.SecuritySolution: + """Gets a specific Security Solution. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param security_solution_name: Name of security solution. Required. + :type security_solution_name: str + :return: SecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecuritySolution + :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", "2020-01-01")) + cls: ClsType[_models.SecuritySolution] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + security_solution_name=security_solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySolution", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_solutions_reference_data_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_solutions_reference_data_operations.py new file mode 100644 index 000000000000..0b33009bda2d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_solutions_reference_data_operations.py @@ -0,0 +1,213 @@ +# 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 SecurityCenterConfiguration +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(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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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) + + +class SecuritySolutionsReferenceDataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`security_solutions_reference_data` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: + """Gets a list of all supported Security Solutions for the subscription. + + :return: SecuritySolutionsReferenceDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecuritySolutionsReferenceDataList + :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", "2020-01-01")) + cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_home_region(self, asc_location: str, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: + """Gets list of all supported Security Solutions for subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: SecuritySolutionsReferenceDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecuritySolutionsReferenceDataList + :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", "2020-01-01")) + cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) + + _request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_standards_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_standards_operations.py new file mode 100644 index 000000000000..e0be7c402572 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_standards_operations.py @@ -0,0 +1,484 @@ +# 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 + +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 SecurityCenterConfiguration +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(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/securityStandards") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "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_get_request(scope: str, standard_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/securityStandards/{standardId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "standardId": _SERIALIZER.url( + "standard_id", standard_id, "str", pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{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_create_or_update_request(scope: str, standard_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/securityStandards/{standardId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "standardId": _SERIALIZER.url( + "standard_id", standard_id, "str", pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$" + ), + } + + _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(scope: str, standard_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/securityStandards/{standardId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str"), + "standardId": _SERIALIZER.url( + "standard_id", standard_id, "str", pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecurityStandardsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`security_standards` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> ItemPaged["_models.SecurityStandard"]: + """Get a list of all relevant security standards over a scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :return: An iterator like instance of either SecurityStandard or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityStandard] + :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", "2024-08-01")) + cls: ClsType[_models.SecurityStandardList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityStandardList", 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, scope: str, standard_id: str, **kwargs: Any) -> _models.SecurityStandard: + """Get a specific security standard for the requested scope by standardId. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: str + :return: SecurityStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityStandard + :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", "2024-08-01")) + cls: ClsType[_models.SecurityStandard] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + standard_id=standard_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("SecurityStandard", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + scope: str, + standard_id: str, + standard: _models.SecurityStandard, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityStandard: + """Creates or updates a security standard over a given scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: str + :param standard: Custom security standard over a pre-defined scope. Required. + :type standard: ~azure.mgmt.security.models.SecurityStandard + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SecurityStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityStandard + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + scope: str, + standard_id: str, + standard: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityStandard: + """Creates or updates a security standard over a given scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: str + :param standard: Custom security standard over a pre-defined scope. Required. + :type standard: 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: SecurityStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityStandard + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, scope: str, standard_id: str, standard: Union[_models.SecurityStandard, IO[bytes]], **kwargs: Any + ) -> _models.SecurityStandard: + """Creates or updates a security standard over a given scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: str + :param standard: Custom security standard over a pre-defined scope. Is either a + SecurityStandard type or a IO[bytes] type. Required. + :type standard: ~azure.mgmt.security.models.SecurityStandard or IO[bytes] + :return: SecurityStandard or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityStandard + :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", "2024-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityStandard] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(standard, (IOBase, bytes)): + _content = standard + else: + _json = self._serialize.body(standard, "SecurityStandard") + + _request = build_create_or_update_request( + scope=scope, + standard_id=standard_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("SecurityStandard", 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, scope: str, standard_id: str, **kwargs: Any + ) -> None: + """Delete a security standard over a given scope. + + :param scope: The scope of the security standard. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :param standard_id: The Security Standard key - unique key for the standard type. Required. + :type standard_id: 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", "2024-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + scope=scope, + standard_id=standard_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/security/azure-mgmt-security/azure/mgmt/security/operations/_sensitivity_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sensitivity_settings_operations.py new file mode 100644 index 000000000000..11ce589758d8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sensitivity_settings_operations.py @@ -0,0 +1,310 @@ +# 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 + +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 SecurityCenterConfiguration +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_create_or_update_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/sensitivitySettings/current") + + # 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_get_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-15-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/sensitivitySettings/current") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-15-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/sensitivitySettings") + + # 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 SensitivitySettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`sensitivity_settings` 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: SecurityCenterConfiguration = 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") + + @overload + def create_or_update( + self, + sensitivity_settings: _models.UpdateSensitivitySettingsRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Create or update data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Required. + :type sensitivity_settings: ~azure.mgmt.security.models.UpdateSensitivitySettingsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, sensitivity_settings: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Create or update data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Required. + :type sensitivity_settings: 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: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO[bytes]], **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Create or update data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Is either a + UpdateSensitivitySettingsRequest type or a IO[bytes] type. Required. + :type sensitivity_settings: ~azure.mgmt.security.models.UpdateSensitivitySettingsRequest or + IO[bytes] + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsResponse + :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", "2023-02-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sensitivity_settings, (IOBase, bytes)): + _content = sensitivity_settings + else: + _json = self._serialize.body(sensitivity_settings, "UpdateSensitivitySettingsRequest") + + _request = build_create_or_update_request( + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, **kwargs: Any) -> _models.GetSensitivitySettingsResponse: + """Gets data sensitivity settings for sensitive data discovery. + + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsResponse + :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", "2023-02-15-preview")) + cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> _models.GetSensitivitySettingsListResponse: + """Gets a list with a single sensitivity settings resource. + + :return: GetSensitivitySettingsListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.models.GetSensitivitySettingsListResponse + :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", "2023-02-15-preview")) + cls: ClsType[_models.GetSensitivitySettingsListResponse] = kwargs.pop("cls", None) + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_server_vulnerability_assessment_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_server_vulnerability_assessment_operations.py new file mode 100644 index 000000000000..5e3b53bbf081 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_server_vulnerability_assessment_operations.py @@ -0,0 +1,552 @@ +# 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, Iterator, Literal, Optional, TypeVar, Union, cast + +from azure.core import PipelineClient +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 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 SecurityCenterConfiguration +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_by_extended_resource_request( + resource_group_name: str, + resource_namespace: str, + resource_type: str, + 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), + "resourceName": _SERIALIZER.url("resource_name", 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_get_request( + resource_group_name: str, + resource_namespace: str, + resource_type: str, + 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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "serverVulnerabilityAssessment": _SERIALIZER.url( + "server_vulnerability_assessment", server_vulnerability_assessment, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + resource_namespace: str, + resource_type: str, + 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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "serverVulnerabilityAssessment": _SERIALIZER.url( + "server_vulnerability_assessment", server_vulnerability_assessment, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_namespace: str, + resource_type: str, + 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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "serverVulnerabilityAssessment": _SERIALIZER.url( + "server_vulnerability_assessment", server_vulnerability_assessment, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServerVulnerabilityAssessmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`server_vulnerability_assessment` 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: SecurityCenterConfiguration = 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_by_extended_resource( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsList: + """Gets a list of server vulnerability assessment onboarding statuses on a given resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The Namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :return: ServerVulnerabilityAssessmentsList or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsList + :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", "2020-01-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsList] = kwargs.pop("cls", None) + + _request = build_list_by_extended_resource_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServerVulnerabilityAssessmentsList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Gets a server vulnerability assessment onboarding statuses on a given resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The Namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :return: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessment + :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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + server_vulnerability_assessment=server_vulnerability_assessment, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def create_or_update( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creating a server vulnerability assessment on a resource, which will onboard a resource for + having a vulnerability assessment on it. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The Namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :return: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessment + :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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + server_vulnerability_assessment=server_vulnerability_assessment, + 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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + server_vulnerability_assessment=server_vulnerability_assessment, + 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 [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Removing server vulnerability assessment from a resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The Namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_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 {}) + + server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + server_vulnerability_assessment=server_vulnerability_assessment, + 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/security/azure-mgmt-security/azure/mgmt/security/operations/_server_vulnerability_assessments_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_server_vulnerability_assessments_settings_operations.py new file mode 100644 index 000000000000..875227ca7d73 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_server_vulnerability_assessments_settings_operations.py @@ -0,0 +1,496 @@ +# 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 + +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 SecurityCenterConfiguration +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_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request( + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "settingKind": _SERIALIZER.url("setting_kind", setting_kind, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-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}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "settingKind": _SERIALIZER.url("setting_kind", setting_kind, "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_delete_request( + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "settingKind": _SERIALIZER.url("setting_kind", setting_kind, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServerVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`server_vulnerability_assessments_settings` 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: SecurityCenterConfiguration = 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_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.ServerVulnerabilityAssessmentsSetting"]: + """Get a list of all the server vulnerability assessments settings over a subscription level + scope. + + :return: An iterator like instance of either ServerVulnerabilityAssessmentsSetting or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting] + :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", "2023-05-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSettingsList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSettingsList", 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, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Get a server vulnerability assessments setting of the requested kind, that is set on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :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", "2023-05-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + setting_kind=setting_kind, + 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("ServerVulnerabilityAssessmentsSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: _models.ServerVulnerabilityAssessmentsSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Required. + :type server_vulnerability_assessments_setting: + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Required. + :type server_vulnerability_assessments_setting: 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: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: Union[_models.ServerVulnerabilityAssessmentsSetting, IO[bytes]], + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Is either a ServerVulnerabilityAssessmentsSetting type or a IO[bytes] + type. Required. + :type server_vulnerability_assessments_setting: + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting or IO[bytes] + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSetting + :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", "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(server_vulnerability_assessments_setting, (IOBase, bytes)): + _content = server_vulnerability_assessments_setting + else: + _json = self._serialize.body( + server_vulnerability_assessments_setting, "ServerVulnerabilityAssessmentsSetting" + ) + + _request = build_create_or_update_request( + setting_kind=setting_kind, + 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("ServerVulnerabilityAssessmentsSetting", 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, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any + ) -> None: + """Delete the server vulnerability assessments setting of the requested kind from the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsSettingKindName + :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", "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + setting_kind=setting_kind, + 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/security/azure-mgmt-security/azure/mgmt/security/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_settings_operations.py new file mode 100644 index 000000000000..772bc4c81fca --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_settings_operations.py @@ -0,0 +1,381 @@ +# 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 + +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 SecurityCenterConfiguration +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(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", "2022-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request( + setting_name: Union[str, _models.SettingNameAutoGenerated], 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", "2022-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "settingName": _SERIALIZER.url("setting_name", setting_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_update_request( + setting_name: Union[str, _models.SettingNameAutoGenerated], 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", "2022-05-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}/providers/Microsoft.Security/settings/{settingName}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "settingName": _SERIALIZER.url("setting_name", setting_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) + + +class SettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`settings` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.Setting"]: + """Settings about different configurations in Microsoft Defender for Cloud. + + :return: An iterator like instance of either Setting or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Setting] + :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", "2022-05-01")) + cls: ClsType[_models.SettingsList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SettingsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, setting_name: Union[str, _models.SettingNameAutoGenerated], **kwargs: Any) -> _models.Setting: + """Settings of different configurations in Microsoft Defender for Cloud. + + :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", + "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingNameAutoGenerated + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Setting + :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", "2022-05-01")) + cls: ClsType[_models.Setting] = kwargs.pop("cls", None) + + _request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Setting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + setting_name: Union[str, _models.SettingNameAutoGenerated], + setting: _models.Setting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Setting: + """updating settings about different configurations in Microsoft Defender for Cloud. + + :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", + "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingNameAutoGenerated + :param setting: Setting object. Required. + :type setting: ~azure.mgmt.security.models.Setting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + setting_name: Union[str, _models.SettingNameAutoGenerated], + setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Setting: + """updating settings about different configurations in Microsoft Defender for Cloud. + + :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", + "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingNameAutoGenerated + :param setting: Setting object. Required. + :type setting: 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: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + setting_name: Union[str, _models.SettingNameAutoGenerated], + setting: Union[_models.Setting, IO[bytes]], + **kwargs: Any + ) -> _models.Setting: + """updating settings about different configurations in Microsoft Defender for Cloud. + + :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", + "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. + :type setting_name: str or ~azure.mgmt.security.models.SettingNameAutoGenerated + :param setting: Setting object. Is either a Setting type or a IO[bytes] type. Required. + :type setting: ~azure.mgmt.security.models.Setting or IO[bytes] + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Setting + :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", "2022-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Setting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IOBase, bytes)): + _content = setting + else: + _json = self._serialize.body(setting, "Setting") + + _request = build_update_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Setting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_software_inventories_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_software_inventories_operations.py new file mode 100644 index 000000000000..a424e6770b78 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_software_inventories_operations.py @@ -0,0 +1,383 @@ +# 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.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 SecurityCenterConfiguration +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_by_extended_resource_request( + resource_group_name: str, + resource_namespace: str, + resource_type: str, + 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", "2021-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), + "resourceName": _SERIALIZER.url("resource_name", 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_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/softwareInventories" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request( + resource_group_name: str, + resource_namespace: str, + resource_type: str, + resource_name: str, + software_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories/{softwareName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "softwareName": _SERIALIZER.url("software_name", software_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) + + +class SoftwareInventoriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`software_inventories` 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: SecurityCenterConfiguration = 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_by_extended_resource( + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.Software"]: + """Gets the software inventory of the virtual machine. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of either Software or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Software] + :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", "2021-05-01-preview")) + cls: ClsType[_models.SoftwaresList] = 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_by_extended_resource_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SoftwaresList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.Software"]: + """Gets the software inventory of all virtual machines in the subscriptions. + + :return: An iterator like instance of either Software or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.Software] + :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", "2021-05-01-preview")) + cls: ClsType[_models.SoftwaresList] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SoftwaresList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_namespace: str, + resource_type: str, + resource_name: str, + software_name: str, + **kwargs: Any + ) -> _models.Software: + """Gets a single software data of the virtual machine. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_namespace: The namespace of the resource. Required. + :type resource_namespace: str + :param resource_type: The type of the resource. Required. + :type resource_type: str + :param resource_name: Name of the resource. Required. + :type resource_name: str + :param software_name: Name of the installed software. Required. + :type software_name: str + :return: Software or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Software + :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", "2021-05-01-preview")) + cls: ClsType[_models.Software] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_namespace=resource_namespace, + resource_type=resource_type, + resource_name=resource_name, + software_name=software_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Software", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_baseline_rules_operations.py new file mode 100644 index 000000000000..0f54fcf918c4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_baseline_rules_operations.py @@ -0,0 +1,651 @@ +# 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 + +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 SecurityCenterConfiguration +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_create_or_update_request(rule_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}", + ) + path_format_arguments = { + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(rule_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}", + ) + path_format_arguments = { + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(rule_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}", + ) + path_format_arguments = { + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") + _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_add_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlVulnerabilityAssessmentBaselineRulesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`sql_vulnerability_assessment_baseline_rules` 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: SecurityCenterConfiguration = 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") + + @overload + def create_or_update( + self, + rule_id: str, + workspace_id: str, + resource_id: str, + body: Optional[_models.RuleResultsInput] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RuleResults: + """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline results for this rule. Default value is None. + :type body: ~azure.mgmt.security.models.RuleResultsInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RuleResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + rule_id: str, + workspace_id: str, + resource_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RuleResults: + """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline results for this rule. 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: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RuleResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + rule_id: str, + workspace_id: str, + resource_id: str, + body: Optional[Union[_models.RuleResultsInput, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.RuleResults: + """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + Creates a Baseline for a rule in a database. Will overwrite any previously existing results. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline results for this rule. Is either a RuleResultsInput type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.security.models.RuleResultsInput or IO[bytes] + :return: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RuleResults + :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", "2023-02-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "RuleResultsInput") + else: + _json = None + + _request = build_create_or_update_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RuleResults: + """Gets the results for a given rule in the Baseline. + + Gets the results for a given rule in the Baseline. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RuleResults + :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", "2023-02-01-preview")) + cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) + + _request = build_get_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleResults", 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, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any + ) -> None: + """Deletes a rule from the Baseline of a given database. + + Deletes a rule from the Baseline of a given database. + + :param rule_id: The rule Id. Required. + :type rule_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: 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", "2023-02-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RulesResults: + """Gets the results for all rules in the Baseline. + + Gets the results for all rules in the Baseline. + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RulesResults + :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", "2023-02-01-preview")) + cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RulesResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def add( + self, + workspace_id: str, + resource_id: str, + body: Optional[_models.RulesResultsInput] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RulesResults: + """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline rules. Default value is None. + :type body: ~azure.mgmt.security.models.RulesResultsInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RulesResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def add( + self, + workspace_id: str, + resource_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RulesResults: + """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline rules. 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: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RulesResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def add( + self, + workspace_id: str, + resource_id: str, + body: Optional[Union[_models.RulesResultsInput, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.RulesResults: + """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + Add a list of baseline rules. Will overwrite any previously existing results (for all rules). + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param body: The baseline rules. Is either a RulesResultsInput type or a IO[bytes] type. + Default value is None. + :type body: ~azure.mgmt.security.models.RulesResultsInput or IO[bytes] + :return: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.RulesResults + :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", "2023-02-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "RulesResultsInput") + else: + _json = None + + _request = build_add_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RulesResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_scan_results_operations.py new file mode 100644 index 000000000000..0eb8f9f7415b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_scan_results_operations.py @@ -0,0 +1,239 @@ +# 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 SecurityCenterConfiguration +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( + scan_id: str, scan_result_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults/{scanResultId}", + ) + path_format_arguments = { + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + "scanResultId": _SERIALIZER.url("scan_result_id", scan_result_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(scan_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults", + ) + path_format_arguments = { + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") + _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 SqlVulnerabilityAssessmentScanResultsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`sql_vulnerability_assessment_scan_results` 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: SecurityCenterConfiguration = 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, scan_id: str, scan_result_id: str, workspace_id: str, resource_id: str, **kwargs: Any + ) -> _models.ScanResult: + """Gets the scan results of a single rule in a scan record. + + Gets the scan results of a single rule in a scan record. + + :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. + Required. + :type scan_id: str + :param scan_result_id: The rule Id of the results. Required. + :type scan_result_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: ScanResult or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ScanResult + :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", "2023-02-01-preview")) + cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) + + _request = build_get_request( + scan_id=scan_id, + scan_result_id=scan_result_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScanResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.ScanResults: + """Gets a list of scan results for a single scan record. + + Gets a list of scan results for a single scan record. + + :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. + Required. + :type scan_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: ScanResults or the result of cls(response) + :rtype: ~azure.mgmt.security.models.ScanResults + :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", "2023-02-01-preview")) + cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) + + _request = build_list_request( + scan_id=scan_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScanResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_scans_operations.py new file mode 100644 index 000000000000..a14ad318c607 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_scans_operations.py @@ -0,0 +1,223 @@ +# 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 SecurityCenterConfiguration +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(scan_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}" + ) + path_format_arguments = { + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") + _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 SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`sql_vulnerability_assessment_scans` 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: SecurityCenterConfiguration = 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, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: + """Gets the scan details of a single scan record. + + Gets the scan details of a single scan record. + + :param scan_id: The scan Id. Type 'latest' to get the scan record for the latest scan. + Required. + :type scan_id: str + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: Scan or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Scan + :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", "2023-02-01-preview")) + cls: ClsType[_models.Scan] = kwargs.pop("cls", None) + + _request = build_get_request( + scan_id=scan_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Scan", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scans: + """Gets a list of scan records. + + Gets a list of scan records. + + :param workspace_id: The workspace Id. Required. + :type workspace_id: str + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :return: Scans or the result of cls(response) + :rtype: ~azure.mgmt.security.models.Scans + :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", "2023-02-01-preview")) + cls: ClsType[_models.Scans] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Scans", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_standard_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_standard_assignments_operations.py new file mode 100644 index 000000000000..22f17d52de30 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_standard_assignments_operations.py @@ -0,0 +1,507 @@ +# 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 + +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 SecurityCenterConfiguration +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(resource_id: str, standard_assignment_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/standardAssignments/{standardAssignmentName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "standardAssignmentName": _SERIALIZER.url( + "standard_assignment_name", + standard_assignment_name, + "str", + pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{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_create_request(resource_id: str, standard_assignment_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-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", "/{resourceId}/providers/Microsoft.Security/standardAssignments/{standardAssignmentName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "standardAssignmentName": _SERIALIZER.url( + "standard_assignment_name", + standard_assignment_name, + "str", + pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$", + ), + } + + _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_id: str, standard_assignment_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/standardAssignments/{standardAssignmentName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "standardAssignmentName": _SERIALIZER.url( + "standard_assignment_name", + standard_assignment_name, + "str", + pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/standardAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "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) + + +class StandardAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`standard_assignments` 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: SecurityCenterConfiguration = 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_id: str, standard_assignment_name: str, **kwargs: Any) -> _models.StandardAssignment: + """Retrieves a standard assignment. + + This operation retrieves a single standard assignment, given its name and the scope it was + created at. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_name: str + :return: StandardAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.StandardAssignment + :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", "2024-08-01")) + cls: ClsType[_models.StandardAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_id=resource_id, + standard_assignment_name=standard_assignment_name, + 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("StandardAssignment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_id: str, + standard_assignment_name: str, + standard_assignment: _models.StandardAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StandardAssignment: + """Creates or updates a standard assignment. + + This operation creates or updates a standard assignment with the given scope and name. standard + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_name: str + :param standard_assignment: Custom standard assignment over a pre-defined scope. Required. + :type standard_assignment: ~azure.mgmt.security.models.StandardAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StandardAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.StandardAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_id: str, + standard_assignment_name: str, + standard_assignment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StandardAssignment: + """Creates or updates a standard assignment. + + This operation creates or updates a standard assignment with the given scope and name. standard + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_name: str + :param standard_assignment: Custom standard assignment over a pre-defined scope. Required. + :type standard_assignment: 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: StandardAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.StandardAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_id: str, + standard_assignment_name: str, + standard_assignment: Union[_models.StandardAssignment, IO[bytes]], + **kwargs: Any + ) -> _models.StandardAssignment: + """Creates or updates a standard assignment. + + This operation creates or updates a standard assignment with the given scope and name. standard + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_name: str + :param standard_assignment: Custom standard assignment over a pre-defined scope. Is either a + StandardAssignment type or a IO[bytes] type. Required. + :type standard_assignment: ~azure.mgmt.security.models.StandardAssignment or IO[bytes] + :return: StandardAssignment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.StandardAssignment + :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", "2024-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StandardAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(standard_assignment, (IOBase, bytes)): + _content = standard_assignment + else: + _json = self._serialize.body(standard_assignment, "StandardAssignment") + + _request = build_create_request( + resource_id=resource_id, + standard_assignment_name=standard_assignment_name, + 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("StandardAssignment", 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_id: str, standard_assignment_name: str, **kwargs: Any + ) -> None: + """Deletes a standard assignment. + + This operation deletes a standard assignment, given its name and the scope it was created in. + The scope of a standard assignment is the part of its ID preceding + '/providers/Microsoft.Security/standardAssignments/{standardAssignmentName}'. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param standard_assignment_name: The standard assignments assignment key - unique key for the + standard assignment. Required. + :type standard_assignment_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", "2024-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_id=resource_id, + standard_assignment_name=standard_assignment_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, scope: str, **kwargs: Any) -> ItemPaged["_models.StandardAssignment"]: + """Get a list of all relevant standard assignments over a scope. + + :param scope: The scope of the standard assignment. Valid scopes are: management group (format: + 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + Required. + :type scope: str + :return: An iterator like instance of either StandardAssignment or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.StandardAssignment] + :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", "2024-08-01")) + cls: ClsType[_models.StandardAssignmentsList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StandardAssignmentsList", 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) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sub_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sub_assessments_operations.py new file mode 100644 index 000000000000..3b2a20452972 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sub_assessments_operations.py @@ -0,0 +1,335 @@ +# 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.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 SecurityCenterConfiguration +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(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/subAssessments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(scope: str, assessment_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments" + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "assessmentName": _SERIALIZER.url("assessment_name", assessment_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_get_request(scope: str, assessment_name: str, sub_assessment_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments/{subAssessmentName}", + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), + "subAssessmentName": _SERIALIZER.url("sub_assessment_name", sub_assessment_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) + + +class SubAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`sub_assessments` 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: SecurityCenterConfiguration = 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, scope: str, **kwargs: Any) -> ItemPaged["_models.SecuritySubAssessment"]: + """Get security sub-assessments on all your scanned resources inside a subscription scope. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :return: An iterator like instance of either SecuritySubAssessment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecuritySubAssessment] + :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", "2019-01-01-preview")) + cls: ClsType[_models.SecuritySubAssessmentList] = 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( + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecuritySubAssessmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, scope: str, assessment_name: str, **kwargs: Any) -> ItemPaged["_models.SecuritySubAssessment"]: + """Get security sub-assessments on all your scanned resources inside a scope. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :return: An iterator like instance of either SecuritySubAssessment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecuritySubAssessment] + :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", "2019-01-01-preview")) + cls: ClsType[_models.SecuritySubAssessmentList] = 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( + scope=scope, + assessment_name=assessment_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecuritySubAssessmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, scope: str, assessment_name: str, sub_assessment_name: str, **kwargs: Any + ) -> _models.SecuritySubAssessment: + """Get a security sub-assessment on your scanned resource. + + :param scope: Scope of the query, can be subscription + (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group + (/providers/Microsoft.Management/managementGroups/mgName). Required. + :type scope: str + :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. + :type assessment_name: str + :param sub_assessment_name: The Sub-Assessment Key - Unique key for the sub-assessment type. + Required. + :type sub_assessment_name: str + :return: SecuritySubAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecuritySubAssessment + :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", "2019-01-01-preview")) + cls: ClsType[_models.SecuritySubAssessment] = kwargs.pop("cls", None) + + _request = build_get_request( + scope=scope, + assessment_name=assessment_name, + sub_assessment_name=sub_assessment_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySubAssessment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_tasks_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_tasks_operations.py new file mode 100644 index 000000000000..d4617cbdf208 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_tasks_operations.py @@ -0,0 +1,760 @@ +# 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, Union + +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 SecurityCenterConfiguration +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(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/tasks") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_home_region_request( + asc_location: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_subscription_level_task_request( # pylint: disable=name-too-long + asc_location: str, task_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", "2015-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "taskName": _SERIALIZER.url("task_name", task_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_update_subscription_level_task_state_request( # pylint: disable=name-too-long + asc_location: str, + task_name: str, + task_update_action_type: Union[str, _models.TaskUpdateActionType], + 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", "2015-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "taskName": _SERIALIZER.url("task_name", task_name, "str"), + "taskUpdateActionType": _SERIALIZER.url("task_update_action_type", task_update_action_type, "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_list_by_resource_group_request( + resource_group_name: str, asc_location: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_resource_group_level_task_request( # pylint: disable=name-too-long + resource_group_name: str, asc_location: str, task_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", "2015-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "taskName": _SERIALIZER.url("task_name", task_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_update_resource_group_level_task_state_request( # pylint: disable=name-too-long + resource_group_name: str, + asc_location: str, + task_name: str, + task_update_action_type: Union[str, _models.TaskUpdateActionType], + 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", "2015-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "taskName": _SERIALIZER.url("task_name", task_name, "str"), + "taskUpdateActionType": _SERIALIZER.url("task_update_action_type", task_update_action_type, "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) + + +class TasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`tasks` 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: SecurityCenterConfiguration = 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, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.SecurityTask"]: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either SecurityTask or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityTask] + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTaskList] = 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( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityTaskList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region( + self, asc_location: str, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.SecurityTask"]: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either SecurityTask or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityTask] + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTaskList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityTaskList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_subscription_level_task(self, asc_location: str, task_name: str, **kwargs: Any) -> _models.SecurityTask: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param task_name: Name of the task object, will be a GUID. Required. + :type task_name: str + :return: SecurityTask or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityTask + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) + + _request = build_get_subscription_level_task_request( + asc_location=asc_location, + task_name=task_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityTask", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def update_subscription_level_task_state( # pylint: disable=inconsistent-return-statements + self, + asc_location: str, + task_name: str, + task_update_action_type: Union[str, _models.TaskUpdateActionType], + **kwargs: Any + ) -> None: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param task_name: Name of the task object, will be a GUID. Required. + :type task_name: str + :param task_update_action_type: Type of the action to do on the task. Known values are: + "Activate", "Dismiss", "Start", "Resolve", and "Close". Required. + :type task_update_action_type: str or ~azure.mgmt.security.models.TaskUpdateActionType + :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", "2015-06-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_subscription_level_task_state_request( + asc_location=asc_location, + task_name=task_name, + task_update_action_type=task_update_action_type, + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, asc_location: str, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.SecurityTask"]: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param filter: OData filter. Optional. Default value is None. + :type filter: str + :return: An iterator like instance of either SecurityTask or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityTask] + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTaskList] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityTaskList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_resource_group_level_task( + self, resource_group_name: str, asc_location: str, task_name: str, **kwargs: Any + ) -> _models.SecurityTask: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param task_name: Name of the task object, will be a GUID. Required. + :type task_name: str + :return: SecurityTask or the result of cls(response) + :rtype: ~azure.mgmt.security.models.SecurityTask + :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", "2015-06-01-preview")) + cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) + + _request = build_get_resource_group_level_task_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + task_name=task_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityTask", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def update_resource_group_level_task_state( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + asc_location: str, + task_name: str, + task_update_action_type: Union[str, _models.TaskUpdateActionType], + **kwargs: Any + ) -> None: + """Recommended tasks that will help improve the security of the subscription proactively. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param task_name: Name of the task object, will be a GUID. Required. + :type task_name: str + :param task_update_action_type: Type of the action to do on the task. Known values are: + "Activate", "Dismiss", "Start", "Resolve", and "Close". Required. + :type task_update_action_type: str or ~azure.mgmt.security.models.TaskUpdateActionType + :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", "2015-06-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_update_resource_group_level_task_state_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + task_name=task_name, + task_update_action_type=task_update_action_type, + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_topology_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_topology_operations.py new file mode 100644 index 000000000000..2e30118732c3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_topology_operations.py @@ -0,0 +1,339 @@ +# 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.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 SecurityCenterConfiguration +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(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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/topologies") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/topologies", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( + resource_group_name: str, asc_location: str, topology_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", "2020-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/topologies/{topologyResourceName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), + "topologyResourceName": _SERIALIZER.url("topology_resource_name", topology_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) + + +class TopologyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`topology` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.TopologyResource"]: + """Gets a list that allows to build a topology view of a subscription. + + :return: An iterator like instance of either TopologyResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.TopologyResource] + :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", "2020-01-01")) + cls: ClsType[_models.TopologyList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TopologyList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_home_region(self, asc_location: str, **kwargs: Any) -> ItemPaged["_models.TopologyResource"]: + """Gets a list that allows to build a topology view of a subscription and location. + + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :return: An iterator like instance of either TopologyResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.TopologyResource] + :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", "2020-01-01")) + cls: ClsType[_models.TopologyList] = 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_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TopologyList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, asc_location: str, topology_resource_name: str, **kwargs: Any + ) -> _models.TopologyResource: + """Gets a specific topology component. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param asc_location: The location where ASC stores the data of the subscription. can be + retrieved from Get locations. Required. + :type asc_location: str + :param topology_resource_name: Name of a topology resources collection. Required. + :type topology_resource_name: str + :return: TopologyResource or the result of cls(response) + :rtype: ~azure.mgmt.security.models.TopologyResource + :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", "2020-01-01")) + cls: ClsType[_models.TopologyResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + topology_resource_name=topology_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TopologyResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_workspace_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_workspace_settings_operations.py new file mode 100644 index 000000000000..f661fdc6694a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_workspace_settings_operations.py @@ -0,0 +1,602 @@ +# 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 + +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 SecurityCenterConfiguration +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(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", "2017-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(workspace_setting_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", "2017-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request(workspace_setting_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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(workspace_setting_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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(workspace_setting_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", "2017-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.SecurityCenter`'s + :attr:`workspace_settings` 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: SecurityCenterConfiguration = 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, **kwargs: Any) -> ItemPaged["_models.WorkspaceSetting"]: + """Settings about where we should store your security data and logs. If the result is empty, it + means that no custom-workspace configuration was set. + + :return: An iterator like instance of either WorkspaceSetting or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.WorkspaceSetting] + :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", "2017-08-01-preview")) + cls: ClsType[_models.WorkspaceSettingList] = 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( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WorkspaceSettingList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, workspace_setting_name: str, **kwargs: Any) -> _models.WorkspaceSetting: + """Settings about where we should store your security data and logs. If the result is empty, it + means that no custom-workspace configuration was set. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :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", "2017-08-01-preview")) + cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkspaceSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + workspace_setting_name: str, + workspace_setting: _models.WorkspaceSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceSetting: + """creating settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Required. + :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + workspace_setting_name: str, + workspace_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceSetting: + """creating settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Required. + :type workspace_setting: 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: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, workspace_setting_name: str, workspace_setting: Union[_models.WorkspaceSetting, IO[bytes]], **kwargs: Any + ) -> _models.WorkspaceSetting: + """creating settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Is either a WorkspaceSetting type or a + IO[bytes] type. Required. + :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting or IO[bytes] + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_setting, (IOBase, bytes)): + _content = workspace_setting + else: + _json = self._serialize.body(workspace_setting, "WorkspaceSetting") + + _request = build_create_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkspaceSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + workspace_setting_name: str, + workspace_setting: _models.WorkspaceSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceSetting: + """Settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Required. + :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + workspace_setting_name: str, + workspace_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceSetting: + """Settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Required. + :type workspace_setting: 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: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, workspace_setting_name: str, workspace_setting: Union[_models.WorkspaceSetting, IO[bytes]], **kwargs: Any + ) -> _models.WorkspaceSetting: + """Settings about where we should store your security data and logs. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_name: str + :param workspace_setting: Security data setting object. Is either a WorkspaceSetting type or a + IO[bytes] type. Required. + :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting or IO[bytes] + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.models.WorkspaceSetting + :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", "2017-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_setting, (IOBase, bytes)): + _content = workspace_setting + else: + _json = self._serialize.body(workspace_setting, "WorkspaceSetting") + + _request = build_update_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkspaceSetting", 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, workspace_setting_name: str, **kwargs: Any + ) -> None: + """Deletes the custom workspace settings for this subscription. new VMs will report to the default + workspace. + + :param workspace_setting_name: Name of the security setting. Required. + :type workspace_setting_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", "2017-08-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + workspace_setting_name=workspace_setting_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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_configuration.py deleted file mode 100644 index 9f608d149419..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2015-06-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_metadata.json deleted file mode 100644 index 3d6f68e3fc51..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2015-06-01-preview", - "total_api_version_list": ["2015-06-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "locations": "LocationsOperations", - "operations": "Operations", - "tasks": "TasksOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_security_center.py deleted file mode 100644 index 44e7188ee52a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_security_center.py +++ /dev/null @@ -1,119 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import LocationsOperations, Operations, TasksOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar locations: LocationsOperations operations - :vartype locations: azure.mgmt.security.v2015_06_01_preview.operations.LocationsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.security.v2015_06_01_preview.operations.Operations - :ivar tasks: TasksOperations operations - :vartype tasks: azure.mgmt.security.v2015_06_01_preview.operations.TasksOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" - ) - self.tasks = TasksOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_configuration.py deleted file mode 100644 index e4aec7cd12f2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2015-06-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_security_center.py deleted file mode 100644 index fc3c83b06f67..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_security_center.py +++ /dev/null @@ -1,121 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import LocationsOperations, Operations, TasksOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar locations: LocationsOperations operations - :vartype locations: azure.mgmt.security.v2015_06_01_preview.aio.operations.LocationsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.security.v2015_06_01_preview.aio.operations.Operations - :ivar tasks: TasksOperations operations - :vartype tasks: azure.mgmt.security.v2015_06_01_preview.aio.operations.TasksOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" - ) - self.tasks = TasksOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/__init__.py deleted file mode 100644 index 8e1c2e52e196..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._locations_operations import LocationsOperations -from ._operations import Operations -from ._tasks_operations import TasksOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "LocationsOperations", - "Operations", - "TasksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_locations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_locations_operations.py deleted file mode 100644 index a0c934299dbe..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_locations_operations.py +++ /dev/null @@ -1,196 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._locations_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class LocationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2015_06_01_preview.aio.SecurityCenter`'s - :attr:`locations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.AscLocation"]: - """The location of the responsible ASC of the specific subscription (home region). For each - subscription there is only one responsible location. The location in the response should be - used to read or write other resources in ASC according to their ID. - - :return: An iterator like instance of either AscLocation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.AscLocation] - :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._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.AscLocationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AscLocationList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, asc_location: str, **kwargs: Any) -> _models.AscLocation: - """Details of a specific location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: AscLocation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2015_06_01_preview.models.AscLocation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.AscLocation] = kwargs.pop("cls", None) - - _request = build_get_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AscLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_operations.py deleted file mode 100644 index 3f7df101e850..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2015_06_01_preview.aio.SecurityCenter`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Exposes all available operations for discovery purposes. - - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_tasks_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_tasks_operations.py deleted file mode 100644 index 9af26e4cb888..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_tasks_operations.py +++ /dev/null @@ -1,589 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._tasks_operations import ( - build_get_resource_group_level_task_request, - build_get_subscription_level_task_request, - build_list_by_home_region_request, - build_list_by_resource_group_request, - build_list_request, - build_update_resource_group_level_task_state_request, - build_update_subscription_level_task_state_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TasksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2015_06_01_preview.aio.SecurityCenter`'s - :attr:`tasks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.SecurityTask"]: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either SecurityTask or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask] - :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._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityTaskList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region( - self, asc_location: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SecurityTask"]: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either SecurityTask or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask] - :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._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityTaskList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_subscription_level_task( - self, asc_location: str, task_name: str, **kwargs: Any - ) -> _models.SecurityTask: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param task_name: Name of the task object, will be a GUID. Required. - :type task_name: str - :return: SecurityTask or the result of cls(response) - :rtype: ~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) - - _request = build_get_subscription_level_task_request( - asc_location=asc_location, - task_name=task_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityTask", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def update_subscription_level_task_state( # pylint: disable=inconsistent-return-statements - self, - asc_location: str, - task_name: str, - task_update_action_type: Union[str, _models.TaskUpdateActionType], - **kwargs: Any - ) -> None: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param task_name: Name of the task object, will be a GUID. Required. - :type task_name: str - :param task_update_action_type: Type of the action to do on the task. Known values are: - "Activate", "Dismiss", "Start", "Resolve", and "Close". Required. - :type task_update_action_type: str or - ~azure.mgmt.security.v2015_06_01_preview.models.TaskUpdateActionType - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_task_state_request( - asc_location=asc_location, - task_name=task_name, - task_update_action_type=task_update_action_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, asc_location: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SecurityTask"]: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either SecurityTask or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask] - :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._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityTaskList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_resource_group_level_task( - self, resource_group_name: str, asc_location: str, task_name: str, **kwargs: Any - ) -> _models.SecurityTask: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param task_name: Name of the task object, will be a GUID. Required. - :type task_name: str - :return: SecurityTask or the result of cls(response) - :rtype: ~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) - - _request = build_get_resource_group_level_task_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - task_name=task_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityTask", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def update_resource_group_level_task_state( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - asc_location: str, - task_name: str, - task_update_action_type: Union[str, _models.TaskUpdateActionType], - **kwargs: Any - ) -> None: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param task_name: Name of the task object, will be a GUID. Required. - :type task_name: str - :param task_update_action_type: Type of the action to do on the task. Known values are: - "Activate", "Dismiss", "Start", "Resolve", and "Close". Required. - :type task_update_action_type: str or - ~azure.mgmt.security.v2015_06_01_preview.models.TaskUpdateActionType - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_task_state_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - task_name=task_name, - task_update_action_type=task_update_action_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/__init__.py deleted file mode 100644 index 66eeb1a94bdd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/__init__.py +++ /dev/null @@ -1,41 +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 ._models_py3 import AscLocation -from ._models_py3 import AscLocationList -from ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationList -from ._models_py3 import Resource -from ._models_py3 import SecurityTask -from ._models_py3 import SecurityTaskList -from ._models_py3 import SecurityTaskParameters - -from ._security_center_enums import TaskUpdateActionType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AscLocation", - "AscLocationList", - "CloudErrorBody", - "ErrorAdditionalInfo", - "Operation", - "OperationDisplay", - "OperationList", - "Resource", - "SecurityTask", - "SecurityTaskList", - "SecurityTaskParameters", - "TaskUpdateActionType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_models_py3.py deleted file mode 100644 index d44f89cb8219..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_models_py3.py +++ /dev/null @@ -1,419 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AscLocation(Resource): - """The ASC location of the subscription is in the "name" field. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: An empty set of properties. - :vartype properties: JSON - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "object"}, - } - - def __init__(self, *, properties: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword properties: An empty set of properties. - :paramtype properties: JSON - """ - super().__init__(**kwargs) - self.properties = properties - - -class AscLocationList(_serialization.Model): - """List of locations where ASC saves your data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2015_06_01_preview.models.AscLocation] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AscLocation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class CloudErrorBody(_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.security.v2015_06_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2015_06_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class Operation(_serialization.Model): - """Possible operation in the REST API of Microsoft.Security. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the operation. - :vartype name: str - :ivar origin: Where the operation is originated. - :vartype origin: str - :ivar display: Security operation display. - :vartype display: ~azure.mgmt.security.v2015_06_01_preview.models.OperationDisplay - """ - - _validation = { - "name": {"readonly": True}, - "origin": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "origin": {"key": "origin", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Security operation display. - :paramtype display: ~azure.mgmt.security.v2015_06_01_preview.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.origin = None - self.display = display - - -class OperationDisplay(_serialization.Model): - """Security operation display. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The resource provider for the operation. - :vartype provider: str - :ivar resource: The display name of the resource the operation applies to. - :vartype resource: str - :ivar operation: The display name of the security operation. - :vartype operation: str - :ivar description: The description of the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationList(_serialization.Model): - """List of possible operations for Microsoft.Security resource provider. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of Security operations. - :vartype value: list[~azure.mgmt.security.v2015_06_01_preview.models.Operation] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of Security operations. - :paramtype value: list[~azure.mgmt.security.v2015_06_01_preview.models.Operation] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class SecurityTask(Resource): - """Security task that we recommend to do in order to strengthen security. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar state: State of the task (Active, Resolved etc.). - :vartype state: str - :ivar creation_time_utc: The time this task was discovered in UTC. - :vartype creation_time_utc: ~datetime.datetime - :ivar security_task_parameters: Changing set of properties, depending on the task type that is - derived from the name field. - :vartype security_task_parameters: - ~azure.mgmt.security.v2015_06_01_preview.models.SecurityTaskParameters - :ivar last_state_change_time_utc: The time this task's details were last changed in UTC. - :vartype last_state_change_time_utc: ~datetime.datetime - :ivar sub_state: Additional data on the state of the task. - :vartype sub_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "state": {"readonly": True}, - "creation_time_utc": {"readonly": True}, - "last_state_change_time_utc": {"readonly": True}, - "sub_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "creation_time_utc": {"key": "properties.creationTimeUtc", "type": "iso-8601"}, - "security_task_parameters": {"key": "properties.securityTaskParameters", "type": "SecurityTaskParameters"}, - "last_state_change_time_utc": {"key": "properties.lastStateChangeTimeUtc", "type": "iso-8601"}, - "sub_state": {"key": "properties.subState", "type": "str"}, - } - - def __init__( - self, *, security_task_parameters: Optional["_models.SecurityTaskParameters"] = None, **kwargs: Any - ) -> None: - """ - :keyword security_task_parameters: Changing set of properties, depending on the task type that - is derived from the name field. - :paramtype security_task_parameters: - ~azure.mgmt.security.v2015_06_01_preview.models.SecurityTaskParameters - """ - super().__init__(**kwargs) - self.state = None - self.creation_time_utc = None - self.security_task_parameters = security_task_parameters - self.last_state_change_time_utc = None - self.sub_state = None - - -class SecurityTaskList(_serialization.Model): - """List of security task recommendations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityTask]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityTaskParameters(_serialization.Model): - """Changing set of properties, depending on the task type that is derived from the name field. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar name: Name of the task type. - :vartype name: str - """ - - _validation = { - "name": {"readonly": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, additional_properties: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.name = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_security_center_enums.py deleted file mode 100644 index 1233c7c1c800..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,20 +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 TaskUpdateActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """TaskUpdateActionType.""" - - ACTIVATE = "Activate" - DISMISS = "Dismiss" - START = "Start" - RESOLVE = "Resolve" - CLOSE = "Close" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/__init__.py deleted file mode 100644 index 8e1c2e52e196..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._locations_operations import LocationsOperations -from ._operations import Operations -from ._tasks_operations import TasksOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "LocationsOperations", - "Operations", - "TasksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_locations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_locations_operations.py deleted file mode 100644 index 74a717113d83..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_locations_operations.py +++ /dev/null @@ -1,253 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(asc_location: 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", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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) - - -class LocationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2015_06_01_preview.SecurityCenter`'s - :attr:`locations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.AscLocation"]: - """The location of the responsible ASC of the specific subscription (home region). For each - subscription there is only one responsible location. The location in the response should be - used to read or write other resources in ASC according to their ID. - - :return: An iterator like instance of either AscLocation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.AscLocation] - :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._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.AscLocationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AscLocationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, asc_location: str, **kwargs: Any) -> _models.AscLocation: - """Details of a specific location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: AscLocation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2015_06_01_preview.models.AscLocation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.AscLocation] = kwargs.pop("cls", None) - - _request = build_get_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AscLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_operations.py deleted file mode 100644 index e222fbae6559..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_operations.py +++ /dev/null @@ -1,158 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**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", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Security/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2015_06_01_preview.SecurityCenter`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Exposes all available operations for discovery purposes. - - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OperationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_tasks_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_tasks_operations.py deleted file mode 100644 index b5bd0c828ec4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_tasks_operations.py +++ /dev/null @@ -1,828 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/tasks") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_home_region_request( - asc_location: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_subscription_level_task_request( # pylint: disable=name-too-long - asc_location: str, task_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", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "taskName": _SERIALIZER.url("task_name", task_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_update_subscription_level_task_state_request( # pylint: disable=name-too-long - asc_location: str, - task_name: str, - task_update_action_type: Union[str, _models.TaskUpdateActionType], - 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", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "taskName": _SERIALIZER.url("task_name", task_name, "str"), - "taskUpdateActionType": _SERIALIZER.url("task_update_action_type", task_update_action_type, "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_list_by_resource_group_request( - resource_group_name: str, asc_location: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_resource_group_level_task_request( # pylint: disable=name-too-long - resource_group_name: str, asc_location: str, task_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", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "taskName": _SERIALIZER.url("task_name", task_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_update_resource_group_level_task_state_request( # pylint: disable=name-too-long - resource_group_name: str, - asc_location: str, - task_name: str, - task_update_action_type: Union[str, _models.TaskUpdateActionType], - 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", "2015-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "taskName": _SERIALIZER.url("task_name", task_name, "str"), - "taskUpdateActionType": _SERIALIZER.url("task_update_action_type", task_update_action_type, "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) - - -class TasksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2015_06_01_preview.SecurityCenter`'s - :attr:`tasks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.SecurityTask"]: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either SecurityTask or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask] - :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._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityTaskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region( - self, asc_location: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SecurityTask"]: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either SecurityTask or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask] - :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._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityTaskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_subscription_level_task(self, asc_location: str, task_name: str, **kwargs: Any) -> _models.SecurityTask: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param task_name: Name of the task object, will be a GUID. Required. - :type task_name: str - :return: SecurityTask or the result of cls(response) - :rtype: ~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) - - _request = build_get_subscription_level_task_request( - asc_location=asc_location, - task_name=task_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityTask", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def update_subscription_level_task_state( # pylint: disable=inconsistent-return-statements - self, - asc_location: str, - task_name: str, - task_update_action_type: Union[str, _models.TaskUpdateActionType], - **kwargs: Any - ) -> None: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param task_name: Name of the task object, will be a GUID. Required. - :type task_name: str - :param task_update_action_type: Type of the action to do on the task. Known values are: - "Activate", "Dismiss", "Start", "Resolve", and "Close". Required. - :type task_update_action_type: str or - ~azure.mgmt.security.v2015_06_01_preview.models.TaskUpdateActionType - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_task_state_request( - asc_location=asc_location, - task_name=task_name, - task_update_action_type=task_update_action_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, asc_location: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SecurityTask"]: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either SecurityTask or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask] - :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._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityTaskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_resource_group_level_task( - self, resource_group_name: str, asc_location: str, task_name: str, **kwargs: Any - ) -> _models.SecurityTask: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param task_name: Name of the task object, will be a GUID. Required. - :type task_name: str - :return: SecurityTask or the result of cls(response) - :rtype: ~azure.mgmt.security.v2015_06_01_preview.models.SecurityTask - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) - - _request = build_get_resource_group_level_task_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - task_name=task_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityTask", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def update_resource_group_level_task_state( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - asc_location: str, - task_name: str, - task_update_action_type: Union[str, _models.TaskUpdateActionType], - **kwargs: Any - ) -> None: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param task_name: Name of the task object, will be a GUID. Required. - :type task_name: str - :param task_update_action_type: Type of the action to do on the task. Known values are: - "Activate", "Dismiss", "Start", "Resolve", and "Close". Required. - :type task_update_action_type: str or - ~azure.mgmt.security.v2015_06_01_preview.models.TaskUpdateActionType - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_task_state_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - task_name=task_name, - task_update_action_type=task_update_action_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_configuration.py deleted file mode 100644 index 0395ad5ead06..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2017-08-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2017-08-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_metadata.json deleted file mode 100644 index 1c216d71524c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2017-08-01", - "total_api_version_list": ["2017-08-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "compliance_results": "ComplianceResultsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_security_center.py deleted file mode 100644 index 3f4156e5140c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_security_center.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ComplianceResultsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar compliance_results: ComplianceResultsOperations operations - :vartype compliance_results: - azure.mgmt.security.v2017_08_01.operations.ComplianceResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-08-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.compliance_results = ComplianceResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_configuration.py deleted file mode 100644 index 5bcc46819079..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2017-08-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2017-08-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_security_center.py deleted file mode 100644 index 3875631b52e3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_security_center.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ComplianceResultsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar compliance_results: ComplianceResultsOperations operations - :vartype compliance_results: - azure.mgmt.security.v2017_08_01.aio.operations.ComplianceResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-08-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.compliance_results = ComplianceResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/__init__.py deleted file mode 100644 index 7cfcb2ac627d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._compliance_results_operations import ComplianceResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComplianceResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_compliance_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_compliance_results_operations.py deleted file mode 100644 index 662e7ffd3028..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_compliance_results_operations.py +++ /dev/null @@ -1,195 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._compliance_results_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ComplianceResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01.aio.SecurityCenter`'s - :attr:`compliance_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.ComplianceResult"]: - """Security compliance results in the subscription. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either ComplianceResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2017_08_01.models.ComplianceResult] - :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._api_version or "2017-08-01")) - cls: ClsType[_models.ComplianceResultList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ComplianceResultList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_id: str, compliance_result_name: str, **kwargs: Any) -> _models.ComplianceResult: - """Security Compliance Result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param compliance_result_name: name of the desired assessment compliance result. Required. - :type compliance_result_name: str - :return: ComplianceResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01.models.ComplianceResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-08-01")) - cls: ClsType[_models.ComplianceResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - compliance_result_name=compliance_result_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ComplianceResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/__init__.py deleted file mode 100644 index 1303df6fb8f4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/__init__.py +++ /dev/null @@ -1,29 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import ComplianceResult -from ._models_py3 import ComplianceResultList -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Resource - -from ._security_center_enums import ResourceStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "ComplianceResult", - "ComplianceResultList", - "ErrorAdditionalInfo", - "Resource", - "ResourceStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_models_py3.py deleted file mode 100644 index 387b12dfe892..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_models_py3.py +++ /dev/null @@ -1,189 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CloudErrorBody(_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.security.v2017_08_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2017_08_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ComplianceResult(Resource): - """a compliance result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar resource_status: The status of the resource regarding a single assessment. Known values - are: "Healthy", "NotApplicable", "OffByPolicy", and "NotHealthy". - :vartype resource_status: str or ~azure.mgmt.security.v2017_08_01.models.ResourceStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "resource_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "resource_status": {"key": "properties.resourceStatus", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_status = None - - -class ComplianceResultList(_serialization.Model): - """List of compliance results response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: List of compliance results. Required. - :vartype value: list[~azure.mgmt.security.v2017_08_01.models.ComplianceResult] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ComplianceResult]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.ComplianceResult"], **kwargs: Any) -> None: - """ - :keyword value: List of compliance results. Required. - :paramtype value: list[~azure.mgmt.security.v2017_08_01.models.ComplianceResult] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_security_center_enums.py deleted file mode 100644 index 06b060062754..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_security_center_enums.py +++ /dev/null @@ -1,23 +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 ResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the resource regarding a single assessment.""" - - HEALTHY = "Healthy" - """This assessment on the resource is healthy""" - NOT_APPLICABLE = "NotApplicable" - """This assessment is not applicable to this resource""" - OFF_BY_POLICY = "OffByPolicy" - """This assessment is turned off by policy on this subscription""" - NOT_HEALTHY = "NotHealthy" - """This assessment on the resource is not healthy""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/__init__.py deleted file mode 100644 index 7cfcb2ac627d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._compliance_results_operations import ComplianceResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComplianceResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_compliance_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_compliance_results_operations.py deleted file mode 100644 index 4bb1b65ebcc2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_compliance_results_operations.py +++ /dev/null @@ -1,247 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/complianceResults") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_id: str, compliance_result_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/complianceResults/{complianceResultName}" - ) - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "complianceResultName": _SERIALIZER.url("compliance_result_name", compliance_result_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) - - -class ComplianceResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01.SecurityCenter`'s - :attr:`compliance_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> Iterable["_models.ComplianceResult"]: - """Security compliance results in the subscription. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either ComplianceResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2017_08_01.models.ComplianceResult] - :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._api_version or "2017-08-01")) - cls: ClsType[_models.ComplianceResultList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ComplianceResultList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_id: str, compliance_result_name: str, **kwargs: Any) -> _models.ComplianceResult: - """Security Compliance Result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param compliance_result_name: name of the desired assessment compliance result. Required. - :type compliance_result_name: str - :return: ComplianceResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01.models.ComplianceResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-08-01")) - cls: ClsType[_models.ComplianceResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - compliance_result_name=compliance_result_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ComplianceResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_configuration.py deleted file mode 100644 index 3410148ef841..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-08-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", "2017-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_metadata.json deleted file mode 100644 index 733248692d31..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2017-08-01-preview", - "total_api_version_list": ["2017-08-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "auto_provisioning_settings": "AutoProvisioningSettingsOperations", - "compliances": "CompliancesOperations", - "information_protection_policies": "InformationProtectionPoliciesOperations", - "security_contacts": "SecurityContactsOperations", - "workspace_settings": "WorkspaceSettingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_security_center.py deleted file mode 100644 index 5fe4cb43ffe1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_security_center.py +++ /dev/null @@ -1,139 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AutoProvisioningSettingsOperations, - CompliancesOperations, - InformationProtectionPoliciesOperations, - SecurityContactsOperations, - WorkspaceSettingsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar auto_provisioning_settings: AutoProvisioningSettingsOperations operations - :vartype auto_provisioning_settings: - azure.mgmt.security.v2017_08_01_preview.operations.AutoProvisioningSettingsOperations - :ivar compliances: CompliancesOperations operations - :vartype compliances: azure.mgmt.security.v2017_08_01_preview.operations.CompliancesOperations - :ivar information_protection_policies: InformationProtectionPoliciesOperations operations - :vartype information_protection_policies: - azure.mgmt.security.v2017_08_01_preview.operations.InformationProtectionPoliciesOperations - :ivar security_contacts: SecurityContactsOperations operations - :vartype security_contacts: - azure.mgmt.security.v2017_08_01_preview.operations.SecurityContactsOperations - :ivar workspace_settings: WorkspaceSettingsOperations operations - :vartype workspace_settings: - azure.mgmt.security.v2017_08_01_preview.operations.WorkspaceSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-08-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.auto_provisioning_settings = AutoProvisioningSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - self.compliances = CompliancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - self.information_protection_policies = InformationProtectionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - self.security_contacts = SecurityContactsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - self.workspace_settings = WorkspaceSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_configuration.py deleted file mode 100644 index 3ee3b681d9d3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-08-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", "2017-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_security_center.py deleted file mode 100644 index beaf99ad432d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_security_center.py +++ /dev/null @@ -1,142 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AutoProvisioningSettingsOperations, - CompliancesOperations, - InformationProtectionPoliciesOperations, - SecurityContactsOperations, - WorkspaceSettingsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar auto_provisioning_settings: AutoProvisioningSettingsOperations operations - :vartype auto_provisioning_settings: - azure.mgmt.security.v2017_08_01_preview.aio.operations.AutoProvisioningSettingsOperations - :ivar compliances: CompliancesOperations operations - :vartype compliances: - azure.mgmt.security.v2017_08_01_preview.aio.operations.CompliancesOperations - :ivar information_protection_policies: InformationProtectionPoliciesOperations operations - :vartype information_protection_policies: - azure.mgmt.security.v2017_08_01_preview.aio.operations.InformationProtectionPoliciesOperations - :ivar security_contacts: SecurityContactsOperations operations - :vartype security_contacts: - azure.mgmt.security.v2017_08_01_preview.aio.operations.SecurityContactsOperations - :ivar workspace_settings: WorkspaceSettingsOperations operations - :vartype workspace_settings: - azure.mgmt.security.v2017_08_01_preview.aio.operations.WorkspaceSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-08-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.auto_provisioning_settings = AutoProvisioningSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - self.compliances = CompliancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - self.information_protection_policies = InformationProtectionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - self.security_contacts = SecurityContactsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - self.workspace_settings = WorkspaceSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/__init__.py deleted file mode 100644 index a09258020a82..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,27 +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 ._auto_provisioning_settings_operations import AutoProvisioningSettingsOperations -from ._compliances_operations import CompliancesOperations -from ._information_protection_policies_operations import InformationProtectionPoliciesOperations -from ._security_contacts_operations import SecurityContactsOperations -from ._workspace_settings_operations import WorkspaceSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AutoProvisioningSettingsOperations", - "CompliancesOperations", - "InformationProtectionPoliciesOperations", - "SecurityContactsOperations", - "WorkspaceSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_auto_provisioning_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_auto_provisioning_settings_operations.py deleted file mode 100644 index 7af435870697..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_auto_provisioning_settings_operations.py +++ /dev/null @@ -1,312 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._auto_provisioning_settings_operations import ( - build_create_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AutoProvisioningSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.aio.SecurityCenter`'s - :attr:`auto_provisioning_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.AutoProvisioningSetting"]: - """Exposes the auto provisioning settings of the subscriptions. - - :return: An iterator like instance of either AutoProvisioningSetting or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.AutoProvisioningSettingList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AutoProvisioningSettingList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, setting_name: str, **kwargs: Any) -> _models.AutoProvisioningSetting: - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. Required. - :type setting_name: str - :return: AutoProvisioningSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoProvisioningSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - setting_name: str, - setting: _models.AutoProvisioningSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoProvisioningSetting: - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. Required. - :type setting_name: str - :param setting: Auto provisioning setting key. Required. - :type setting: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AutoProvisioningSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, setting_name: str, setting: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AutoProvisioningSetting: - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. Required. - :type setting_name: str - :param setting: Auto provisioning setting key. Required. - :type setting: 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: AutoProvisioningSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, setting_name: str, setting: Union[_models.AutoProvisioningSetting, IO[bytes]], **kwargs: Any - ) -> _models.AutoProvisioningSetting: - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. Required. - :type setting_name: str - :param setting: Auto provisioning setting key. Is either a AutoProvisioningSetting type or a - IO[bytes] type. Required. - :type setting: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting or - IO[bytes] - :return: AutoProvisioningSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(setting, (IOBase, bytes)): - _content = setting - else: - _json = self._serialize.body(setting, "AutoProvisioningSetting") - - _request = build_create_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoProvisioningSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_compliances_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_compliances_operations.py deleted file mode 100644 index 72178e77a83d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_compliances_operations.py +++ /dev/null @@ -1,201 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._compliances_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CompliancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.aio.SecurityCenter`'s - :attr:`compliances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Compliance"]: - """The Compliance scores of the specific management group. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either Compliance or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.Compliance] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.ComplianceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ComplianceList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, scope: str, compliance_name: str, **kwargs: Any) -> _models.Compliance: - """Details of a specific Compliance. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param compliance_name: name of the Compliance. Required. - :type compliance_name: str - :return: Compliance or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.Compliance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.Compliance] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - compliance_name=compliance_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Compliance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_information_protection_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_information_protection_policies_operations.py deleted file mode 100644 index c48dfcddb8d0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_information_protection_policies_operations.py +++ /dev/null @@ -1,361 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._information_protection_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class InformationProtectionPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.aio.SecurityCenter`'s - :attr:`information_protection_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, - scope: str, - information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], - **kwargs: Any - ) -> _models.InformationProtectionPolicy: - """Details of the information protection policy. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. Known - values are: "effective" and "custom". Required. - :type information_protection_policy_name: str or - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicyName - :return: InformationProtectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - information_protection_policy_name=information_protection_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - scope: str, - information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], - information_protection_policy: _models.InformationProtectionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.InformationProtectionPolicy: - """Details of the information protection policy. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. Known - values are: "effective" and "custom". Required. - :type information_protection_policy_name: str or - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicyName - :param information_protection_policy: Information protection policy. Required. - :type information_protection_policy: - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: InformationProtectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - scope: str, - information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], - information_protection_policy: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.InformationProtectionPolicy: - """Details of the information protection policy. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. Known - values are: "effective" and "custom". Required. - :type information_protection_policy_name: str or - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicyName - :param information_protection_policy: Information protection policy. Required. - :type information_protection_policy: 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: InformationProtectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - scope: str, - information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], - information_protection_policy: Union[_models.InformationProtectionPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.InformationProtectionPolicy: - """Details of the information protection policy. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. Known - values are: "effective" and "custom". Required. - :type information_protection_policy_name: str or - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicyName - :param information_protection_policy: Information protection policy. Is either a - InformationProtectionPolicy type or a IO[bytes] type. Required. - :type information_protection_policy: - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy or IO[bytes] - :return: InformationProtectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(information_protection_policy, (IOBase, bytes)): - _content = information_protection_policy - else: - _json = self._serialize.body(information_protection_policy, "InformationProtectionPolicy") - - _request = build_create_or_update_request( - scope=scope, - information_protection_policy_name=information_protection_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.InformationProtectionPolicy"]: - """Information protection policies of a specific management group. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either InformationProtectionPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.InformationProtectionPolicyList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("InformationProtectionPolicyList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_security_contacts_operations.py deleted file mode 100644 index 4a0948c6e4d7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_security_contacts_operations.py +++ /dev/null @@ -1,488 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_contacts_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityContactsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.aio.SecurityCenter`'s - :attr:`security_contacts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityContact"]: - """Security contact configurations for the subscription. - - :return: An iterator like instance of either SecurityContact or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.SecurityContactList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityContactList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, security_contact_name: str, **kwargs: Any) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - _request = build_get_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - security_contact_name: str, - security_contact: _models.SecurityContact, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - security_contact_name: str, - security_contact: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: 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: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, security_contact_name: str, security_contact: Union[_models.SecurityContact, IO[bytes]], **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Is either a SecurityContact type or a - IO[bytes] type. Required. - :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact or - IO[bytes] - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_contact, (IOBase, bytes)): - _content = security_contact - else: - _json = self._serialize.body(security_contact, "SecurityContact") - - _request = build_create_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, security_contact_name: str, **kwargs: Any - ) -> None: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def update( - self, - security_contact_name: str, - security_contact: _models.SecurityContact, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - security_contact_name: str, - security_contact: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: 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: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, security_contact_name: str, security_contact: Union[_models.SecurityContact, IO[bytes]], **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Is either a SecurityContact type or a - IO[bytes] type. Required. - :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact or - IO[bytes] - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_contact, (IOBase, bytes)): - _content = security_contact - else: - _json = self._serialize.body(security_contact, "SecurityContact") - - _request = build_update_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_workspace_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_workspace_settings_operations.py deleted file mode 100644 index 7dfb04538942..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_workspace_settings_operations.py +++ /dev/null @@ -1,491 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._workspace_settings_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WorkspaceSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.aio.SecurityCenter`'s - :attr:`workspace_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.WorkspaceSetting"]: - """Settings about where we should store your security data and logs. If the result is empty, it - means that no custom-workspace configuration was set. - - :return: An iterator like instance of either WorkspaceSetting or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.WorkspaceSettingList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("WorkspaceSettingList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, workspace_setting_name: str, **kwargs: Any) -> _models.WorkspaceSetting: - """Settings about where we should store your security data and logs. If the result is empty, it - means that no custom-workspace configuration was set. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - workspace_setting_name=workspace_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WorkspaceSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - workspace_setting_name: str, - workspace_setting: _models.WorkspaceSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WorkspaceSetting: - """creating settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Required. - :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - workspace_setting_name: str, - workspace_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WorkspaceSetting: - """creating settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Required. - :type workspace_setting: 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: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, workspace_setting_name: str, workspace_setting: Union[_models.WorkspaceSetting, IO[bytes]], **kwargs: Any - ) -> _models.WorkspaceSetting: - """creating settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Is either a WorkspaceSetting type or a - IO[bytes] type. Required. - :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting or - IO[bytes] - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(workspace_setting, (IOBase, bytes)): - _content = workspace_setting - else: - _json = self._serialize.body(workspace_setting, "WorkspaceSetting") - - _request = build_create_request( - workspace_setting_name=workspace_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WorkspaceSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - workspace_setting_name: str, - workspace_setting: _models.WorkspaceSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WorkspaceSetting: - """Settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Required. - :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - workspace_setting_name: str, - workspace_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WorkspaceSetting: - """Settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Required. - :type workspace_setting: 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: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, workspace_setting_name: str, workspace_setting: Union[_models.WorkspaceSetting, IO[bytes]], **kwargs: Any - ) -> _models.WorkspaceSetting: - """Settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Is either a WorkspaceSetting type or a - IO[bytes] type. Required. - :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting or - IO[bytes] - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(workspace_setting, (IOBase, bytes)): - _content = workspace_setting - else: - _json = self._serialize.body(workspace_setting, "WorkspaceSetting") - - _request = build_update_request( - workspace_setting_name=workspace_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WorkspaceSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, workspace_setting_name: str, **kwargs: Any - ) -> None: - """Deletes the custom workspace settings for this subscription. new VMs will report to the default - workspace. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - workspace_setting_name=workspace_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/__init__.py deleted file mode 100644 index d832d981d78d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/__init__.py +++ /dev/null @@ -1,61 +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 ._models_py3 import AutoProvisioningSetting -from ._models_py3 import AutoProvisioningSettingList -from ._models_py3 import CloudErrorBody -from ._models_py3 import Compliance -from ._models_py3 import ComplianceList -from ._models_py3 import ComplianceSegment -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import InformationProtectionKeyword -from ._models_py3 import InformationProtectionPolicy -from ._models_py3 import InformationProtectionPolicyList -from ._models_py3 import InformationType -from ._models_py3 import Resource -from ._models_py3 import SecurityContact -from ._models_py3 import SecurityContactList -from ._models_py3 import SensitivityLabel -from ._models_py3 import WorkspaceSetting -from ._models_py3 import WorkspaceSettingList - -from ._security_center_enums import AlertNotifications -from ._security_center_enums import AlertsToAdmins -from ._security_center_enums import AutoProvision -from ._security_center_enums import InformationProtectionPolicyName -from ._security_center_enums import Rank -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AutoProvisioningSetting", - "AutoProvisioningSettingList", - "CloudErrorBody", - "Compliance", - "ComplianceList", - "ComplianceSegment", - "ErrorAdditionalInfo", - "InformationProtectionKeyword", - "InformationProtectionPolicy", - "InformationProtectionPolicyList", - "InformationType", - "Resource", - "SecurityContact", - "SecurityContactList", - "SensitivityLabel", - "WorkspaceSetting", - "WorkspaceSettingList", - "AlertNotifications", - "AlertsToAdmins", - "AutoProvision", - "InformationProtectionPolicyName", - "Rank", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_models_py3.py deleted file mode 100644 index 81bdbb75a220..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_models_py3.py +++ /dev/null @@ -1,739 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AutoProvisioningSetting(Resource): - """Auto provisioning setting. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar auto_provision: Describes what kind of security agent provisioning action to take. Known - values are: "On" and "Off". - :vartype auto_provision: str or ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvision - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "auto_provision": {"key": "properties.autoProvision", "type": "str"}, - } - - def __init__(self, *, auto_provision: Optional[Union[str, "_models.AutoProvision"]] = None, **kwargs: Any) -> None: - """ - :keyword auto_provision: Describes what kind of security agent provisioning action to take. - Known values are: "On" and "Off". - :paramtype auto_provision: str or ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvision - """ - super().__init__(**kwargs) - self.auto_provision = auto_provision - - -class AutoProvisioningSettingList(_serialization.Model): - """List of all the auto provisioning settings response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of all the auto provisioning settings. - :vartype value: list[~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AutoProvisioningSetting]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.AutoProvisioningSetting"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of all the auto provisioning settings. - :paramtype value: list[~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class CloudErrorBody(_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.security.v2017_08_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2017_08_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Compliance(Resource): - """Compliance of a scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar assessment_timestamp_utc_date: The timestamp when the Compliance calculation was - conducted. - :vartype assessment_timestamp_utc_date: ~datetime.datetime - :ivar resource_count: The resource count of the given subscription for which the Compliance - calculation was conducted (needed for Management Group Compliance calculation). - :vartype resource_count: int - :ivar assessment_result: An array of segment, which is the actually the compliance assessment. - :vartype assessment_result: - list[~azure.mgmt.security.v2017_08_01_preview.models.ComplianceSegment] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "assessment_timestamp_utc_date": {"readonly": True}, - "resource_count": {"readonly": True}, - "assessment_result": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "assessment_timestamp_utc_date": {"key": "properties.assessmentTimestampUtcDate", "type": "iso-8601"}, - "resource_count": {"key": "properties.resourceCount", "type": "int"}, - "assessment_result": {"key": "properties.assessmentResult", "type": "[ComplianceSegment]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.assessment_timestamp_utc_date = None - self.resource_count = None - self.assessment_result = None - - -class ComplianceList(_serialization.Model): - """List of Compliance objects response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of Compliance objects. - :vartype value: list[~azure.mgmt.security.v2017_08_01_preview.models.Compliance] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Compliance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Compliance"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of Compliance objects. - :paramtype value: list[~azure.mgmt.security.v2017_08_01_preview.models.Compliance] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class ComplianceSegment(_serialization.Model): - """A segment of a compliance assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar segment_type: The segment type, e.g. compliant, non-compliance, insufficient coverage, - N/A, etc. - :vartype segment_type: str - :ivar percentage: The size (%) of the segment. - :vartype percentage: float - """ - - _validation = { - "segment_type": {"readonly": True}, - "percentage": {"readonly": True}, - } - - _attribute_map = { - "segment_type": {"key": "segmentType", "type": "str"}, - "percentage": {"key": "percentage", "type": "float"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.segment_type = None - self.percentage = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class InformationProtectionKeyword(_serialization.Model): - """The information type keyword. - - :ivar pattern: The keyword pattern. - :vartype pattern: str - :ivar custom: Indicates whether the keyword is custom or not. - :vartype custom: bool - :ivar can_be_numeric: Indicates whether the keyword can be applied on numeric types or not. - :vartype can_be_numeric: bool - :ivar excluded: Indicates whether the keyword is excluded or not. - :vartype excluded: bool - """ - - _attribute_map = { - "pattern": {"key": "pattern", "type": "str"}, - "custom": {"key": "custom", "type": "bool"}, - "can_be_numeric": {"key": "canBeNumeric", "type": "bool"}, - "excluded": {"key": "excluded", "type": "bool"}, - } - - def __init__( - self, - *, - pattern: Optional[str] = None, - custom: Optional[bool] = None, - can_be_numeric: Optional[bool] = None, - excluded: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword pattern: The keyword pattern. - :paramtype pattern: str - :keyword custom: Indicates whether the keyword is custom or not. - :paramtype custom: bool - :keyword can_be_numeric: Indicates whether the keyword can be applied on numeric types or not. - :paramtype can_be_numeric: bool - :keyword excluded: Indicates whether the keyword is excluded or not. - :paramtype excluded: bool - """ - super().__init__(**kwargs) - self.pattern = pattern - self.custom = custom - self.can_be_numeric = can_be_numeric - self.excluded = excluded - - -class InformationProtectionPolicy(Resource): - """Information protection policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar last_modified_utc: Describes the last UTC time the policy was modified. - :vartype last_modified_utc: ~datetime.datetime - :ivar version: Describes the version of the policy. - :vartype version: str - :ivar labels: Dictionary of sensitivity labels. - :vartype labels: dict[str, ~azure.mgmt.security.v2017_08_01_preview.models.SensitivityLabel] - :ivar information_types: The sensitivity information types. - :vartype information_types: dict[str, - ~azure.mgmt.security.v2017_08_01_preview.models.InformationType] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "last_modified_utc": {"readonly": True}, - "version": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "last_modified_utc": {"key": "properties.lastModifiedUtc", "type": "iso-8601"}, - "version": {"key": "properties.version", "type": "str"}, - "labels": {"key": "properties.labels", "type": "{SensitivityLabel}"}, - "information_types": {"key": "properties.informationTypes", "type": "{InformationType}"}, - } - - def __init__( - self, - *, - labels: Optional[Dict[str, "_models.SensitivityLabel"]] = None, - information_types: Optional[Dict[str, "_models.InformationType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword labels: Dictionary of sensitivity labels. - :paramtype labels: dict[str, ~azure.mgmt.security.v2017_08_01_preview.models.SensitivityLabel] - :keyword information_types: The sensitivity information types. - :paramtype information_types: dict[str, - ~azure.mgmt.security.v2017_08_01_preview.models.InformationType] - """ - super().__init__(**kwargs) - self.last_modified_utc = None - self.version = None - self.labels = labels - self.information_types = information_types - - -class InformationProtectionPolicyList(_serialization.Model): - """Information protection policies response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of information protection policies. - :vartype value: - list[~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[InformationProtectionPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.InformationProtectionPolicy"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of information protection policies. - :paramtype value: - list[~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class InformationType(_serialization.Model): - """The information type. - - :ivar display_name: The name of the information type. - :vartype display_name: str - :ivar description: The description of the information type. - :vartype description: str - :ivar order: The order of the information type. - :vartype order: int - :ivar recommended_label_id: The recommended label id to be associated with this information - type. - :vartype recommended_label_id: str - :ivar enabled: Indicates whether the information type is enabled or not. - :vartype enabled: bool - :ivar custom: Indicates whether the information type is custom or not. - :vartype custom: bool - :ivar keywords: The information type keywords. - :vartype keywords: - list[~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionKeyword] - """ - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "order": {"key": "order", "type": "int"}, - "recommended_label_id": {"key": "recommendedLabelId", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - "custom": {"key": "custom", "type": "bool"}, - "keywords": {"key": "keywords", "type": "[InformationProtectionKeyword]"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - order: Optional[int] = None, - recommended_label_id: Optional[str] = None, - enabled: Optional[bool] = None, - custom: Optional[bool] = None, - keywords: Optional[List["_models.InformationProtectionKeyword"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The name of the information type. - :paramtype display_name: str - :keyword description: The description of the information type. - :paramtype description: str - :keyword order: The order of the information type. - :paramtype order: int - :keyword recommended_label_id: The recommended label id to be associated with this information - type. - :paramtype recommended_label_id: str - :keyword enabled: Indicates whether the information type is enabled or not. - :paramtype enabled: bool - :keyword custom: Indicates whether the information type is custom or not. - :paramtype custom: bool - :keyword keywords: The information type keywords. - :paramtype keywords: - list[~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionKeyword] - """ - super().__init__(**kwargs) - self.display_name = display_name - self.description = description - self.order = order - self.recommended_label_id = recommended_label_id - self.enabled = enabled - self.custom = custom - self.keywords = keywords - - -class SecurityContact(Resource): - """Contact details for security issues. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar email: The email of this security contact. - :vartype email: str - :ivar phone: The phone number of this security contact. - :vartype phone: str - :ivar alert_notifications: Whether to send security alerts notifications to the security - contact. Known values are: "On" and "Off". - :vartype alert_notifications: str or - ~azure.mgmt.security.v2017_08_01_preview.models.AlertNotifications - :ivar alerts_to_admins: Whether to send security alerts notifications to subscription admins. - Known values are: "On" and "Off". - :vartype alerts_to_admins: str or - ~azure.mgmt.security.v2017_08_01_preview.models.AlertsToAdmins - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "email": {"key": "properties.email", "type": "str"}, - "phone": {"key": "properties.phone", "type": "str"}, - "alert_notifications": {"key": "properties.alertNotifications", "type": "str"}, - "alerts_to_admins": {"key": "properties.alertsToAdmins", "type": "str"}, - } - - def __init__( - self, - *, - email: Optional[str] = None, - phone: Optional[str] = None, - alert_notifications: Optional[Union[str, "_models.AlertNotifications"]] = None, - alerts_to_admins: Optional[Union[str, "_models.AlertsToAdmins"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword email: The email of this security contact. - :paramtype email: str - :keyword phone: The phone number of this security contact. - :paramtype phone: str - :keyword alert_notifications: Whether to send security alerts notifications to the security - contact. Known values are: "On" and "Off". - :paramtype alert_notifications: str or - ~azure.mgmt.security.v2017_08_01_preview.models.AlertNotifications - :keyword alerts_to_admins: Whether to send security alerts notifications to subscription - admins. Known values are: "On" and "Off". - :paramtype alerts_to_admins: str or - ~azure.mgmt.security.v2017_08_01_preview.models.AlertsToAdmins - """ - super().__init__(**kwargs) - self.email = email - self.phone = phone - self.alert_notifications = alert_notifications - self.alerts_to_admins = alerts_to_admins - - -class SecurityContactList(_serialization.Model): - """List of security contacts response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of security contacts. - :vartype value: list[~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityContact]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SensitivityLabel(_serialization.Model): - """The sensitivity label. - - :ivar display_name: The name of the sensitivity label. - :vartype display_name: str - :ivar description: The description of the sensitivity label. - :vartype description: str - :ivar rank: The rank of the sensitivity label. Known values are: "None", "Low", "Medium", - "High", and "Critical". - :vartype rank: str or ~azure.mgmt.security.v2017_08_01_preview.models.Rank - :ivar order: The order of the sensitivity label. - :vartype order: int - :ivar enabled: Indicates whether the label is enabled or not. - :vartype enabled: bool - """ - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "rank": {"key": "rank", "type": "str"}, - "order": {"key": "order", "type": "int"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - rank: Optional[Union[str, "_models.Rank"]] = None, - order: Optional[int] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The name of the sensitivity label. - :paramtype display_name: str - :keyword description: The description of the sensitivity label. - :paramtype description: str - :keyword rank: The rank of the sensitivity label. Known values are: "None", "Low", "Medium", - "High", and "Critical". - :paramtype rank: str or ~azure.mgmt.security.v2017_08_01_preview.models.Rank - :keyword order: The order of the sensitivity label. - :paramtype order: int - :keyword enabled: Indicates whether the label is enabled or not. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.display_name = display_name - self.description = description - self.rank = rank - self.order = order - self.enabled = enabled - - -class WorkspaceSetting(Resource): - """Configures where to store the OMS agent data for workspaces under a scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar workspace_id: The full Azure ID of the workspace to save the data in. - :vartype workspace_id: str - :ivar scope: All the VMs in this scope will send their security data to the mentioned workspace - unless overridden by a setting with more specific scope. - :vartype scope: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - } - - def __init__(self, *, workspace_id: Optional[str] = None, scope: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword workspace_id: The full Azure ID of the workspace to save the data in. - :paramtype workspace_id: str - :keyword scope: All the VMs in this scope will send their security data to the mentioned - workspace unless overridden by a setting with more specific scope. - :paramtype scope: str - """ - super().__init__(**kwargs) - self.workspace_id = workspace_id - self.scope = scope - - -class WorkspaceSettingList(_serialization.Model): - """List of workspace settings response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: List of workspace settings. Required. - :vartype value: list[~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[WorkspaceSetting]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.WorkspaceSetting"], **kwargs: Any) -> None: - """ - :keyword value: List of workspace settings. Required. - :paramtype value: list[~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_security_center_enums.py deleted file mode 100644 index 2250b56a7e1f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,54 +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 AlertNotifications(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Whether to send security alerts notifications to the security contact.""" - - ON = "On" - """Get notifications on new alerts""" - OFF = "Off" - """Don't get notifications on new alerts""" - - -class AlertsToAdmins(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Whether to send security alerts notifications to subscription admins.""" - - ON = "On" - """Send notification on new alerts to the subscription's admins""" - OFF = "Off" - """Don't send notification on new alerts to the subscription's admins""" - - -class AutoProvision(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes what kind of security agent provisioning action to take.""" - - ON = "On" - """Install missing security agent on VMs automatically""" - OFF = "Off" - """Do not install security agent on the VMs automatically""" - - -class InformationProtectionPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """InformationProtectionPolicyName.""" - - EFFECTIVE = "effective" - CUSTOM = "custom" - - -class Rank(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rank of the sensitivity label.""" - - NONE = "None" - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - CRITICAL = "Critical" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/__init__.py deleted file mode 100644 index a09258020a82..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/__init__.py +++ /dev/null @@ -1,27 +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 ._auto_provisioning_settings_operations import AutoProvisioningSettingsOperations -from ._compliances_operations import CompliancesOperations -from ._information_protection_policies_operations import InformationProtectionPoliciesOperations -from ._security_contacts_operations import SecurityContactsOperations -from ._workspace_settings_operations import WorkspaceSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AutoProvisioningSettingsOperations", - "CompliancesOperations", - "InformationProtectionPoliciesOperations", - "SecurityContactsOperations", - "WorkspaceSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_auto_provisioning_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_auto_provisioning_settings_operations.py deleted file mode 100644 index c69ae126f0e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_auto_provisioning_settings_operations.py +++ /dev/null @@ -1,401 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(setting_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", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(setting_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", "2017-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "settingName": _SERIALIZER.url("setting_name", setting_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) - - -class AutoProvisioningSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.SecurityCenter`'s - :attr:`auto_provisioning_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.AutoProvisioningSetting"]: - """Exposes the auto provisioning settings of the subscriptions. - - :return: An iterator like instance of either AutoProvisioningSetting or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.AutoProvisioningSettingList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AutoProvisioningSettingList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, setting_name: str, **kwargs: Any) -> _models.AutoProvisioningSetting: - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. Required. - :type setting_name: str - :return: AutoProvisioningSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoProvisioningSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - setting_name: str, - setting: _models.AutoProvisioningSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoProvisioningSetting: - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. Required. - :type setting_name: str - :param setting: Auto provisioning setting key. Required. - :type setting: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AutoProvisioningSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, setting_name: str, setting: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AutoProvisioningSetting: - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. Required. - :type setting_name: str - :param setting: Auto provisioning setting key. Required. - :type setting: 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: AutoProvisioningSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, setting_name: str, setting: Union[_models.AutoProvisioningSetting, IO[bytes]], **kwargs: Any - ) -> _models.AutoProvisioningSetting: - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. Required. - :type setting_name: str - :param setting: Auto provisioning setting key. Is either a AutoProvisioningSetting type or a - IO[bytes] type. Required. - :type setting: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting or - IO[bytes] - :return: AutoProvisioningSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(setting, (IOBase, bytes)): - _content = setting - else: - _json = self._serialize.body(setting, "AutoProvisioningSetting") - - _request = build_create_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoProvisioningSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_compliances_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_compliances_operations.py deleted file mode 100644 index c7e3fdf6ea26..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_compliances_operations.py +++ /dev/null @@ -1,252 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/compliances") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, compliance_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/compliances/{complianceName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "complianceName": _SERIALIZER.url("compliance_name", compliance_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) - - -class CompliancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.SecurityCenter`'s - :attr:`compliances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> Iterable["_models.Compliance"]: - """The Compliance scores of the specific management group. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either Compliance or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.Compliance] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.ComplianceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ComplianceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, scope: str, compliance_name: str, **kwargs: Any) -> _models.Compliance: - """Details of a specific Compliance. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param compliance_name: name of the Compliance. Required. - :type compliance_name: str - :return: Compliance or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.Compliance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.Compliance] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - compliance_name=compliance_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Compliance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_information_protection_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_information_protection_policies_operations.py deleted file mode 100644 index 3889b481b5a0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_information_protection_policies_operations.py +++ /dev/null @@ -1,450 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - scope: str, information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], **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", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "informationProtectionPolicyName": _SERIALIZER.url( - "information_protection_policy_name", information_protection_policy_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - scope: str, information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], **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", "2017-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "informationProtectionPolicyName": _SERIALIZER.url( - "information_protection_policy_name", information_protection_policy_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_list_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/informationProtectionPolicies") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class InformationProtectionPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.SecurityCenter`'s - :attr:`information_protection_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, - scope: str, - information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], - **kwargs: Any - ) -> _models.InformationProtectionPolicy: - """Details of the information protection policy. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. Known - values are: "effective" and "custom". Required. - :type information_protection_policy_name: str or - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicyName - :return: InformationProtectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - information_protection_policy_name=information_protection_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - scope: str, - information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], - information_protection_policy: _models.InformationProtectionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.InformationProtectionPolicy: - """Details of the information protection policy. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. Known - values are: "effective" and "custom". Required. - :type information_protection_policy_name: str or - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicyName - :param information_protection_policy: Information protection policy. Required. - :type information_protection_policy: - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: InformationProtectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - scope: str, - information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], - information_protection_policy: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.InformationProtectionPolicy: - """Details of the information protection policy. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. Known - values are: "effective" and "custom". Required. - :type information_protection_policy_name: str or - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicyName - :param information_protection_policy: Information protection policy. Required. - :type information_protection_policy: 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: InformationProtectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - scope: str, - information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], - information_protection_policy: Union[_models.InformationProtectionPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.InformationProtectionPolicy: - """Details of the information protection policy. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. Known - values are: "effective" and "custom". Required. - :type information_protection_policy_name: str or - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicyName - :param information_protection_policy: Information protection policy. Is either a - InformationProtectionPolicy type or a IO[bytes] type. Required. - :type information_protection_policy: - ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy or IO[bytes] - :return: InformationProtectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(information_protection_policy, (IOBase, bytes)): - _content = information_protection_policy - else: - _json = self._serialize.body(information_protection_policy, "InformationProtectionPolicy") - - _request = build_create_or_update_request( - scope=scope, - information_protection_policy_name=information_protection_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("InformationProtectionPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> Iterable["_models.InformationProtectionPolicy"]: - """Information protection policies of a specific management group. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either InformationProtectionPolicy or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.InformationProtectionPolicyList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("InformationProtectionPolicyList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_security_contacts_operations.py deleted file mode 100644 index 1c7290f3985d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_security_contacts_operations.py +++ /dev/null @@ -1,636 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(security_contact_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", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(security_contact_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", "2017-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_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_delete_request(security_contact_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", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(security_contact_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", "2017-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_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) - - -class SecurityContactsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.SecurityCenter`'s - :attr:`security_contacts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecurityContact"]: - """Security contact configurations for the subscription. - - :return: An iterator like instance of either SecurityContact or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.SecurityContactList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityContactList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, security_contact_name: str, **kwargs: Any) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - _request = build_get_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - security_contact_name: str, - security_contact: _models.SecurityContact, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - security_contact_name: str, - security_contact: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: 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: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, security_contact_name: str, security_contact: Union[_models.SecurityContact, IO[bytes]], **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Is either a SecurityContact type or a - IO[bytes] type. Required. - :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact or - IO[bytes] - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_contact, (IOBase, bytes)): - _content = security_contact - else: - _json = self._serialize.body(security_contact, "SecurityContact") - - _request = build_create_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, security_contact_name: str, **kwargs: Any - ) -> None: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - def update( - self, - security_contact_name: str, - security_contact: _models.SecurityContact, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - security_contact_name: str, - security_contact: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: 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: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, security_contact_name: str, security_contact: Union[_models.SecurityContact, IO[bytes]], **kwargs: Any - ) -> _models.SecurityContact: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Is either a SecurityContact type or a - IO[bytes] type. Required. - :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact or - IO[bytes] - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_contact, (IOBase, bytes)): - _content = security_contact - else: - _json = self._serialize.body(security_contact, "SecurityContact") - - _request = build_update_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_workspace_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_workspace_settings_operations.py deleted file mode 100644 index 2de17cbc2d9c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_workspace_settings_operations.py +++ /dev/null @@ -1,639 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(workspace_setting_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", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(workspace_setting_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", "2017-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(workspace_setting_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", "2017-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(workspace_setting_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", "2017-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class WorkspaceSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2017_08_01_preview.SecurityCenter`'s - :attr:`workspace_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.WorkspaceSetting"]: - """Settings about where we should store your security data and logs. If the result is empty, it - means that no custom-workspace configuration was set. - - :return: An iterator like instance of either WorkspaceSetting or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting] - :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._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.WorkspaceSettingList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("WorkspaceSettingList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, workspace_setting_name: str, **kwargs: Any) -> _models.WorkspaceSetting: - """Settings about where we should store your security data and logs. If the result is empty, it - means that no custom-workspace configuration was set. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - workspace_setting_name=workspace_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WorkspaceSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - workspace_setting_name: str, - workspace_setting: _models.WorkspaceSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WorkspaceSetting: - """creating settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Required. - :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - workspace_setting_name: str, - workspace_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WorkspaceSetting: - """creating settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Required. - :type workspace_setting: 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: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, workspace_setting_name: str, workspace_setting: Union[_models.WorkspaceSetting, IO[bytes]], **kwargs: Any - ) -> _models.WorkspaceSetting: - """creating settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Is either a WorkspaceSetting type or a - IO[bytes] type. Required. - :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting or - IO[bytes] - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(workspace_setting, (IOBase, bytes)): - _content = workspace_setting - else: - _json = self._serialize.body(workspace_setting, "WorkspaceSetting") - - _request = build_create_request( - workspace_setting_name=workspace_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WorkspaceSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - workspace_setting_name: str, - workspace_setting: _models.WorkspaceSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WorkspaceSetting: - """Settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Required. - :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - workspace_setting_name: str, - workspace_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WorkspaceSetting: - """Settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Required. - :type workspace_setting: 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: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, workspace_setting_name: str, workspace_setting: Union[_models.WorkspaceSetting, IO[bytes]], **kwargs: Any - ) -> _models.WorkspaceSetting: - """Settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. Is either a WorkspaceSetting type or a - IO[bytes] type. Required. - :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting or - IO[bytes] - :return: WorkspaceSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(workspace_setting, (IOBase, bytes)): - _content = workspace_setting - else: - _json = self._serialize.body(workspace_setting, "WorkspaceSetting") - - _request = build_update_request( - workspace_setting_name=workspace_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WorkspaceSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, workspace_setting_name: str, **kwargs: Any - ) -> None: - """Deletes the custom workspace settings for this subscription. new VMs will report to the default - workspace. - - :param workspace_setting_name: Name of the security setting. Required. - :type workspace_setting_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - workspace_setting_name=workspace_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_configuration.py deleted file mode 100644 index 56aaa2079b95..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2018-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_metadata.json deleted file mode 100644 index 39ad3a4ea72a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2018-06-01", - "total_api_version_list": ["2018-06-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "pricings": "PricingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_security_center.py deleted file mode 100644 index e5bd462fd96e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_security_center.py +++ /dev/null @@ -1,107 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import PricingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.v2018_06_01.operations.PricingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2018-06-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_configuration.py deleted file mode 100644 index 1efce452acf6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2018-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_security_center.py deleted file mode 100644 index 713cc96f6cfe..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_security_center.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import PricingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.v2018_06_01.aio.operations.PricingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2018-06-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/__init__.py deleted file mode 100644 index 3f34d5a48636..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._pricings_operations import PricingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PricingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_pricings_operations.py deleted file mode 100644 index 0248ae2f08df..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_pricings_operations.py +++ /dev/null @@ -1,263 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._pricings_operations import build_get_request, build_list_request, build_update_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PricingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2018_06_01.aio.SecurityCenter`'s - :attr:`pricings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.PricingList: - """Lists Microsoft Defender for Cloud pricing configurations in the subscription. - - :return: PricingList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.PricingList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) - cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PricingList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: - """Gets a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - _request = build_get_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, pricing_name: str, pricing: _models.Pricing, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: ~azure.mgmt.security.v2018_06_01.models.Pricing - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, pricing_name: str, pricing: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: 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: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. - :type pricing: ~azure.mgmt.security.v2018_06_01.models.Pricing or IO[bytes] - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pricing, (IOBase, bytes)): - _content = pricing - else: - _json = self._serialize.body(pricing, "Pricing") - - _request = build_update_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/__init__.py deleted file mode 100644 index 82e99d49aec6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/__init__.py +++ /dev/null @@ -1,29 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Pricing -from ._models_py3 import PricingList -from ._models_py3 import Resource - -from ._security_center_enums import PricingTier -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "ErrorAdditionalInfo", - "Pricing", - "PricingList", - "Resource", - "PricingTier", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_models_py3.py deleted file mode 100644 index 3d4b3bbaad90..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_models_py3.py +++ /dev/null @@ -1,197 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CloudErrorBody(_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.security.v2018_06_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2018_06_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Pricing(Resource): - """Microsoft Defender for Cloud is provided in two pricing tiers: free and standard, with the - standard tier available with a trial period. The standard tier offers advanced security - capabilities, while the free tier offers basic security features. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar pricing_tier: The pricing tier value. Microsoft Defender for Cloud is provided in two - pricing tiers: free and standard, with the standard tier available with a trial period. The - standard tier offers advanced security capabilities, while the free tier offers basic security - features. Known values are: "Free" and "Standard". - :vartype pricing_tier: str or ~azure.mgmt.security.v2018_06_01.models.PricingTier - :ivar free_trial_remaining_time: The duration left for the subscriptions free trial period - in - ISO 8601 format (e.g. P3Y6M4DT12H30M5S). - :vartype free_trial_remaining_time: ~datetime.timedelta - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "free_trial_remaining_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "pricing_tier": {"key": "properties.pricingTier", "type": "str"}, - "free_trial_remaining_time": {"key": "properties.freeTrialRemainingTime", "type": "duration"}, - } - - def __init__(self, *, pricing_tier: Optional[Union[str, "_models.PricingTier"]] = None, **kwargs: Any) -> None: - """ - :keyword pricing_tier: The pricing tier value. Microsoft Defender for Cloud is provided in two - pricing tiers: free and standard, with the standard tier available with a trial period. The - standard tier offers advanced security capabilities, while the free tier offers basic security - features. Known values are: "Free" and "Standard". - :paramtype pricing_tier: str or ~azure.mgmt.security.v2018_06_01.models.PricingTier - """ - super().__init__(**kwargs) - self.pricing_tier = pricing_tier - self.free_trial_remaining_time = None - - -class PricingList(_serialization.Model): - """List of pricing configurations response. - - All required parameters must be populated in order to send to server. - - :ivar value: List of pricing configurations. Required. - :vartype value: list[~azure.mgmt.security.v2018_06_01.models.Pricing] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Pricing]"}, - } - - def __init__(self, *, value: List["_models.Pricing"], **kwargs: Any) -> None: - """ - :keyword value: List of pricing configurations. Required. - :paramtype value: list[~azure.mgmt.security.v2018_06_01.models.Pricing] - """ - super().__init__(**kwargs) - self.value = value diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_security_center_enums.py deleted file mode 100644 index 340d6e87274f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_security_center_enums.py +++ /dev/null @@ -1,22 +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 PricingTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The pricing tier value. Microsoft Defender for Cloud is provided in two pricing tiers: free and - standard, with the standard tier available with a trial period. The standard tier offers - advanced security capabilities, while the free tier offers basic security features. - """ - - FREE = "Free" - """Get free Microsoft Defender for Cloud experience with basic security features""" - STANDARD = "Standard" - """Get the standard Microsoft Defender for Cloud experience with advanced security features""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/__init__.py deleted file mode 100644 index 3f34d5a48636..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._pricings_operations import PricingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PricingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_pricings_operations.py deleted file mode 100644 index 42bcc7df4229..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_pricings_operations.py +++ /dev/null @@ -1,351 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2018-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(pricing_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", "2018-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url("pricing_name", pricing_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_update_request(pricing_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", "2018-06-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}/providers/Microsoft.Security/pricings/{pricingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url("pricing_name", pricing_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) - - -class PricingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2018_06_01.SecurityCenter`'s - :attr:`pricings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> _models.PricingList: - """Lists Microsoft Defender for Cloud pricing configurations in the subscription. - - :return: PricingList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.PricingList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) - cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PricingList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: - """Gets a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - _request = build_get_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, pricing_name: str, pricing: _models.Pricing, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: ~azure.mgmt.security.v2018_06_01.models.Pricing - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, pricing_name: str, pricing: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: 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: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. - :type pricing: ~azure.mgmt.security.v2018_06_01.models.Pricing or IO[bytes] - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pricing, (IOBase, bytes)): - _content = pricing - else: - _json = self._serialize.body(pricing, "Pricing") - - _request = build_update_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_configuration.py deleted file mode 100644 index 857e261eb2c9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2019-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_metadata.json deleted file mode 100644 index 54dfbbdaf19d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2019-01-01", - "total_api_version_list": ["2019-01-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "advanced_threat_protection": "AdvancedThreatProtectionOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_security_center.py deleted file mode 100644 index fdf23e790666..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_security_center.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import AdvancedThreatProtectionOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar advanced_threat_protection: AdvancedThreatProtectionOperations operations - :vartype advanced_threat_protection: - azure.mgmt.security.v2019_01_01.operations.AdvancedThreatProtectionOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.advanced_threat_protection = AdvancedThreatProtectionOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_configuration.py deleted file mode 100644 index 2e20f8b2a991..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2019-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_security_center.py deleted file mode 100644 index 655477ec0eb0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_security_center.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import AdvancedThreatProtectionOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar advanced_threat_protection: AdvancedThreatProtectionOperations operations - :vartype advanced_threat_protection: - azure.mgmt.security.v2019_01_01.aio.operations.AdvancedThreatProtectionOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.advanced_threat_protection = AdvancedThreatProtectionOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/__init__.py deleted file mode 100644 index 950166c69a9b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._advanced_threat_protection_operations import AdvancedThreatProtectionOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdvancedThreatProtectionOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_advanced_threat_protection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_advanced_threat_protection_operations.py deleted file mode 100644 index b5551ce2b964..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_advanced_threat_protection_operations.py +++ /dev/null @@ -1,232 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._advanced_threat_protection_operations import build_create_request, build_get_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AdvancedThreatProtectionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01.aio.SecurityCenter`'s - :attr:`advanced_threat_protection` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, resource_id: str, **kwargs: Any) -> _models.AdvancedThreatProtectionSetting: - """Gets the Advanced Threat Protection settings for the specified resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: AdvancedThreatProtectionSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-01-01")) - setting_name: Literal["current"] = kwargs.pop("setting_name", "current") - cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - api_version=api_version, - setting_name=setting_name, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdvancedThreatProtectionSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - resource_id: str, - advanced_threat_protection_setting: _models.AdvancedThreatProtectionSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AdvancedThreatProtectionSetting: - """Creates or updates the Advanced Threat Protection settings on a specified resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Required. - :type advanced_threat_protection_setting: - ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AdvancedThreatProtectionSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_id: str, - advanced_threat_protection_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AdvancedThreatProtectionSetting: - """Creates or updates the Advanced Threat Protection settings on a specified resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Required. - :type advanced_threat_protection_setting: 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: AdvancedThreatProtectionSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_id: str, - advanced_threat_protection_setting: Union[_models.AdvancedThreatProtectionSetting, IO[bytes]], - **kwargs: Any - ) -> _models.AdvancedThreatProtectionSetting: - """Creates or updates the Advanced Threat Protection settings on a specified resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Is either a - AdvancedThreatProtectionSetting type or a IO[bytes] type. Required. - :type advanced_threat_protection_setting: - ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting or IO[bytes] - :return: AdvancedThreatProtectionSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-01-01")) - setting_name: Literal["current"] = kwargs.pop("setting_name", "current") - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(advanced_threat_protection_setting, (IOBase, bytes)): - _content = advanced_threat_protection_setting - else: - _json = self._serialize.body(advanced_threat_protection_setting, "AdvancedThreatProtectionSetting") - - _request = build_create_request( - resource_id=resource_id, - api_version=api_version, - setting_name=setting_name, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdvancedThreatProtectionSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/__init__.py deleted file mode 100644 index 8c7246cc6182..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/__init__.py +++ /dev/null @@ -1,24 +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 ._models_py3 import AdvancedThreatProtectionSetting -from ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Resource -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdvancedThreatProtectionSetting", - "CloudErrorBody", - "ErrorAdditionalInfo", - "Resource", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/_models_py3.py deleted file mode 100644 index f6957b29d889..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/_models_py3.py +++ /dev/null @@ -1,153 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Optional - -from ... import _serialization - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AdvancedThreatProtectionSetting(Resource): - """The Advanced Threat Protection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar is_enabled: Indicates whether Advanced Threat Protection is enabled. - :vartype is_enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - } - - def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_enabled: Indicates whether Advanced Threat Protection is enabled. - :paramtype is_enabled: bool - """ - super().__init__(**kwargs) - self.is_enabled = is_enabled - - -class CloudErrorBody(_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.security.v2019_01_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2019_01_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/__init__.py deleted file mode 100644 index 950166c69a9b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._advanced_threat_protection_operations import AdvancedThreatProtectionOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdvancedThreatProtectionOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_advanced_threat_protection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_advanced_threat_protection_operations.py deleted file mode 100644 index 5ca8dfa3b87e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_advanced_threat_protection_operations.py +++ /dev/null @@ -1,294 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_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", "2019-01-01")) - setting_name: Literal["current"] = kwargs.pop("setting_name", "current") - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(resource_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", "2019-01-01")) - setting_name: Literal["current"] = kwargs.pop("setting_name", "current") - 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", "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "settingName": _SERIALIZER.url("setting_name", setting_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) - - -class AdvancedThreatProtectionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01.SecurityCenter`'s - :attr:`advanced_threat_protection` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, resource_id: str, **kwargs: Any) -> _models.AdvancedThreatProtectionSetting: - """Gets the Advanced Threat Protection settings for the specified resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: AdvancedThreatProtectionSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-01-01")) - setting_name: Literal["current"] = kwargs.pop("setting_name", "current") - cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - api_version=api_version, - setting_name=setting_name, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdvancedThreatProtectionSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - resource_id: str, - advanced_threat_protection_setting: _models.AdvancedThreatProtectionSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AdvancedThreatProtectionSetting: - """Creates or updates the Advanced Threat Protection settings on a specified resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Required. - :type advanced_threat_protection_setting: - ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AdvancedThreatProtectionSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_id: str, - advanced_threat_protection_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AdvancedThreatProtectionSetting: - """Creates or updates the Advanced Threat Protection settings on a specified resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Required. - :type advanced_threat_protection_setting: 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: AdvancedThreatProtectionSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_id: str, - advanced_threat_protection_setting: Union[_models.AdvancedThreatProtectionSetting, IO[bytes]], - **kwargs: Any - ) -> _models.AdvancedThreatProtectionSetting: - """Creates or updates the Advanced Threat Protection settings on a specified resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param advanced_threat_protection_setting: Advanced Threat Protection Settings. Is either a - AdvancedThreatProtectionSetting type or a IO[bytes] type. Required. - :type advanced_threat_protection_setting: - ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting or IO[bytes] - :return: AdvancedThreatProtectionSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-01-01")) - setting_name: Literal["current"] = kwargs.pop("setting_name", "current") - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(advanced_threat_protection_setting, (IOBase, bytes)): - _content = advanced_threat_protection_setting - else: - _json = self._serialize.body(advanced_threat_protection_setting, "AdvancedThreatProtectionSetting") - - _request = build_create_request( - resource_id=resource_id, - api_version=api_version, - setting_name=setting_name, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdvancedThreatProtectionSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_configuration.py deleted file mode 100644 index db0e18c16fa9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-01-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", "2019-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_metadata.json deleted file mode 100644 index 49d773ee4f05..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_metadata.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "chosen_version": "2019-01-01-preview", - "total_api_version_list": ["2019-01-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "alerts_suppression_rules": "AlertsSuppressionRulesOperations", - "automations": "AutomationsOperations", - "regulatory_compliance_standards": "RegulatoryComplianceStandardsOperations", - "regulatory_compliance_controls": "RegulatoryComplianceControlsOperations", - "regulatory_compliance_assessments": "RegulatoryComplianceAssessmentsOperations", - "sub_assessments": "SubAssessmentsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_security_center.py deleted file mode 100644 index e33a4003ec97..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_security_center.py +++ /dev/null @@ -1,146 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AlertsSuppressionRulesOperations, - AutomationsOperations, - RegulatoryComplianceAssessmentsOperations, - RegulatoryComplianceControlsOperations, - RegulatoryComplianceStandardsOperations, - SubAssessmentsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar alerts_suppression_rules: AlertsSuppressionRulesOperations operations - :vartype alerts_suppression_rules: - azure.mgmt.security.v2019_01_01_preview.operations.AlertsSuppressionRulesOperations - :ivar automations: AutomationsOperations operations - :vartype automations: azure.mgmt.security.v2019_01_01_preview.operations.AutomationsOperations - :ivar regulatory_compliance_standards: RegulatoryComplianceStandardsOperations operations - :vartype regulatory_compliance_standards: - azure.mgmt.security.v2019_01_01_preview.operations.RegulatoryComplianceStandardsOperations - :ivar regulatory_compliance_controls: RegulatoryComplianceControlsOperations operations - :vartype regulatory_compliance_controls: - azure.mgmt.security.v2019_01_01_preview.operations.RegulatoryComplianceControlsOperations - :ivar regulatory_compliance_assessments: RegulatoryComplianceAssessmentsOperations operations - :vartype regulatory_compliance_assessments: - azure.mgmt.security.v2019_01_01_preview.operations.RegulatoryComplianceAssessmentsOperations - :ivar sub_assessments: SubAssessmentsOperations operations - :vartype sub_assessments: - azure.mgmt.security.v2019_01_01_preview.operations.SubAssessmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-01-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alerts_suppression_rules = AlertsSuppressionRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.automations = AutomationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.regulatory_compliance_standards = RegulatoryComplianceStandardsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.regulatory_compliance_controls = RegulatoryComplianceControlsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.regulatory_compliance_assessments = RegulatoryComplianceAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.sub_assessments = SubAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_configuration.py deleted file mode 100644 index 741960b84b80..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-01-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", "2019-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_security_center.py deleted file mode 100644 index eba72f0d7aa4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_security_center.py +++ /dev/null @@ -1,149 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AlertsSuppressionRulesOperations, - AutomationsOperations, - RegulatoryComplianceAssessmentsOperations, - RegulatoryComplianceControlsOperations, - RegulatoryComplianceStandardsOperations, - SubAssessmentsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar alerts_suppression_rules: AlertsSuppressionRulesOperations operations - :vartype alerts_suppression_rules: - azure.mgmt.security.v2019_01_01_preview.aio.operations.AlertsSuppressionRulesOperations - :ivar automations: AutomationsOperations operations - :vartype automations: - azure.mgmt.security.v2019_01_01_preview.aio.operations.AutomationsOperations - :ivar regulatory_compliance_standards: RegulatoryComplianceStandardsOperations operations - :vartype regulatory_compliance_standards: - azure.mgmt.security.v2019_01_01_preview.aio.operations.RegulatoryComplianceStandardsOperations - :ivar regulatory_compliance_controls: RegulatoryComplianceControlsOperations operations - :vartype regulatory_compliance_controls: - azure.mgmt.security.v2019_01_01_preview.aio.operations.RegulatoryComplianceControlsOperations - :ivar regulatory_compliance_assessments: RegulatoryComplianceAssessmentsOperations operations - :vartype regulatory_compliance_assessments: - azure.mgmt.security.v2019_01_01_preview.aio.operations.RegulatoryComplianceAssessmentsOperations - :ivar sub_assessments: SubAssessmentsOperations operations - :vartype sub_assessments: - azure.mgmt.security.v2019_01_01_preview.aio.operations.SubAssessmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-01-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alerts_suppression_rules = AlertsSuppressionRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.automations = AutomationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.regulatory_compliance_standards = RegulatoryComplianceStandardsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.regulatory_compliance_controls = RegulatoryComplianceControlsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.regulatory_compliance_assessments = RegulatoryComplianceAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - self.sub_assessments = SubAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/__init__.py deleted file mode 100644 index 60c0186f89d0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,29 +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 ._alerts_suppression_rules_operations import AlertsSuppressionRulesOperations -from ._automations_operations import AutomationsOperations -from ._regulatory_compliance_standards_operations import RegulatoryComplianceStandardsOperations -from ._regulatory_compliance_controls_operations import RegulatoryComplianceControlsOperations -from ._regulatory_compliance_assessments_operations import RegulatoryComplianceAssessmentsOperations -from ._sub_assessments_operations import SubAssessmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertsSuppressionRulesOperations", - "AutomationsOperations", - "RegulatoryComplianceStandardsOperations", - "RegulatoryComplianceControlsOperations", - "RegulatoryComplianceAssessmentsOperations", - "SubAssessmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_alerts_suppression_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_alerts_suppression_rules_operations.py deleted file mode 100644 index c1a7aeff0bf4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_alerts_suppression_rules_operations.py +++ /dev/null @@ -1,377 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._alerts_suppression_rules_operations import ( - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AlertsSuppressionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.aio.SecurityCenter`'s - :attr:`alerts_suppression_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, alert_type: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.AlertsSuppressionRule"]: - """List of all the dismiss rules for the given subscription. - - :param alert_type: Type of the alert to get rules for. Default value is None. - :type alert_type: str - :return: An iterator like instance of either AlertsSuppressionRule or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.AlertsSuppressionRulesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - alert_type=alert_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertsSuppressionRulesList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, alerts_suppression_rule_name: str, **kwargs: Any) -> _models.AlertsSuppressionRule: - """Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :return: AlertsSuppressionRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) - - _request = build_get_request( - alerts_suppression_rule_name=alerts_suppression_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertsSuppressionRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - alerts_suppression_rule_name: str, - alerts_suppression_rule: _models.AlertsSuppressionRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertsSuppressionRule: - """Update existing rule or create new rule if it doesn't exist. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :param alerts_suppression_rule: Suppression rule object. Required. - :type alerts_suppression_rule: - ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AlertsSuppressionRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - alerts_suppression_rule_name: str, - alerts_suppression_rule: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertsSuppressionRule: - """Update existing rule or create new rule if it doesn't exist. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :param alerts_suppression_rule: Suppression rule object. Required. - :type alerts_suppression_rule: 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: AlertsSuppressionRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - alerts_suppression_rule_name: str, - alerts_suppression_rule: Union[_models.AlertsSuppressionRule, IO[bytes]], - **kwargs: Any - ) -> _models.AlertsSuppressionRule: - """Update existing rule or create new rule if it doesn't exist. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :param alerts_suppression_rule: Suppression rule object. Is either a AlertsSuppressionRule type - or a IO[bytes] type. Required. - :type alerts_suppression_rule: - ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule or IO[bytes] - :return: AlertsSuppressionRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alerts_suppression_rule, (IOBase, bytes)): - _content = alerts_suppression_rule - else: - _json = self._serialize.body(alerts_suppression_rule, "AlertsSuppressionRule") - - _request = build_update_request( - alerts_suppression_rule_name=alerts_suppression_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertsSuppressionRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, alerts_suppression_rule_name: str, **kwargs: Any - ) -> None: - """Delete dismiss alert rule for this subscription. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - alerts_suppression_rule_name=alerts_suppression_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_automations_operations.py deleted file mode 100644 index a1b00c81e800..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_automations_operations.py +++ /dev/null @@ -1,622 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._automations_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_validate_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AutomationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.aio.SecurityCenter`'s - :attr:`automations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Automation"]: - """Lists all the security automations in the specified subscription. Use the 'nextLink' property - in the response to get the next page of security automations for the specified subscription. - - :return: An iterator like instance of either Automation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.Automation] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.AutomationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AutomationList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Automation"]: - """Lists all the security automations in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security automations for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Automation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.Automation] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.AutomationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AutomationList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_group_name: str, automation_name: str, **kwargs: Any) -> _models.Automation: - """Retrieves information about the model of a security automation. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :return: Automation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.Automation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - automation_name=automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Automation", pipeline_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, - automation_name: str, - automation: _models.Automation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Automation: - """Creates or updates a security automation. If a security automation is already created and a - subsequent request is issued for the same automation id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Required. - :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Automation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - automation_name: str, - automation: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Automation: - """Creates or updates a security automation. If a security automation is already created and a - subsequent request is issued for the same automation id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Required. - :type automation: 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: Automation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - automation_name: str, - automation: Union[_models.Automation, IO[bytes]], - **kwargs: Any - ) -> _models.Automation: - """Creates or updates a security automation. If a security automation is already created and a - subsequent request is issued for the same automation id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Is either a Automation type or a IO[bytes] - type. Required. - :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation or IO[bytes] - :return: Automation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Automation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(automation, (IOBase, bytes)): - _content = automation - else: - _json = self._serialize.body(automation, "Automation") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - automation_name=automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Automation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Automation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, automation_name: str, **kwargs: Any - ) -> None: - """Deletes a security automation. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - automation_name=automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def validate( - self, - resource_group_name: str, - automation_name: str, - automation: _models.Automation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutomationValidationStatus: - """Validates the security automation model before create or update. Any validation errors are - returned to the client. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Required. - :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AutomationValidationStatus or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AutomationValidationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate( - self, - resource_group_name: str, - automation_name: str, - automation: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutomationValidationStatus: - """Validates the security automation model before create or update. Any validation errors are - returned to the client. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Required. - :type automation: 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: AutomationValidationStatus or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AutomationValidationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate( - self, - resource_group_name: str, - automation_name: str, - automation: Union[_models.Automation, IO[bytes]], - **kwargs: Any - ) -> _models.AutomationValidationStatus: - """Validates the security automation model before create or update. Any validation errors are - returned to the client. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Is either a Automation type or a IO[bytes] - type. Required. - :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation or IO[bytes] - :return: AutomationValidationStatus or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AutomationValidationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutomationValidationStatus] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(automation, (IOBase, bytes)): - _content = automation - else: - _json = self._serialize.body(automation, "Automation") - - _request = build_validate_request( - resource_group_name=resource_group_name, - automation_name=automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutomationValidationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_assessments_operations.py deleted file mode 100644 index dfd001a27fb6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_assessments_operations.py +++ /dev/null @@ -1,226 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._regulatory_compliance_assessments_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RegulatoryComplianceAssessmentsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.aio.SecurityCenter`'s - :attr:`regulatory_compliance_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, - regulatory_compliance_standard_name: str, - regulatory_compliance_control_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RegulatoryComplianceAssessment"]: - """Details and state of assessments mapped to selected regulatory compliance control. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - Required. - :type regulatory_compliance_control_name: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either RegulatoryComplianceAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceAssessment] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - regulatory_compliance_control_name=regulatory_compliance_control_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RegulatoryComplianceAssessmentList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - regulatory_compliance_standard_name: str, - regulatory_compliance_control_name: str, - regulatory_compliance_assessment_name: str, - **kwargs: Any - ) -> _models.RegulatoryComplianceAssessment: - """Supported regulatory compliance details and state for selected assessment. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - Required. - :type regulatory_compliance_control_name: str - :param regulatory_compliance_assessment_name: Name of the regulatory compliance assessment - object. Required. - :type regulatory_compliance_assessment_name: str - :return: RegulatoryComplianceAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - regulatory_compliance_control_name=regulatory_compliance_control_name, - regulatory_compliance_assessment_name=regulatory_compliance_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RegulatoryComplianceAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_controls_operations.py deleted file mode 100644 index aa4f01f9f4f4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_controls_operations.py +++ /dev/null @@ -1,210 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._regulatory_compliance_controls_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RegulatoryComplianceControlsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.aio.SecurityCenter`'s - :attr:`regulatory_compliance_controls` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, regulatory_compliance_standard_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RegulatoryComplianceControl"]: - """All supported regulatory compliance controls details and state for selected standard. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either RegulatoryComplianceControl or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceControl] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceControlList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RegulatoryComplianceControlList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, regulatory_compliance_standard_name: str, regulatory_compliance_control_name: str, **kwargs: Any - ) -> _models.RegulatoryComplianceControl: - """Selected regulatory compliance control details and state. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - Required. - :type regulatory_compliance_control_name: str - :return: RegulatoryComplianceControl or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceControl - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceControl] = kwargs.pop("cls", None) - - _request = build_get_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - regulatory_compliance_control_name=regulatory_compliance_control_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RegulatoryComplianceControl", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_standards_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_standards_operations.py deleted file mode 100644 index 544410471f2b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_standards_operations.py +++ /dev/null @@ -1,202 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._regulatory_compliance_standards_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RegulatoryComplianceStandardsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.aio.SecurityCenter`'s - :attr:`regulatory_compliance_standards` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RegulatoryComplianceStandard"]: - """Supported regulatory compliance standards details and state. - - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either RegulatoryComplianceStandard or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceStandard] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceStandardList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RegulatoryComplianceStandardList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, regulatory_compliance_standard_name: str, **kwargs: Any - ) -> _models.RegulatoryComplianceStandard: - """Supported regulatory compliance details state for selected standard. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :return: RegulatoryComplianceStandard or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceStandard - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceStandard] = kwargs.pop("cls", None) - - _request = build_get_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RegulatoryComplianceStandard", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_sub_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_sub_assessments_operations.py deleted file mode 100644 index 02f4788fd362..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_sub_assessments_operations.py +++ /dev/null @@ -1,295 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._sub_assessments_operations import build_get_request, build_list_all_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SubAssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.aio.SecurityCenter`'s - :attr:`sub_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_all(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecuritySubAssessment"]: - """Get security sub-assessments on all your scanned resources inside a subscription scope. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either SecuritySubAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.SecuritySubAssessment] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.SecuritySubAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_all_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecuritySubAssessmentList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, scope: str, assessment_name: str, **kwargs: Any) -> AsyncIterable["_models.SecuritySubAssessment"]: - """Get security sub-assessments on all your scanned resources inside a scope. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :return: An iterator like instance of either SecuritySubAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.SecuritySubAssessment] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.SecuritySubAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - assessment_name=assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecuritySubAssessmentList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, scope: str, assessment_name: str, sub_assessment_name: str, **kwargs: Any - ) -> _models.SecuritySubAssessment: - """Get a security sub-assessment on your scanned resource. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param sub_assessment_name: The Sub-Assessment Key - Unique key for the sub-assessment type. - Required. - :type sub_assessment_name: str - :return: SecuritySubAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.SecuritySubAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.SecuritySubAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - assessment_name=assessment_name, - sub_assessment_name=sub_assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecuritySubAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/__init__.py deleted file mode 100644 index 93bc6625aac2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/__init__.py +++ /dev/null @@ -1,123 +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 ._models_py3 import AdditionalData -from ._models_py3 import AlertsSuppressionRule -from ._models_py3 import AlertsSuppressionRulesList -from ._models_py3 import Automation -from ._models_py3 import AutomationAction -from ._models_py3 import AutomationActionEventHub -from ._models_py3 import AutomationActionLogicApp -from ._models_py3 import AutomationActionWorkspace -from ._models_py3 import AutomationList -from ._models_py3 import AutomationRuleSet -from ._models_py3 import AutomationScope -from ._models_py3 import AutomationSource -from ._models_py3 import AutomationTriggeringRule -from ._models_py3 import AutomationValidationStatus -from ._models_py3 import AzureResourceDetails -from ._models_py3 import AzureTrackedResourceLocation -from ._models_py3 import CVE -from ._models_py3 import CVSS -from ._models_py3 import CloudErrorBody -from ._models_py3 import ContainerRegistryVulnerabilityProperties -from ._models_py3 import ETag -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Kind -from ._models_py3 import OnPremiseResourceDetails -from ._models_py3 import OnPremiseSqlResourceDetails -from ._models_py3 import RegulatoryComplianceAssessment -from ._models_py3 import RegulatoryComplianceAssessmentList -from ._models_py3 import RegulatoryComplianceControl -from ._models_py3 import RegulatoryComplianceControlList -from ._models_py3 import RegulatoryComplianceStandard -from ._models_py3 import RegulatoryComplianceStandardList -from ._models_py3 import Resource -from ._models_py3 import ResourceDetails -from ._models_py3 import ScopeElement -from ._models_py3 import SecuritySubAssessment -from ._models_py3 import SecuritySubAssessmentList -from ._models_py3 import ServerVulnerabilityProperties -from ._models_py3 import SqlServerVulnerabilityProperties -from ._models_py3 import SubAssessmentStatus -from ._models_py3 import SuppressionAlertsScope -from ._models_py3 import Tags -from ._models_py3 import TrackedResource -from ._models_py3 import VendorReference - -from ._security_center_enums import ActionType -from ._security_center_enums import AssessedResourceType -from ._security_center_enums import EventSource -from ._security_center_enums import Operator -from ._security_center_enums import PropertyType -from ._security_center_enums import RuleState -from ._security_center_enums import Severity -from ._security_center_enums import Source -from ._security_center_enums import State -from ._security_center_enums import SubAssessmentStatusCode -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdditionalData", - "AlertsSuppressionRule", - "AlertsSuppressionRulesList", - "Automation", - "AutomationAction", - "AutomationActionEventHub", - "AutomationActionLogicApp", - "AutomationActionWorkspace", - "AutomationList", - "AutomationRuleSet", - "AutomationScope", - "AutomationSource", - "AutomationTriggeringRule", - "AutomationValidationStatus", - "AzureResourceDetails", - "AzureTrackedResourceLocation", - "CVE", - "CVSS", - "CloudErrorBody", - "ContainerRegistryVulnerabilityProperties", - "ETag", - "ErrorAdditionalInfo", - "Kind", - "OnPremiseResourceDetails", - "OnPremiseSqlResourceDetails", - "RegulatoryComplianceAssessment", - "RegulatoryComplianceAssessmentList", - "RegulatoryComplianceControl", - "RegulatoryComplianceControlList", - "RegulatoryComplianceStandard", - "RegulatoryComplianceStandardList", - "Resource", - "ResourceDetails", - "ScopeElement", - "SecuritySubAssessment", - "SecuritySubAssessmentList", - "ServerVulnerabilityProperties", - "SqlServerVulnerabilityProperties", - "SubAssessmentStatus", - "SuppressionAlertsScope", - "Tags", - "TrackedResource", - "VendorReference", - "ActionType", - "AssessedResourceType", - "EventSource", - "Operator", - "PropertyType", - "RuleState", - "Severity", - "Source", - "State", - "SubAssessmentStatusCode", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_models_py3.py deleted file mode 100644 index 4ae6e8bc8019..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_models_py3.py +++ /dev/null @@ -1,1875 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AdditionalData(_serialization.Model): - """Details of the sub-assessment. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ContainerRegistryVulnerabilityProperties, ServerVulnerabilityProperties, - SqlServerVulnerabilityProperties - - All required parameters must be populated in order to send to server. - - :ivar assessed_resource_type: Sub-assessment resource type. Required. Known values are: - "SqlServerVulnerability", "ContainerRegistryVulnerability", and "ServerVulnerability". - :vartype assessed_resource_type: str or - ~azure.mgmt.security.v2019_01_01_preview.models.AssessedResourceType - """ - - _validation = { - "assessed_resource_type": {"required": True}, - } - - _attribute_map = { - "assessed_resource_type": {"key": "assessedResourceType", "type": "str"}, - } - - _subtype_map = { - "assessed_resource_type": { - "ContainerRegistryVulnerability": "ContainerRegistryVulnerabilityProperties", - "ServerVulnerabilityAssessment": "ServerVulnerabilityProperties", - "SqlServerVulnerability": "SqlServerVulnerabilityProperties", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.assessed_resource_type: Optional[str] = None - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AlertsSuppressionRule(Resource): - """Describes the suppression rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar alert_type: Type of the alert to automatically suppress. For all alert types, use '*'. - :vartype alert_type: str - :ivar last_modified_utc: The last time this rule was modified. - :vartype last_modified_utc: ~datetime.datetime - :ivar expiration_date_utc: Expiration date of the rule, if value is not provided or provided as - null there will no expiration at all. - :vartype expiration_date_utc: ~datetime.datetime - :ivar reason: The reason for dismissing the alert. - :vartype reason: str - :ivar state: Possible states of the rule. Known values are: "Enabled", "Disabled", and - "Expired". - :vartype state: str or ~azure.mgmt.security.v2019_01_01_preview.models.RuleState - :ivar comment: Any comment regarding the rule. - :vartype comment: str - :ivar suppression_alerts_scope: The suppression conditions. - :vartype suppression_alerts_scope: - ~azure.mgmt.security.v2019_01_01_preview.models.SuppressionAlertsScope - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "last_modified_utc": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "alert_type": {"key": "properties.alertType", "type": "str"}, - "last_modified_utc": {"key": "properties.lastModifiedUtc", "type": "iso-8601"}, - "expiration_date_utc": {"key": "properties.expirationDateUtc", "type": "iso-8601"}, - "reason": {"key": "properties.reason", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "comment": {"key": "properties.comment", "type": "str"}, - "suppression_alerts_scope": {"key": "properties.suppressionAlertsScope", "type": "SuppressionAlertsScope"}, - } - - def __init__( - self, - *, - alert_type: Optional[str] = None, - expiration_date_utc: Optional[datetime.datetime] = None, - reason: Optional[str] = None, - state: Optional[Union[str, "_models.RuleState"]] = None, - comment: Optional[str] = None, - suppression_alerts_scope: Optional["_models.SuppressionAlertsScope"] = None, - **kwargs: Any - ) -> None: - """ - :keyword alert_type: Type of the alert to automatically suppress. For all alert types, use '*'. - :paramtype alert_type: str - :keyword expiration_date_utc: Expiration date of the rule, if value is not provided or provided - as null there will no expiration at all. - :paramtype expiration_date_utc: ~datetime.datetime - :keyword reason: The reason for dismissing the alert. - :paramtype reason: str - :keyword state: Possible states of the rule. Known values are: "Enabled", "Disabled", and - "Expired". - :paramtype state: str or ~azure.mgmt.security.v2019_01_01_preview.models.RuleState - :keyword comment: Any comment regarding the rule. - :paramtype comment: str - :keyword suppression_alerts_scope: The suppression conditions. - :paramtype suppression_alerts_scope: - ~azure.mgmt.security.v2019_01_01_preview.models.SuppressionAlertsScope - """ - super().__init__(**kwargs) - self.alert_type = alert_type - self.last_modified_utc = None - self.expiration_date_utc = expiration_date_utc - self.reason = reason - self.state = state - self.comment = comment - self.suppression_alerts_scope = suppression_alerts_scope - - -class AlertsSuppressionRulesList(_serialization.Model): - """Suppression rules list for subscription. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: Required. - :vartype value: list[~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule] - :ivar next_link: URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AlertsSuppressionRule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.AlertsSuppressionRule"], **kwargs: Any) -> None: - """ - :keyword value: Required. - :paramtype value: list[~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class Tags(_serialization.Model): - """A list of key value pairs that describe the resource. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class ETag(_serialization.Model): - """Entity tag is used for comparing two or more entities from the same requested resource. - - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - """ - - _attribute_map = { - "etag": {"key": "etag", "type": "str"}, - } - - def __init__(self, *, etag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - """ - super().__init__(**kwargs) - self.etag = etag - - -class Kind(_serialization.Model): - """Describes an Azure resource with kind. - - :ivar kind: Kind of the resource. - :vartype kind: str - """ - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__(self, *, kind: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword kind: Kind of the resource. - :paramtype kind: str - """ - super().__init__(**kwargs) - self.kind = kind - - -class AzureTrackedResourceLocation(_serialization.Model): - """Describes an Azure resource with location. - - :ivar location: Location where the resource is stored. - :vartype location: str - """ - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - - -class TrackedResource(Resource, AzureTrackedResourceLocation, Kind, ETag, Tags): - """Describes an Azure tracked resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) - self.tags = tags - self.etag = etag - self.kind = kind - self.location = location - self.id = None - self.name = None - self.type = None - - -class Automation(TrackedResource): # pylint: disable=too-many-instance-attributes - """The security automation resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar description: The security automation description. - :vartype description: str - :ivar is_enabled: Indicates whether the security automation is enabled. - :vartype is_enabled: bool - :ivar scopes: A collection of scopes on which the security automations logic is applied. - Supported scopes are the subscription itself or a resource group under that subscription. The - automation will only apply on defined scopes. - :vartype scopes: list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationScope] - :ivar sources: A collection of the source event types which evaluate the security automation - set of rules. - :vartype sources: list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationSource] - :ivar actions: A collection of the actions which are triggered if all the configured rules - evaluations, within at least one rule set, are true. - :vartype actions: list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationAction] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "scopes": {"key": "properties.scopes", "type": "[AutomationScope]"}, - "sources": {"key": "properties.sources", "type": "[AutomationSource]"}, - "actions": {"key": "properties.actions", "type": "[AutomationAction]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - description: Optional[str] = None, - is_enabled: Optional[bool] = None, - scopes: Optional[List["_models.AutomationScope"]] = None, - sources: Optional[List["_models.AutomationSource"]] = None, - actions: Optional[List["_models.AutomationAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - :keyword description: The security automation description. - :paramtype description: str - :keyword is_enabled: Indicates whether the security automation is enabled. - :paramtype is_enabled: bool - :keyword scopes: A collection of scopes on which the security automations logic is applied. - Supported scopes are the subscription itself or a resource group under that subscription. The - automation will only apply on defined scopes. - :paramtype scopes: list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationScope] - :keyword sources: A collection of the source event types which evaluate the security automation - set of rules. - :paramtype sources: list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationSource] - :keyword actions: A collection of the actions which are triggered if all the configured rules - evaluations, within at least one rule set, are true. - :paramtype actions: list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationAction] - """ - super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) - self.description = description - self.is_enabled = is_enabled - self.scopes = scopes - self.sources = sources - self.actions = actions - - -class AutomationAction(_serialization.Model): - """The action that should be triggered. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AutomationActionEventHub, AutomationActionLogicApp, AutomationActionWorkspace - - All required parameters must be populated in order to send to server. - - :ivar action_type: The type of the action that will be triggered by the Automation. Required. - Known values are: "LogicApp", "EventHub", and "Workspace". - :vartype action_type: str or ~azure.mgmt.security.v2019_01_01_preview.models.ActionType - """ - - _validation = { - "action_type": {"required": True}, - } - - _attribute_map = { - "action_type": {"key": "actionType", "type": "str"}, - } - - _subtype_map = { - "action_type": { - "EventHub": "AutomationActionEventHub", - "LogicApp": "AutomationActionLogicApp", - "Workspace": "AutomationActionWorkspace", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.action_type: Optional[str] = None - - -class AutomationActionEventHub(AutomationAction): - """The target Event Hub to which event data will be exported. To learn more about Microsoft - Defender for Cloud continuous export capabilities, visit https://aka.ms/ASCExportLearnMore. - - 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 action_type: The type of the action that will be triggered by the Automation. Required. - Known values are: "LogicApp", "EventHub", and "Workspace". - :vartype action_type: str or ~azure.mgmt.security.v2019_01_01_preview.models.ActionType - :ivar event_hub_resource_id: The target Event Hub Azure Resource ID. - :vartype event_hub_resource_id: str - :ivar sas_policy_name: The target Event Hub SAS policy name. - :vartype sas_policy_name: str - :ivar connection_string: The target Event Hub connection string (it will not be included in any - response). - :vartype connection_string: str - """ - - _validation = { - "action_type": {"required": True}, - "sas_policy_name": {"readonly": True}, - } - - _attribute_map = { - "action_type": {"key": "actionType", "type": "str"}, - "event_hub_resource_id": {"key": "eventHubResourceId", "type": "str"}, - "sas_policy_name": {"key": "sasPolicyName", "type": "str"}, - "connection_string": {"key": "connectionString", "type": "str"}, - } - - def __init__( - self, *, event_hub_resource_id: Optional[str] = None, connection_string: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword event_hub_resource_id: The target Event Hub Azure Resource ID. - :paramtype event_hub_resource_id: str - :keyword connection_string: The target Event Hub connection string (it will not be included in - any response). - :paramtype connection_string: str - """ - super().__init__(**kwargs) - self.action_type: str = "EventHub" - self.event_hub_resource_id = event_hub_resource_id - self.sas_policy_name = None - self.connection_string = connection_string - - -class AutomationActionLogicApp(AutomationAction): - """The logic app action that should be triggered. To learn more about Microsoft Defender for - Cloud's Workflow Automation capabilities, visit https://aka.ms/ASCWorkflowAutomationLearnMore. - - All required parameters must be populated in order to send to server. - - :ivar action_type: The type of the action that will be triggered by the Automation. Required. - Known values are: "LogicApp", "EventHub", and "Workspace". - :vartype action_type: str or ~azure.mgmt.security.v2019_01_01_preview.models.ActionType - :ivar logic_app_resource_id: The triggered Logic App Azure Resource ID. This can also reside on - other subscriptions, given that you have permissions to trigger the Logic App. - :vartype logic_app_resource_id: str - :ivar uri: The Logic App trigger URI endpoint (it will not be included in any response). - :vartype uri: str - """ - - _validation = { - "action_type": {"required": True}, - } - - _attribute_map = { - "action_type": {"key": "actionType", "type": "str"}, - "logic_app_resource_id": {"key": "logicAppResourceId", "type": "str"}, - "uri": {"key": "uri", "type": "str"}, - } - - def __init__( - self, *, logic_app_resource_id: Optional[str] = None, uri: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword logic_app_resource_id: The triggered Logic App Azure Resource ID. This can also reside - on other subscriptions, given that you have permissions to trigger the Logic App. - :paramtype logic_app_resource_id: str - :keyword uri: The Logic App trigger URI endpoint (it will not be included in any response). - :paramtype uri: str - """ - super().__init__(**kwargs) - self.action_type: str = "LogicApp" - self.logic_app_resource_id = logic_app_resource_id - self.uri = uri - - -class AutomationActionWorkspace(AutomationAction): - """The Log Analytics Workspace to which event data will be exported. Security alerts data will - reside in the 'SecurityAlert' table and the assessments data will reside in the - 'SecurityRecommendation' table (under the 'Security'/'SecurityCenterFree' solutions). Note that - in order to view the data in the workspace, the Security Center Log Analytics free/standard - solution needs to be enabled on that workspace. To learn more about Microsoft Defender for - Cloud continuous export capabilities, visit https://aka.ms/ASCExportLearnMore. - - All required parameters must be populated in order to send to server. - - :ivar action_type: The type of the action that will be triggered by the Automation. Required. - Known values are: "LogicApp", "EventHub", and "Workspace". - :vartype action_type: str or ~azure.mgmt.security.v2019_01_01_preview.models.ActionType - :ivar workspace_resource_id: The fully qualified Log Analytics Workspace Azure Resource ID. - :vartype workspace_resource_id: str - """ - - _validation = { - "action_type": {"required": True}, - } - - _attribute_map = { - "action_type": {"key": "actionType", "type": "str"}, - "workspace_resource_id": {"key": "workspaceResourceId", "type": "str"}, - } - - def __init__(self, *, workspace_resource_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword workspace_resource_id: The fully qualified Log Analytics Workspace Azure Resource ID. - :paramtype workspace_resource_id: str - """ - super().__init__(**kwargs) - self.action_type: str = "Workspace" - self.workspace_resource_id = workspace_resource_id - - -class AutomationList(_serialization.Model): - """List of security automations response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of security automations under the given scope. Required. - :vartype value: list[~azure.mgmt.security.v2019_01_01_preview.models.Automation] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Automation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Automation"], **kwargs: Any) -> None: - """ - :keyword value: The list of security automations under the given scope. Required. - :paramtype value: list[~azure.mgmt.security.v2019_01_01_preview.models.Automation] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class AutomationRuleSet(_serialization.Model): - """A rule set which evaluates all its rules upon an event interception. Only when all the included - rules in the rule set will be evaluated as 'true', will the event trigger the defined actions. - - :ivar rules: - :vartype rules: list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationTriggeringRule] - """ - - _attribute_map = { - "rules": {"key": "rules", "type": "[AutomationTriggeringRule]"}, - } - - def __init__(self, *, rules: Optional[List["_models.AutomationTriggeringRule"]] = None, **kwargs: Any) -> None: - """ - :keyword rules: - :paramtype rules: - list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationTriggeringRule] - """ - super().__init__(**kwargs) - self.rules = rules - - -class AutomationScope(_serialization.Model): - """A single automation scope. - - :ivar description: The resources scope description. - :vartype description: str - :ivar scope_path: The resources scope path. Can be the subscription on which the automation is - defined on or a resource group under that subscription (fully qualified Azure resource IDs). - :vartype scope_path: str - """ - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "scope_path": {"key": "scopePath", "type": "str"}, - } - - def __init__(self, *, description: Optional[str] = None, scope_path: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword description: The resources scope description. - :paramtype description: str - :keyword scope_path: The resources scope path. Can be the subscription on which the automation - is defined on or a resource group under that subscription (fully qualified Azure resource IDs). - :paramtype scope_path: str - """ - super().__init__(**kwargs) - self.description = description - self.scope_path = scope_path - - -class AutomationSource(_serialization.Model): - """The source event types which evaluate the security automation set of rules. For example - - security alerts and security assessments. To learn more about the supported security events - data models schemas - please visit https://aka.ms/ASCAutomationSchemas. - - :ivar event_source: A valid event source type. Known values are: "Assessments", - "AssessmentsSnapshot", "SubAssessments", "SubAssessmentsSnapshot", "Alerts", "SecureScores", - "SecureScoresSnapshot", "SecureScoreControls", "SecureScoreControlsSnapshot", - "RegulatoryComplianceAssessment", and "RegulatoryComplianceAssessmentSnapshot". - :vartype event_source: str or ~azure.mgmt.security.v2019_01_01_preview.models.EventSource - :ivar rule_sets: A set of rules which evaluate upon event interception. A logical disjunction - is applied between defined rule sets (logical 'or'). - :vartype rule_sets: list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationRuleSet] - """ - - _attribute_map = { - "event_source": {"key": "eventSource", "type": "str"}, - "rule_sets": {"key": "ruleSets", "type": "[AutomationRuleSet]"}, - } - - def __init__( - self, - *, - event_source: Optional[Union[str, "_models.EventSource"]] = None, - rule_sets: Optional[List["_models.AutomationRuleSet"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword event_source: A valid event source type. Known values are: "Assessments", - "AssessmentsSnapshot", "SubAssessments", "SubAssessmentsSnapshot", "Alerts", "SecureScores", - "SecureScoresSnapshot", "SecureScoreControls", "SecureScoreControlsSnapshot", - "RegulatoryComplianceAssessment", and "RegulatoryComplianceAssessmentSnapshot". - :paramtype event_source: str or ~azure.mgmt.security.v2019_01_01_preview.models.EventSource - :keyword rule_sets: A set of rules which evaluate upon event interception. A logical - disjunction is applied between defined rule sets (logical 'or'). - :paramtype rule_sets: list[~azure.mgmt.security.v2019_01_01_preview.models.AutomationRuleSet] - """ - super().__init__(**kwargs) - self.event_source = event_source - self.rule_sets = rule_sets - - -class AutomationTriggeringRule(_serialization.Model): - """A rule which is evaluated upon event interception. The rule is configured by comparing a - specific value from the event model to an expected value. This comparison is done by using one - of the supported operators set. - - :ivar property_j_path: The JPath of the entity model property that should be checked. - :vartype property_j_path: str - :ivar property_type: The data type of the compared operands (string, integer, floating point - number or a boolean [true/false]]. Known values are: "String", "Integer", "Number", and - "Boolean". - :vartype property_type: str or ~azure.mgmt.security.v2019_01_01_preview.models.PropertyType - :ivar expected_value: The expected value. - :vartype expected_value: str - :ivar operator: A valid comparer operator to use. A case-insensitive comparison will be applied - for String PropertyType. Known values are: "Equals", "GreaterThan", "GreaterThanOrEqualTo", - "LesserThan", "LesserThanOrEqualTo", "NotEquals", "Contains", "StartsWith", and "EndsWith". - :vartype operator: str or ~azure.mgmt.security.v2019_01_01_preview.models.Operator - """ - - _attribute_map = { - "property_j_path": {"key": "propertyJPath", "type": "str"}, - "property_type": {"key": "propertyType", "type": "str"}, - "expected_value": {"key": "expectedValue", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - } - - def __init__( - self, - *, - property_j_path: Optional[str] = None, - property_type: Optional[Union[str, "_models.PropertyType"]] = None, - expected_value: Optional[str] = None, - operator: Optional[Union[str, "_models.Operator"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword property_j_path: The JPath of the entity model property that should be checked. - :paramtype property_j_path: str - :keyword property_type: The data type of the compared operands (string, integer, floating point - number or a boolean [true/false]]. Known values are: "String", "Integer", "Number", and - "Boolean". - :paramtype property_type: str or ~azure.mgmt.security.v2019_01_01_preview.models.PropertyType - :keyword expected_value: The expected value. - :paramtype expected_value: str - :keyword operator: A valid comparer operator to use. A case-insensitive comparison will be - applied for String PropertyType. Known values are: "Equals", "GreaterThan", - "GreaterThanOrEqualTo", "LesserThan", "LesserThanOrEqualTo", "NotEquals", "Contains", - "StartsWith", and "EndsWith". - :paramtype operator: str or ~azure.mgmt.security.v2019_01_01_preview.models.Operator - """ - super().__init__(**kwargs) - self.property_j_path = property_j_path - self.property_type = property_type - self.expected_value = expected_value - self.operator = operator - - -class AutomationValidationStatus(_serialization.Model): - """The security automation model state property bag. - - :ivar is_valid: Indicates whether the model is valid or not. - :vartype is_valid: bool - :ivar message: The validation message. - :vartype message: str - """ - - _attribute_map = { - "is_valid": {"key": "isValid", "type": "bool"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, is_valid: Optional[bool] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword is_valid: Indicates whether the model is valid or not. - :paramtype is_valid: bool - :keyword message: The validation message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.is_valid = is_valid - self.message = message - - -class ResourceDetails(_serialization.Model): - """Details of the resource that was assessed. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureResourceDetails, OnPremiseResourceDetails - - All required parameters must be populated in order to send to server. - - :ivar source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2019_01_01_preview.models.Source - """ - - _validation = { - "source": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - } - - _subtype_map = {"source": {"Azure": "AzureResourceDetails", "OnPremise": "OnPremiseResourceDetails"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.source: Optional[str] = None - - -class AzureResourceDetails(ResourceDetails): - """Details of the Azure resource that was assessed. - - 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 source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2019_01_01_preview.models.Source - :ivar id: Azure resource Id of the assessed resource. - :vartype id: str - """ - - _validation = { - "source": {"required": True}, - "id": {"readonly": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.source: str = "Azure" - self.id = None - - -class CloudErrorBody(_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.security.v2019_01_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2019_01_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ContainerRegistryVulnerabilityProperties(AdditionalData): - """Additional context fields for container registry Vulnerability assessment. - - 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 assessed_resource_type: Sub-assessment resource type. Required. Known values are: - "SqlServerVulnerability", "ContainerRegistryVulnerability", and "ServerVulnerability". - :vartype assessed_resource_type: str or - ~azure.mgmt.security.v2019_01_01_preview.models.AssessedResourceType - :ivar type: Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information - Gathered, Vulnerability. - :vartype type: str - :ivar cvss: Dictionary from cvss version to cvss details object. - :vartype cvss: dict[str, ~azure.mgmt.security.v2019_01_01_preview.models.CVSS] - :ivar patchable: Indicates whether a patch is available or not. - :vartype patchable: bool - :ivar cve: List of CVEs. - :vartype cve: list[~azure.mgmt.security.v2019_01_01_preview.models.CVE] - :ivar published_time: Published time. - :vartype published_time: ~datetime.datetime - :ivar vendor_references: - :vartype vendor_references: - list[~azure.mgmt.security.v2019_01_01_preview.models.VendorReference] - :ivar repository_name: Name of the repository which the vulnerable image belongs to. - :vartype repository_name: str - :ivar image_digest: Digest of the vulnerable image. - :vartype image_digest: str - """ - - _validation = { - "assessed_resource_type": {"required": True}, - "type": {"readonly": True}, - "cvss": {"readonly": True}, - "patchable": {"readonly": True}, - "cve": {"readonly": True}, - "published_time": {"readonly": True}, - "vendor_references": {"readonly": True}, - "repository_name": {"readonly": True}, - "image_digest": {"readonly": True}, - } - - _attribute_map = { - "assessed_resource_type": {"key": "assessedResourceType", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "cvss": {"key": "cvss", "type": "{CVSS}"}, - "patchable": {"key": "patchable", "type": "bool"}, - "cve": {"key": "cve", "type": "[CVE]"}, - "published_time": {"key": "publishedTime", "type": "iso-8601"}, - "vendor_references": {"key": "vendorReferences", "type": "[VendorReference]"}, - "repository_name": {"key": "repositoryName", "type": "str"}, - "image_digest": {"key": "imageDigest", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.assessed_resource_type: str = "ContainerRegistryVulnerability" - self.type = None - self.cvss = None - self.patchable = None - self.cve = None - self.published_time = None - self.vendor_references = None - self.repository_name = None - self.image_digest = None - - -class CVE(_serialization.Model): - """CVE details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar title: CVE title. - :vartype title: str - :ivar link: Link url. - :vartype link: str - """ - - _validation = { - "title": {"readonly": True}, - "link": {"readonly": True}, - } - - _attribute_map = { - "title": {"key": "title", "type": "str"}, - "link": {"key": "link", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.title = None - self.link = None - - -class CVSS(_serialization.Model): - """CVSS details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar base: CVSS base. - :vartype base: float - """ - - _validation = { - "base": {"readonly": True}, - } - - _attribute_map = { - "base": {"key": "base", "type": "float"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.base = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class OnPremiseResourceDetails(ResourceDetails): - """Details of the On Premise resource that was assessed. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - OnPremiseSqlResourceDetails - - All required parameters must be populated in order to send to server. - - :ivar source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2019_01_01_preview.models.Source - :ivar workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :vartype workspace_id: str - :ivar vmuuid: The unique Id of the machine. Required. - :vartype vmuuid: str - :ivar source_computer_id: The oms agent Id installed on the machine. Required. - :vartype source_computer_id: str - :ivar machine_name: The name of the machine. Required. - :vartype machine_name: str - """ - - _validation = { - "source": {"required": True}, - "workspace_id": {"required": True}, - "vmuuid": {"required": True}, - "source_computer_id": {"required": True}, - "machine_name": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "vmuuid": {"key": "vmuuid", "type": "str"}, - "source_computer_id": {"key": "sourceComputerId", "type": "str"}, - "machine_name": {"key": "machineName", "type": "str"}, - } - - _subtype_map = {"source": {"OnPremiseSql": "OnPremiseSqlResourceDetails"}} - - def __init__( - self, *, workspace_id: str, vmuuid: str, source_computer_id: str, machine_name: str, **kwargs: Any - ) -> None: - """ - :keyword workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :paramtype workspace_id: str - :keyword vmuuid: The unique Id of the machine. Required. - :paramtype vmuuid: str - :keyword source_computer_id: The oms agent Id installed on the machine. Required. - :paramtype source_computer_id: str - :keyword machine_name: The name of the machine. Required. - :paramtype machine_name: str - """ - super().__init__(**kwargs) - self.source: str = "OnPremise" - self.workspace_id = workspace_id - self.vmuuid = vmuuid - self.source_computer_id = source_computer_id - self.machine_name = machine_name - - -class OnPremiseSqlResourceDetails(OnPremiseResourceDetails): - """Details of the On Premise Sql resource that was assessed. - - All required parameters must be populated in order to send to server. - - :ivar source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2019_01_01_preview.models.Source - :ivar workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :vartype workspace_id: str - :ivar vmuuid: The unique Id of the machine. Required. - :vartype vmuuid: str - :ivar source_computer_id: The oms agent Id installed on the machine. Required. - :vartype source_computer_id: str - :ivar machine_name: The name of the machine. Required. - :vartype machine_name: str - :ivar server_name: The Sql server name installed on the machine. Required. - :vartype server_name: str - :ivar database_name: The Sql database name installed on the machine. Required. - :vartype database_name: str - """ - - _validation = { - "source": {"required": True}, - "workspace_id": {"required": True}, - "vmuuid": {"required": True}, - "source_computer_id": {"required": True}, - "machine_name": {"required": True}, - "server_name": {"required": True}, - "database_name": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "vmuuid": {"key": "vmuuid", "type": "str"}, - "source_computer_id": {"key": "sourceComputerId", "type": "str"}, - "machine_name": {"key": "machineName", "type": "str"}, - "server_name": {"key": "serverName", "type": "str"}, - "database_name": {"key": "databaseName", "type": "str"}, - } - - def __init__( - self, - *, - workspace_id: str, - vmuuid: str, - source_computer_id: str, - machine_name: str, - server_name: str, - database_name: str, - **kwargs: Any - ) -> None: - """ - :keyword workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :paramtype workspace_id: str - :keyword vmuuid: The unique Id of the machine. Required. - :paramtype vmuuid: str - :keyword source_computer_id: The oms agent Id installed on the machine. Required. - :paramtype source_computer_id: str - :keyword machine_name: The name of the machine. Required. - :paramtype machine_name: str - :keyword server_name: The Sql server name installed on the machine. Required. - :paramtype server_name: str - :keyword database_name: The Sql database name installed on the machine. Required. - :paramtype database_name: str - """ - super().__init__( - workspace_id=workspace_id, - vmuuid=vmuuid, - source_computer_id=source_computer_id, - machine_name=machine_name, - **kwargs - ) - self.source: str = "OnPremiseSql" - self.server_name = server_name - self.database_name = database_name - - -class RegulatoryComplianceAssessment(Resource): # pylint: disable=too-many-instance-attributes - """Regulatory compliance assessment details and state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar description: The description of the regulatory compliance assessment. - :vartype description: str - :ivar assessment_type: The expected type of assessment contained in the AssessmentDetailsLink. - :vartype assessment_type: str - :ivar assessment_details_link: Link to more detailed assessment results data. The response type - will be according to the assessmentType field. - :vartype assessment_details_link: str - :ivar state: Aggregative state based on the assessment's scanned resources states. Known values - are: "Passed", "Failed", "Skipped", and "Unsupported". - :vartype state: str or ~azure.mgmt.security.v2019_01_01_preview.models.State - :ivar passed_resources: The given assessment's related resources count with passed state. - :vartype passed_resources: int - :ivar failed_resources: The given assessment's related resources count with failed state. - :vartype failed_resources: int - :ivar skipped_resources: The given assessment's related resources count with skipped state. - :vartype skipped_resources: int - :ivar unsupported_resources: The given assessment's related resources count with unsupported - state. - :vartype unsupported_resources: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "description": {"readonly": True}, - "assessment_type": {"readonly": True}, - "assessment_details_link": {"readonly": True}, - "passed_resources": {"readonly": True}, - "failed_resources": {"readonly": True}, - "skipped_resources": {"readonly": True}, - "unsupported_resources": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "assessment_type": {"key": "properties.assessmentType", "type": "str"}, - "assessment_details_link": {"key": "properties.assessmentDetailsLink", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "passed_resources": {"key": "properties.passedResources", "type": "int"}, - "failed_resources": {"key": "properties.failedResources", "type": "int"}, - "skipped_resources": {"key": "properties.skippedResources", "type": "int"}, - "unsupported_resources": {"key": "properties.unsupportedResources", "type": "int"}, - } - - def __init__(self, *, state: Optional[Union[str, "_models.State"]] = None, **kwargs: Any) -> None: - """ - :keyword state: Aggregative state based on the assessment's scanned resources states. Known - values are: "Passed", "Failed", "Skipped", and "Unsupported". - :paramtype state: str or ~azure.mgmt.security.v2019_01_01_preview.models.State - """ - super().__init__(**kwargs) - self.description = None - self.assessment_type = None - self.assessment_details_link = None - self.state = state - self.passed_resources = None - self.failed_resources = None - self.skipped_resources = None - self.unsupported_resources = None - - -class RegulatoryComplianceAssessmentList(_serialization.Model): - """List of regulatory compliance assessment response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: Required. - :vartype value: - list[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceAssessment] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RegulatoryComplianceAssessment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.RegulatoryComplianceAssessment"], **kwargs: Any) -> None: - """ - :keyword value: Required. - :paramtype value: - list[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceAssessment] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class RegulatoryComplianceControl(Resource): - """Regulatory compliance control details and state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar description: The description of the regulatory compliance control. - :vartype description: str - :ivar state: Aggregative state based on the control's supported assessments states. Known - values are: "Passed", "Failed", "Skipped", and "Unsupported". - :vartype state: str or ~azure.mgmt.security.v2019_01_01_preview.models.State - :ivar passed_assessments: The number of supported regulatory compliance assessments of the - given control with a passed state. - :vartype passed_assessments: int - :ivar failed_assessments: The number of supported regulatory compliance assessments of the - given control with a failed state. - :vartype failed_assessments: int - :ivar skipped_assessments: The number of supported regulatory compliance assessments of the - given control with a skipped state. - :vartype skipped_assessments: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "description": {"readonly": True}, - "passed_assessments": {"readonly": True}, - "failed_assessments": {"readonly": True}, - "skipped_assessments": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "passed_assessments": {"key": "properties.passedAssessments", "type": "int"}, - "failed_assessments": {"key": "properties.failedAssessments", "type": "int"}, - "skipped_assessments": {"key": "properties.skippedAssessments", "type": "int"}, - } - - def __init__(self, *, state: Optional[Union[str, "_models.State"]] = None, **kwargs: Any) -> None: - """ - :keyword state: Aggregative state based on the control's supported assessments states. Known - values are: "Passed", "Failed", "Skipped", and "Unsupported". - :paramtype state: str or ~azure.mgmt.security.v2019_01_01_preview.models.State - """ - super().__init__(**kwargs) - self.description = None - self.state = state - self.passed_assessments = None - self.failed_assessments = None - self.skipped_assessments = None - - -class RegulatoryComplianceControlList(_serialization.Model): - """List of regulatory compliance controls response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: List of regulatory compliance controls. Required. - :vartype value: - list[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceControl] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RegulatoryComplianceControl]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.RegulatoryComplianceControl"], **kwargs: Any) -> None: - """ - :keyword value: List of regulatory compliance controls. Required. - :paramtype value: - list[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceControl] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class RegulatoryComplianceStandard(Resource): - """Regulatory compliance standard details and state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar state: Aggregative state based on the standard's supported controls states. Known values - are: "Passed", "Failed", "Skipped", and "Unsupported". - :vartype state: str or ~azure.mgmt.security.v2019_01_01_preview.models.State - :ivar passed_controls: The number of supported regulatory compliance controls of the given - standard with a passed state. - :vartype passed_controls: int - :ivar failed_controls: The number of supported regulatory compliance controls of the given - standard with a failed state. - :vartype failed_controls: int - :ivar skipped_controls: The number of supported regulatory compliance controls of the given - standard with a skipped state. - :vartype skipped_controls: int - :ivar unsupported_controls: The number of regulatory compliance controls of the given standard - which are unsupported by automated assessments. - :vartype unsupported_controls: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "passed_controls": {"readonly": True}, - "failed_controls": {"readonly": True}, - "skipped_controls": {"readonly": True}, - "unsupported_controls": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "passed_controls": {"key": "properties.passedControls", "type": "int"}, - "failed_controls": {"key": "properties.failedControls", "type": "int"}, - "skipped_controls": {"key": "properties.skippedControls", "type": "int"}, - "unsupported_controls": {"key": "properties.unsupportedControls", "type": "int"}, - } - - def __init__(self, *, state: Optional[Union[str, "_models.State"]] = None, **kwargs: Any) -> None: - """ - :keyword state: Aggregative state based on the standard's supported controls states. Known - values are: "Passed", "Failed", "Skipped", and "Unsupported". - :paramtype state: str or ~azure.mgmt.security.v2019_01_01_preview.models.State - """ - super().__init__(**kwargs) - self.state = state - self.passed_controls = None - self.failed_controls = None - self.skipped_controls = None - self.unsupported_controls = None - - -class RegulatoryComplianceStandardList(_serialization.Model): - """List of regulatory compliance standards response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: Required. - :vartype value: - list[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceStandard] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RegulatoryComplianceStandard]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.RegulatoryComplianceStandard"], **kwargs: Any) -> None: - """ - :keyword value: Required. - :paramtype value: - list[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceStandard] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class ScopeElement(_serialization.Model): - """A more specific scope used to identify the alerts to suppress. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar field: The alert entity type to suppress by. - :vartype field: str - """ - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "field": {"key": "field", "type": "str"}, - } - - def __init__( - self, *, additional_properties: Optional[Dict[str, Any]] = None, field: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword field: The alert entity type to suppress by. - :paramtype field: str - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.field = field - - -class SecuritySubAssessment(Resource): # pylint: disable=too-many-instance-attributes - """Security sub-assessment on a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar id_properties_id: Vulnerability ID. - :vartype id_properties_id: str - :ivar display_name: User friendly display name of the sub-assessment. - :vartype display_name: str - :ivar status: Status of the sub-assessment. - :vartype status: ~azure.mgmt.security.v2019_01_01_preview.models.SubAssessmentStatus - :ivar remediation: Information on how to remediate this sub-assessment. - :vartype remediation: str - :ivar impact: Description of the impact of this sub-assessment. - :vartype impact: str - :ivar category: Category of the sub-assessment. - :vartype category: str - :ivar description: Human readable description of the assessment status. - :vartype description: str - :ivar time_generated: The date and time the sub-assessment was generated. - :vartype time_generated: ~datetime.datetime - :ivar resource_details: Details of the resource that was assessed. - :vartype resource_details: ~azure.mgmt.security.v2019_01_01_preview.models.ResourceDetails - :ivar additional_data: Details of the sub-assessment. - :vartype additional_data: ~azure.mgmt.security.v2019_01_01_preview.models.AdditionalData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "id_properties_id": {"readonly": True}, - "display_name": {"readonly": True}, - "remediation": {"readonly": True}, - "impact": {"readonly": True}, - "category": {"readonly": True}, - "description": {"readonly": True}, - "time_generated": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "id_properties_id": {"key": "properties.id", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "status": {"key": "properties.status", "type": "SubAssessmentStatus"}, - "remediation": {"key": "properties.remediation", "type": "str"}, - "impact": {"key": "properties.impact", "type": "str"}, - "category": {"key": "properties.category", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "time_generated": {"key": "properties.timeGenerated", "type": "iso-8601"}, - "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, - "additional_data": {"key": "properties.additionalData", "type": "AdditionalData"}, - } - - def __init__( - self, - *, - status: Optional["_models.SubAssessmentStatus"] = None, - resource_details: Optional["_models.ResourceDetails"] = None, - additional_data: Optional["_models.AdditionalData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Status of the sub-assessment. - :paramtype status: ~azure.mgmt.security.v2019_01_01_preview.models.SubAssessmentStatus - :keyword resource_details: Details of the resource that was assessed. - :paramtype resource_details: ~azure.mgmt.security.v2019_01_01_preview.models.ResourceDetails - :keyword additional_data: Details of the sub-assessment. - :paramtype additional_data: ~azure.mgmt.security.v2019_01_01_preview.models.AdditionalData - """ - super().__init__(**kwargs) - self.id_properties_id = None - self.display_name = None - self.status = status - self.remediation = None - self.impact = None - self.category = None - self.description = None - self.time_generated = None - self.resource_details = resource_details - self.additional_data = additional_data - - -class SecuritySubAssessmentList(_serialization.Model): - """List of security sub-assessments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2019_01_01_preview.models.SecuritySubAssessment] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecuritySubAssessment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class ServerVulnerabilityProperties(AdditionalData): - """Additional context fields for server vulnerability assessment. - - 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 assessed_resource_type: Sub-assessment resource type. Required. Known values are: - "SqlServerVulnerability", "ContainerRegistryVulnerability", and "ServerVulnerability". - :vartype assessed_resource_type: str or - ~azure.mgmt.security.v2019_01_01_preview.models.AssessedResourceType - :ivar type: Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information - Gathered. - :vartype type: str - :ivar cvss: Dictionary from cvss version to cvss details object. - :vartype cvss: dict[str, ~azure.mgmt.security.v2019_01_01_preview.models.CVSS] - :ivar patchable: Indicates whether a patch is available or not. - :vartype patchable: bool - :ivar cve: List of CVEs. - :vartype cve: list[~azure.mgmt.security.v2019_01_01_preview.models.CVE] - :ivar threat: Threat name. - :vartype threat: str - :ivar published_time: Published time. - :vartype published_time: ~datetime.datetime - :ivar vendor_references: - :vartype vendor_references: - list[~azure.mgmt.security.v2019_01_01_preview.models.VendorReference] - """ - - _validation = { - "assessed_resource_type": {"required": True}, - "type": {"readonly": True}, - "cvss": {"readonly": True}, - "patchable": {"readonly": True}, - "cve": {"readonly": True}, - "threat": {"readonly": True}, - "published_time": {"readonly": True}, - "vendor_references": {"readonly": True}, - } - - _attribute_map = { - "assessed_resource_type": {"key": "assessedResourceType", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "cvss": {"key": "cvss", "type": "{CVSS}"}, - "patchable": {"key": "patchable", "type": "bool"}, - "cve": {"key": "cve", "type": "[CVE]"}, - "threat": {"key": "threat", "type": "str"}, - "published_time": {"key": "publishedTime", "type": "iso-8601"}, - "vendor_references": {"key": "vendorReferences", "type": "[VendorReference]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.assessed_resource_type: str = "ServerVulnerabilityAssessment" - self.type = None - self.cvss = None - self.patchable = None - self.cve = None - self.threat = None - self.published_time = None - self.vendor_references = None - - -class SqlServerVulnerabilityProperties(AdditionalData): - """Details of the resource that was assessed. - - 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 assessed_resource_type: Sub-assessment resource type. Required. Known values are: - "SqlServerVulnerability", "ContainerRegistryVulnerability", and "ServerVulnerability". - :vartype assessed_resource_type: str or - ~azure.mgmt.security.v2019_01_01_preview.models.AssessedResourceType - :ivar type: The resource type the sub assessment refers to in its resource details. - :vartype type: str - :ivar query: The T-SQL query that runs on your SQL database to perform the particular check. - :vartype query: str - """ - - _validation = { - "assessed_resource_type": {"required": True}, - "type": {"readonly": True}, - "query": {"readonly": True}, - } - - _attribute_map = { - "assessed_resource_type": {"key": "assessedResourceType", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "query": {"key": "query", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.assessed_resource_type: str = "SqlServerVulnerability" - self.type = None - self.query = None - - -class SubAssessmentStatus(_serialization.Model): - """Status of the sub-assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Programmatic code for the status of the assessment. Known values are: "Healthy", - "Unhealthy", and "NotApplicable". - :vartype code: str or ~azure.mgmt.security.v2019_01_01_preview.models.SubAssessmentStatusCode - :ivar cause: Programmatic code for the cause of the assessment status. - :vartype cause: str - :ivar description: Human readable description of the assessment status. - :vartype description: str - :ivar severity: The sub-assessment severity level. Known values are: "Low", "Medium", and - "High". - :vartype severity: str or ~azure.mgmt.security.v2019_01_01_preview.models.Severity - """ - - _validation = { - "code": {"readonly": True}, - "cause": {"readonly": True}, - "description": {"readonly": True}, - "severity": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "cause": {"key": "cause", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "severity": {"key": "severity", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.cause = None - self.description = None - self.severity = None - - -class SuppressionAlertsScope(_serialization.Model): - """SuppressionAlertsScope. - - All required parameters must be populated in order to send to server. - - :ivar all_of: All the conditions inside need to be true in order to suppress the alert. - Required. - :vartype all_of: list[~azure.mgmt.security.v2019_01_01_preview.models.ScopeElement] - """ - - _validation = { - "all_of": {"required": True}, - } - - _attribute_map = { - "all_of": {"key": "allOf", "type": "[ScopeElement]"}, - } - - def __init__(self, *, all_of: List["_models.ScopeElement"], **kwargs: Any) -> None: - """ - :keyword all_of: All the conditions inside need to be true in order to suppress the alert. - Required. - :paramtype all_of: list[~azure.mgmt.security.v2019_01_01_preview.models.ScopeElement] - """ - super().__init__(**kwargs) - self.all_of = all_of - - -class VendorReference(_serialization.Model): - """Vendor reference. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar title: Link title. - :vartype title: str - :ivar link: Link url. - :vartype link: str - """ - - _validation = { - "title": {"readonly": True}, - "link": {"readonly": True}, - } - - _attribute_map = { - "title": {"key": "title", "type": "str"}, - "link": {"key": "link", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.title = None - self.link = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_security_center_enums.py deleted file mode 100644 index 53ec353b3f12..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,130 +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): - """The type of the action that will be triggered by the Automation.""" - - LOGIC_APP = "LogicApp" - EVENT_HUB = "EventHub" - WORKSPACE = "Workspace" - - -class AssessedResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Sub-assessment resource type.""" - - SQL_SERVER_VULNERABILITY = "SqlServerVulnerability" - CONTAINER_REGISTRY_VULNERABILITY = "ContainerRegistryVulnerability" - SERVER_VULNERABILITY = "ServerVulnerability" - - -class EventSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """A valid event source type.""" - - ASSESSMENTS = "Assessments" - ASSESSMENTS_SNAPSHOT = "AssessmentsSnapshot" - SUB_ASSESSMENTS = "SubAssessments" - SUB_ASSESSMENTS_SNAPSHOT = "SubAssessmentsSnapshot" - ALERTS = "Alerts" - SECURE_SCORES = "SecureScores" - SECURE_SCORES_SNAPSHOT = "SecureScoresSnapshot" - SECURE_SCORE_CONTROLS = "SecureScoreControls" - SECURE_SCORE_CONTROLS_SNAPSHOT = "SecureScoreControlsSnapshot" - REGULATORY_COMPLIANCE_ASSESSMENT = "RegulatoryComplianceAssessment" - REGULATORY_COMPLIANCE_ASSESSMENT_SNAPSHOT = "RegulatoryComplianceAssessmentSnapshot" - - -class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """A valid comparer operator to use. A case-insensitive comparison will be applied for String - PropertyType. - """ - - EQUALS = "Equals" - """Applies for decimal and non-decimal operands""" - GREATER_THAN = "GreaterThan" - """Applies only for decimal operands""" - GREATER_THAN_OR_EQUAL_TO = "GreaterThanOrEqualTo" - """Applies only for decimal operands""" - LESSER_THAN = "LesserThan" - """Applies only for decimal operands""" - LESSER_THAN_OR_EQUAL_TO = "LesserThanOrEqualTo" - """Applies only for decimal operands""" - NOT_EQUALS = "NotEquals" - """Applies for decimal and non-decimal operands""" - CONTAINS = "Contains" - """Applies only for non-decimal operands""" - STARTS_WITH = "StartsWith" - """Applies only for non-decimal operands""" - ENDS_WITH = "EndsWith" - """Applies only for non-decimal operands""" - - -class PropertyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The data type of the compared operands (string, integer, floating point number or a boolean - [true/false]]. - """ - - STRING = "String" - INTEGER = "Integer" - NUMBER = "Number" - BOOLEAN = "Boolean" - - -class RuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Possible states of the rule.""" - - ENABLED = "Enabled" - DISABLED = "Disabled" - EXPIRED = "Expired" - - -class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sub-assessment severity level.""" - - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - - -class Source(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The platform where the assessed resource resides.""" - - AZURE = "Azure" - """Resource is in Azure""" - ON_PREMISE = "OnPremise" - """Resource in an on premise machine connected to Azure cloud""" - ON_PREMISE_SQL = "OnPremiseSql" - """SQL Resource in an on premise machine connected to Azure cloud""" - - -class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregative state based on the standard's supported controls states.""" - - PASSED = "Passed" - """All supported regulatory compliance controls in the given standard have a passed state""" - FAILED = "Failed" - """At least one supported regulatory compliance control in the given standard has a state of - failed""" - SKIPPED = "Skipped" - """All supported regulatory compliance controls in the given standard have a state of skipped""" - UNSUPPORTED = "Unsupported" - """No supported regulatory compliance data for the given standard""" - - -class SubAssessmentStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Programmatic code for the status of the assessment.""" - - HEALTHY = "Healthy" - """The resource is healthy""" - UNHEALTHY = "Unhealthy" - """The resource has a security issue that needs to be addressed""" - NOT_APPLICABLE = "NotApplicable" - """Assessment for this resource did not happen""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/__init__.py deleted file mode 100644 index 60c0186f89d0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/__init__.py +++ /dev/null @@ -1,29 +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 ._alerts_suppression_rules_operations import AlertsSuppressionRulesOperations -from ._automations_operations import AutomationsOperations -from ._regulatory_compliance_standards_operations import RegulatoryComplianceStandardsOperations -from ._regulatory_compliance_controls_operations import RegulatoryComplianceControlsOperations -from ._regulatory_compliance_assessments_operations import RegulatoryComplianceAssessmentsOperations -from ._sub_assessments_operations import SubAssessmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertsSuppressionRulesOperations", - "AutomationsOperations", - "RegulatoryComplianceStandardsOperations", - "RegulatoryComplianceControlsOperations", - "RegulatoryComplianceAssessmentsOperations", - "SubAssessmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_alerts_suppression_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_alerts_suppression_rules_operations.py deleted file mode 100644 index e7d802bfd824..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_alerts_suppression_rules_operations.py +++ /dev/null @@ -1,503 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, *, alert_type: 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", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if alert_type is not None: - _params["AlertType"] = _SERIALIZER.query("alert_type", alert_type, "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(alerts_suppression_rule_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", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "alertsSuppressionRuleName": _SERIALIZER.url( - "alerts_suppression_rule_name", alerts_suppression_rule_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_update_request(alerts_suppression_rule_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", "2019-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "alertsSuppressionRuleName": _SERIALIZER.url( - "alerts_suppression_rule_name", alerts_suppression_rule_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_delete_request(alerts_suppression_rule_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", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "alertsSuppressionRuleName": _SERIALIZER.url( - "alerts_suppression_rule_name", alerts_suppression_rule_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AlertsSuppressionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.SecurityCenter`'s - :attr:`alerts_suppression_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, alert_type: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AlertsSuppressionRule"]: - """List of all the dismiss rules for the given subscription. - - :param alert_type: Type of the alert to get rules for. Default value is None. - :type alert_type: str - :return: An iterator like instance of either AlertsSuppressionRule or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.AlertsSuppressionRulesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - alert_type=alert_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertsSuppressionRulesList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, alerts_suppression_rule_name: str, **kwargs: Any) -> _models.AlertsSuppressionRule: - """Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :return: AlertsSuppressionRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) - - _request = build_get_request( - alerts_suppression_rule_name=alerts_suppression_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertsSuppressionRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - alerts_suppression_rule_name: str, - alerts_suppression_rule: _models.AlertsSuppressionRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertsSuppressionRule: - """Update existing rule or create new rule if it doesn't exist. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :param alerts_suppression_rule: Suppression rule object. Required. - :type alerts_suppression_rule: - ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AlertsSuppressionRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - alerts_suppression_rule_name: str, - alerts_suppression_rule: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertsSuppressionRule: - """Update existing rule or create new rule if it doesn't exist. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :param alerts_suppression_rule: Suppression rule object. Required. - :type alerts_suppression_rule: 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: AlertsSuppressionRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - alerts_suppression_rule_name: str, - alerts_suppression_rule: Union[_models.AlertsSuppressionRule, IO[bytes]], - **kwargs: Any - ) -> _models.AlertsSuppressionRule: - """Update existing rule or create new rule if it doesn't exist. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :param alerts_suppression_rule: Suppression rule object. Is either a AlertsSuppressionRule type - or a IO[bytes] type. Required. - :type alerts_suppression_rule: - ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule or IO[bytes] - :return: AlertsSuppressionRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alerts_suppression_rule, (IOBase, bytes)): - _content = alerts_suppression_rule - else: - _json = self._serialize.body(alerts_suppression_rule, "AlertsSuppressionRule") - - _request = build_update_request( - alerts_suppression_rule_name=alerts_suppression_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertsSuppressionRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, alerts_suppression_rule_name: str, **kwargs: Any - ) -> None: - """Delete dismiss alert rule for this subscription. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. Required. - :type alerts_suppression_rule_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - alerts_suppression_rule_name=alerts_suppression_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_automations_operations.py deleted file mode 100644 index 7824d626d840..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_automations_operations.py +++ /dev/null @@ -1,821 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/automations") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_request( - resource_group_name: str, automation_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", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, automation_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", "2019-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "automationName": _SERIALIZER.url("automation_name", automation_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_delete_request( - resource_group_name: str, automation_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", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_validate_request( - resource_group_name: str, automation_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", "2019-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}/validate", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AutomationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.SecurityCenter`'s - :attr:`automations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Automation"]: - """Lists all the security automations in the specified subscription. Use the 'nextLink' property - in the response to get the next page of security automations for the specified subscription. - - :return: An iterator like instance of either Automation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.Automation] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.AutomationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AutomationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Automation"]: - """Lists all the security automations in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security automations for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Automation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.Automation] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.AutomationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AutomationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, automation_name: str, **kwargs: Any) -> _models.Automation: - """Retrieves information about the model of a security automation. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :return: Automation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.Automation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - automation_name=automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Automation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - automation_name: str, - automation: _models.Automation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Automation: - """Creates or updates a security automation. If a security automation is already created and a - subsequent request is issued for the same automation id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Required. - :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Automation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - automation_name: str, - automation: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Automation: - """Creates or updates a security automation. If a security automation is already created and a - subsequent request is issued for the same automation id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Required. - :type automation: 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: Automation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - automation_name: str, - automation: Union[_models.Automation, IO[bytes]], - **kwargs: Any - ) -> _models.Automation: - """Creates or updates a security automation. If a security automation is already created and a - subsequent request is issued for the same automation id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Is either a Automation type or a IO[bytes] - type. Required. - :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation or IO[bytes] - :return: Automation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Automation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(automation, (IOBase, bytes)): - _content = automation - else: - _json = self._serialize.body(automation, "Automation") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - automation_name=automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Automation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Automation", pipeline_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, automation_name: str, **kwargs: Any - ) -> None: - """Deletes a security automation. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - automation_name=automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - def validate( - self, - resource_group_name: str, - automation_name: str, - automation: _models.Automation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutomationValidationStatus: - """Validates the security automation model before create or update. Any validation errors are - returned to the client. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Required. - :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AutomationValidationStatus or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AutomationValidationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate( - self, - resource_group_name: str, - automation_name: str, - automation: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutomationValidationStatus: - """Validates the security automation model before create or update. Any validation errors are - returned to the client. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Required. - :type automation: 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: AutomationValidationStatus or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AutomationValidationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate( - self, - resource_group_name: str, - automation_name: str, - automation: Union[_models.Automation, IO[bytes]], - **kwargs: Any - ) -> _models.AutomationValidationStatus: - """Validates the security automation model before create or update. Any validation errors are - returned to the client. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param automation_name: The security automation name. Required. - :type automation_name: str - :param automation: The security automation resource. Is either a Automation type or a IO[bytes] - type. Required. - :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation or IO[bytes] - :return: AutomationValidationStatus or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AutomationValidationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutomationValidationStatus] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(automation, (IOBase, bytes)): - _content = automation - else: - _json = self._serialize.body(automation, "Automation") - - _request = build_validate_request( - resource_group_name=resource_group_name, - automation_name=automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutomationValidationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_assessments_operations.py deleted file mode 100644 index 14e9c57ff138..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_assessments_operations.py +++ /dev/null @@ -1,316 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - regulatory_compliance_standard_name: str, - regulatory_compliance_control_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "regulatoryComplianceStandardName": _SERIALIZER.url( - "regulatory_compliance_standard_name", regulatory_compliance_standard_name, "str" - ), - "regulatoryComplianceControlName": _SERIALIZER.url( - "regulatory_compliance_control_name", regulatory_compliance_control_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - regulatory_compliance_standard_name: str, - regulatory_compliance_control_name: str, - regulatory_compliance_assessment_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", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments/{regulatoryComplianceAssessmentName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "regulatoryComplianceStandardName": _SERIALIZER.url( - "regulatory_compliance_standard_name", regulatory_compliance_standard_name, "str" - ), - "regulatoryComplianceControlName": _SERIALIZER.url( - "regulatory_compliance_control_name", regulatory_compliance_control_name, "str" - ), - "regulatoryComplianceAssessmentName": _SERIALIZER.url( - "regulatory_compliance_assessment_name", regulatory_compliance_assessment_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) - - -class RegulatoryComplianceAssessmentsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.SecurityCenter`'s - :attr:`regulatory_compliance_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, - regulatory_compliance_standard_name: str, - regulatory_compliance_control_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.RegulatoryComplianceAssessment"]: - """Details and state of assessments mapped to selected regulatory compliance control. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - Required. - :type regulatory_compliance_control_name: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either RegulatoryComplianceAssessment or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceAssessment] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - regulatory_compliance_control_name=regulatory_compliance_control_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RegulatoryComplianceAssessmentList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - regulatory_compliance_standard_name: str, - regulatory_compliance_control_name: str, - regulatory_compliance_assessment_name: str, - **kwargs: Any - ) -> _models.RegulatoryComplianceAssessment: - """Supported regulatory compliance details and state for selected assessment. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - Required. - :type regulatory_compliance_control_name: str - :param regulatory_compliance_assessment_name: Name of the regulatory compliance assessment - object. Required. - :type regulatory_compliance_assessment_name: str - :return: RegulatoryComplianceAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - regulatory_compliance_control_name=regulatory_compliance_control_name, - regulatory_compliance_assessment_name=regulatory_compliance_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RegulatoryComplianceAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_controls_operations.py deleted file mode 100644 index 97db724137b0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_controls_operations.py +++ /dev/null @@ -1,288 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - regulatory_compliance_standard_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "regulatoryComplianceStandardName": _SERIALIZER.url( - "regulatory_compliance_standard_name", regulatory_compliance_standard_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - regulatory_compliance_standard_name: str, - regulatory_compliance_control_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", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "regulatoryComplianceStandardName": _SERIALIZER.url( - "regulatory_compliance_standard_name", regulatory_compliance_standard_name, "str" - ), - "regulatoryComplianceControlName": _SERIALIZER.url( - "regulatory_compliance_control_name", regulatory_compliance_control_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) - - -class RegulatoryComplianceControlsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.SecurityCenter`'s - :attr:`regulatory_compliance_controls` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, regulatory_compliance_standard_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RegulatoryComplianceControl"]: - """All supported regulatory compliance controls details and state for selected standard. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either RegulatoryComplianceControl or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceControl] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceControlList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RegulatoryComplianceControlList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, regulatory_compliance_standard_name: str, regulatory_compliance_control_name: str, **kwargs: Any - ) -> _models.RegulatoryComplianceControl: - """Selected regulatory compliance control details and state. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - Required. - :type regulatory_compliance_control_name: str - :return: RegulatoryComplianceControl or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceControl - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceControl] = kwargs.pop("cls", None) - - _request = build_get_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - regulatory_compliance_control_name=regulatory_compliance_control_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RegulatoryComplianceControl", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_standards_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_standards_operations.py deleted file mode 100644 index 8285e81d7849..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_standards_operations.py +++ /dev/null @@ -1,262 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(regulatory_compliance_standard_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", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "regulatoryComplianceStandardName": _SERIALIZER.url( - "regulatory_compliance_standard_name", regulatory_compliance_standard_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) - - -class RegulatoryComplianceStandardsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.SecurityCenter`'s - :attr:`regulatory_compliance_standards` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RegulatoryComplianceStandard"]: - """Supported regulatory compliance standards details and state. - - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: An iterator like instance of either RegulatoryComplianceStandard or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceStandard] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceStandardList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RegulatoryComplianceStandardList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, regulatory_compliance_standard_name: str, **kwargs: Any) -> _models.RegulatoryComplianceStandard: - """Supported regulatory compliance details state for selected standard. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - Required. - :type regulatory_compliance_standard_name: str - :return: RegulatoryComplianceStandard or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.RegulatoryComplianceStandard - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.RegulatoryComplianceStandard] = kwargs.pop("cls", None) - - _request = build_get_request( - regulatory_compliance_standard_name=regulatory_compliance_standard_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RegulatoryComplianceStandard", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_sub_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_sub_assessments_operations.py deleted file mode 100644 index 8162cfc4d514..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_sub_assessments_operations.py +++ /dev/null @@ -1,377 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_all_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/subAssessments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(scope: str, assessment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments" - ) - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_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_get_request(scope: str, assessment_name: str, sub_assessment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments/{subAssessmentName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), - "subAssessmentName": _SERIALIZER.url("sub_assessment_name", sub_assessment_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) - - -class SubAssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_01_01_preview.SecurityCenter`'s - :attr:`sub_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_all(self, scope: str, **kwargs: Any) -> Iterable["_models.SecuritySubAssessment"]: - """Get security sub-assessments on all your scanned resources inside a subscription scope. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either SecuritySubAssessment or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.SecuritySubAssessment] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.SecuritySubAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_all_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecuritySubAssessmentList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, scope: str, assessment_name: str, **kwargs: Any) -> Iterable["_models.SecuritySubAssessment"]: - """Get security sub-assessments on all your scanned resources inside a scope. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :return: An iterator like instance of either SecuritySubAssessment or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_01_01_preview.models.SecuritySubAssessment] - :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._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.SecuritySubAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - assessment_name=assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecuritySubAssessmentList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, scope: str, assessment_name: str, sub_assessment_name: str, **kwargs: Any - ) -> _models.SecuritySubAssessment: - """Get a security sub-assessment on your scanned resource. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param sub_assessment_name: The Sub-Assessment Key - Unique key for the sub-assessment type. - Required. - :type sub_assessment_name: str - :return: SecuritySubAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.SecuritySubAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") - ) - cls: ClsType[_models.SecuritySubAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - assessment_name=assessment_name, - sub_assessment_name=sub_assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecuritySubAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_configuration.py deleted file mode 100644 index 6ee248813544..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-08-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-08-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_metadata.json deleted file mode 100644 index c497fc6fdd82..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2019-08-01", - "total_api_version_list": ["2019-08-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "device_security_groups": "DeviceSecurityGroupsOperations", - "iot_security_solution_analytics": "IotSecuritySolutionAnalyticsOperations", - "iot_security_solutions_analytics_aggregated_alert": "IotSecuritySolutionsAnalyticsAggregatedAlertOperations", - "iot_security_solutions_analytics_recommendation": "IotSecuritySolutionsAnalyticsRecommendationOperations", - "iot_security_solution": "IotSecuritySolutionOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_security_center.py deleted file mode 100644 index 9fc276454ff7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_security_center.py +++ /dev/null @@ -1,142 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - DeviceSecurityGroupsOperations, - IotSecuritySolutionAnalyticsOperations, - IotSecuritySolutionOperations, - IotSecuritySolutionsAnalyticsAggregatedAlertOperations, - IotSecuritySolutionsAnalyticsRecommendationOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar device_security_groups: DeviceSecurityGroupsOperations operations - :vartype device_security_groups: - azure.mgmt.security.v2019_08_01.operations.DeviceSecurityGroupsOperations - :ivar iot_security_solution_analytics: IotSecuritySolutionAnalyticsOperations operations - :vartype iot_security_solution_analytics: - azure.mgmt.security.v2019_08_01.operations.IotSecuritySolutionAnalyticsOperations - :ivar iot_security_solutions_analytics_aggregated_alert: - IotSecuritySolutionsAnalyticsAggregatedAlertOperations operations - :vartype iot_security_solutions_analytics_aggregated_alert: - azure.mgmt.security.v2019_08_01.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations - :ivar iot_security_solutions_analytics_recommendation: - IotSecuritySolutionsAnalyticsRecommendationOperations operations - :vartype iot_security_solutions_analytics_recommendation: - azure.mgmt.security.v2019_08_01.operations.IotSecuritySolutionsAnalyticsRecommendationOperations - :ivar iot_security_solution: IotSecuritySolutionOperations operations - :vartype iot_security_solution: - azure.mgmt.security.v2019_08_01.operations.IotSecuritySolutionOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-08-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.device_security_groups = DeviceSecurityGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - self.iot_security_solution_analytics = IotSecuritySolutionAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - self.iot_security_solutions_analytics_aggregated_alert = IotSecuritySolutionsAnalyticsAggregatedAlertOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - self.iot_security_solutions_analytics_recommendation = IotSecuritySolutionsAnalyticsRecommendationOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - self.iot_security_solution = IotSecuritySolutionOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_configuration.py deleted file mode 100644 index 7ef246a11c03..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-08-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-08-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_security_center.py deleted file mode 100644 index b3565753ce47..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_security_center.py +++ /dev/null @@ -1,144 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - DeviceSecurityGroupsOperations, - IotSecuritySolutionAnalyticsOperations, - IotSecuritySolutionOperations, - IotSecuritySolutionsAnalyticsAggregatedAlertOperations, - IotSecuritySolutionsAnalyticsRecommendationOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar device_security_groups: DeviceSecurityGroupsOperations operations - :vartype device_security_groups: - azure.mgmt.security.v2019_08_01.aio.operations.DeviceSecurityGroupsOperations - :ivar iot_security_solution_analytics: IotSecuritySolutionAnalyticsOperations operations - :vartype iot_security_solution_analytics: - azure.mgmt.security.v2019_08_01.aio.operations.IotSecuritySolutionAnalyticsOperations - :ivar iot_security_solutions_analytics_aggregated_alert: - IotSecuritySolutionsAnalyticsAggregatedAlertOperations operations - :vartype iot_security_solutions_analytics_aggregated_alert: - azure.mgmt.security.v2019_08_01.aio.operations.IotSecuritySolutionsAnalyticsAggregatedAlertOperations - :ivar iot_security_solutions_analytics_recommendation: - IotSecuritySolutionsAnalyticsRecommendationOperations operations - :vartype iot_security_solutions_analytics_recommendation: - azure.mgmt.security.v2019_08_01.aio.operations.IotSecuritySolutionsAnalyticsRecommendationOperations - :ivar iot_security_solution: IotSecuritySolutionOperations operations - :vartype iot_security_solution: - azure.mgmt.security.v2019_08_01.aio.operations.IotSecuritySolutionOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-08-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.device_security_groups = DeviceSecurityGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - self.iot_security_solution_analytics = IotSecuritySolutionAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - self.iot_security_solutions_analytics_aggregated_alert = IotSecuritySolutionsAnalyticsAggregatedAlertOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - self.iot_security_solutions_analytics_recommendation = IotSecuritySolutionsAnalyticsRecommendationOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - self.iot_security_solution = IotSecuritySolutionOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/__init__.py deleted file mode 100644 index 8f30c8ed00eb..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/__init__.py +++ /dev/null @@ -1,31 +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 ._device_security_groups_operations import DeviceSecurityGroupsOperations -from ._iot_security_solution_analytics_operations import IotSecuritySolutionAnalyticsOperations -from ._iot_security_solutions_analytics_aggregated_alert_operations import ( - IotSecuritySolutionsAnalyticsAggregatedAlertOperations, -) -from ._iot_security_solutions_analytics_recommendation_operations import ( - IotSecuritySolutionsAnalyticsRecommendationOperations, -) -from ._iot_security_solution_operations import IotSecuritySolutionOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DeviceSecurityGroupsOperations", - "IotSecuritySolutionAnalyticsOperations", - "IotSecuritySolutionsAnalyticsAggregatedAlertOperations", - "IotSecuritySolutionsAnalyticsRecommendationOperations", - "IotSecuritySolutionOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_device_security_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_device_security_groups_operations.py deleted file mode 100644 index 00115af76de1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_device_security_groups_operations.py +++ /dev/null @@ -1,393 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._device_security_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DeviceSecurityGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.aio.SecurityCenter`'s - :attr:`device_security_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, resource_id: str, **kwargs: Any) -> AsyncIterable["_models.DeviceSecurityGroup"]: - """Use this method get the list of device security groups for the specified IoT Hub resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: An iterator like instance of either DeviceSecurityGroup or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.DeviceSecurityGroupList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_id=resource_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeviceSecurityGroupList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_id: str, device_security_group_name: str, **kwargs: Any - ) -> _models.DeviceSecurityGroup: - """Use this method to get the device security group for the specified IoT Hub resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :return: DeviceSecurityGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - device_security_group_name=device_security_group_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DeviceSecurityGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_id: str, - device_security_group_name: str, - device_security_group: _models.DeviceSecurityGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DeviceSecurityGroup: - """Use this method to creates or updates the device security group on a specified IoT Hub - resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :param device_security_group: Security group object. Required. - :type device_security_group: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DeviceSecurityGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_id: str, - device_security_group_name: str, - device_security_group: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DeviceSecurityGroup: - """Use this method to creates or updates the device security group on a specified IoT Hub - resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :param device_security_group: Security group object. Required. - :type device_security_group: 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: DeviceSecurityGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_id: str, - device_security_group_name: str, - device_security_group: Union[_models.DeviceSecurityGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DeviceSecurityGroup: - """Use this method to creates or updates the device security group on a specified IoT Hub - resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :param device_security_group: Security group object. Is either a DeviceSecurityGroup type or a - IO[bytes] type. Required. - :type device_security_group: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup or - IO[bytes] - :return: DeviceSecurityGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(device_security_group, (IOBase, bytes)): - _content = device_security_group - else: - _json = self._serialize.body(device_security_group, "DeviceSecurityGroup") - - _request = build_create_or_update_request( - resource_id=resource_id, - device_security_group_name=device_security_group_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DeviceSecurityGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DeviceSecurityGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_id: str, device_security_group_name: str, **kwargs: Any - ) -> None: - """User this method to deletes the device security group. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_id=resource_id, - device_security_group_name=device_security_group_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_analytics_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_analytics_operations.py deleted file mode 100644 index b48d661a04e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_analytics_operations.py +++ /dev/null @@ -1,173 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._iot_security_solution_analytics_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class IotSecuritySolutionAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.aio.SecurityCenter`'s - :attr:`iot_security_solution_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list( - self, resource_group_name: str, solution_name: str, **kwargs: Any - ) -> _models.IoTSecuritySolutionAnalyticsModelList: - """Use this method to get IoT security Analytics metrics in an array. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :return: IoTSecuritySolutionAnalyticsModelList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModelList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecuritySolutionAnalyticsModelList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, solution_name: str, **kwargs: Any - ) -> _models.IoTSecuritySolutionAnalyticsModel: - """Use this method to get IoT Security Analytics metrics. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :return: IoTSecuritySolutionAnalyticsModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionAnalyticsModel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecuritySolutionAnalyticsModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_operations.py deleted file mode 100644 index cee2b4986f67..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_operations.py +++ /dev/null @@ -1,625 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._iot_security_solution_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class IotSecuritySolutionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.aio.SecurityCenter`'s - :attr:`iot_security_solution` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_subscription( - self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.IoTSecuritySolutionModel"]: - """Use this method to get the list of IoT Security solutions by subscription. - - :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by - iotHubs. Default value is None. - :type filter: str - :return: An iterator like instance of either IoTSecuritySolutionModel or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("IoTSecuritySolutionsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.IoTSecuritySolutionModel"]: - """Use this method to get the list IoT Security solutions organized by resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by - iotHubs. Default value is None. - :type filter: str - :return: An iterator like instance of either IoTSecuritySolutionModel or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("IoTSecuritySolutionsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, solution_name: str, **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """User this method to get details of a specific IoT Security solution based on solution name. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_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, - solution_name: str, - iot_security_solution_data: _models.IoTSecuritySolutionModel, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to create or update yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param iot_security_solution_data: The security solution data. Required. - :type iot_security_solution_data: - ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - solution_name: str, - iot_security_solution_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to create or update yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param iot_security_solution_data: The security solution data. Required. - :type iot_security_solution_data: 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: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - solution_name: str, - iot_security_solution_data: Union[_models.IoTSecuritySolutionModel, IO[bytes]], - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to create or update yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param iot_security_solution_data: The security solution data. Is either a - IoTSecuritySolutionModel type or a IO[bytes] type. Required. - :type iot_security_solution_data: - ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel or IO[bytes] - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(iot_security_solution_data, (IOBase, bytes)): - _content = iot_security_solution_data - else: - _json = self._serialize.body(iot_security_solution_data, "IoTSecuritySolutionModel") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - solution_name: str, - update_iot_security_solution_data: _models.UpdateIotSecuritySolutionData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to update existing IoT Security solution tags or user defined resources. To - update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param update_iot_security_solution_data: The security solution data. Required. - :type update_iot_security_solution_data: - ~azure.mgmt.security.v2019_08_01.models.UpdateIotSecuritySolutionData - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - solution_name: str, - update_iot_security_solution_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to update existing IoT Security solution tags or user defined resources. To - update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param update_iot_security_solution_data: The security solution data. Required. - :type update_iot_security_solution_data: 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: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - solution_name: str, - update_iot_security_solution_data: Union[_models.UpdateIotSecuritySolutionData, IO[bytes]], - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to update existing IoT Security solution tags or user defined resources. To - update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param update_iot_security_solution_data: The security solution data. Is either a - UpdateIotSecuritySolutionData type or a IO[bytes] type. Required. - :type update_iot_security_solution_data: - ~azure.mgmt.security.v2019_08_01.models.UpdateIotSecuritySolutionData or IO[bytes] - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(update_iot_security_solution_data, (IOBase, bytes)): - _content = update_iot_security_solution_data - else: - _json = self._serialize.body(update_iot_security_solution_data, "UpdateIotSecuritySolutionData") - - _request = build_update_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, solution_name: str, **kwargs: Any - ) -> None: - """Use this method to delete yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py deleted file mode 100644 index 170fa2b896b3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py +++ /dev/null @@ -1,273 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._iot_security_solutions_analytics_aggregated_alert_operations import ( - build_dismiss_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class IotSecuritySolutionsAnalyticsAggregatedAlertOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.aio.SecurityCenter`'s - :attr:`iot_security_solutions_analytics_aggregated_alert` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, solution_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IoTSecurityAggregatedAlert"]: - """Use this method to get the aggregated alert list of yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param top: Number of results to retrieve. Default value is None. - :type top: int - :return: An iterator like instance of either IoTSecurityAggregatedAlert or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedAlert] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecurityAggregatedAlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("IoTSecurityAggregatedAlertList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, solution_name: str, aggregated_alert_name: str, **kwargs: Any - ) -> _models.IoTSecurityAggregatedAlert: - """Use this method to get a single the aggregated alert of yours IoT Security solution. This - aggregation is performed by alert name. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param aggregated_alert_name: Identifier of the aggregated alert. Required. - :type aggregated_alert_name: str - :return: IoTSecurityAggregatedAlert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedAlert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecurityAggregatedAlert] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - aggregated_alert_name=aggregated_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecurityAggregatedAlert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def dismiss( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, solution_name: str, aggregated_alert_name: str, **kwargs: Any - ) -> None: - """Use this method to dismiss an aggregated IoT Security Solution Alert. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param aggregated_alert_name: Identifier of the aggregated alert. Required. - :type aggregated_alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dismiss_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - aggregated_alert_name=aggregated_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py deleted file mode 100644 index 009d7d84fa6d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py +++ /dev/null @@ -1,217 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._iot_security_solutions_analytics_recommendation_operations import ( - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class IotSecuritySolutionsAnalyticsRecommendationOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.aio.SecurityCenter`'s - :attr:`iot_security_solutions_analytics_recommendation` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, resource_group_name: str, solution_name: str, aggregated_recommendation_name: str, **kwargs: Any - ) -> _models.IoTSecurityAggregatedRecommendation: - """Use this method to get the aggregated security analytics recommendation of yours IoT Security - solution. This aggregation is performed by recommendation name. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param aggregated_recommendation_name: Name of the recommendation aggregated for this query. - Required. - :type aggregated_recommendation_name: str - :return: IoTSecurityAggregatedRecommendation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedRecommendation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecurityAggregatedRecommendation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - aggregated_recommendation_name=aggregated_recommendation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecurityAggregatedRecommendation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, solution_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IoTSecurityAggregatedRecommendation"]: - """Use this method to get the list of aggregated security analytics recommendations of yours IoT - Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param top: Number of results to retrieve. Default value is None. - :type top: int - :return: An iterator like instance of either IoTSecurityAggregatedRecommendation or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedRecommendation] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecurityAggregatedRecommendationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("IoTSecurityAggregatedRecommendationList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/__init__.py deleted file mode 100644 index e29bbfcaafc5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/__init__.py +++ /dev/null @@ -1,141 +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 ._models_py3 import ActiveConnectionsNotInAllowedRange -from ._models_py3 import AdditionalWorkspacesProperties -from ._models_py3 import AllowlistCustomAlertRule -from ._models_py3 import AmqpC2DMessagesNotInAllowedRange -from ._models_py3 import AmqpC2DRejectedMessagesNotInAllowedRange -from ._models_py3 import AmqpD2CMessagesNotInAllowedRange -from ._models_py3 import CloudErrorBody -from ._models_py3 import ConnectionFromIpNotAllowed -from ._models_py3 import ConnectionToIpNotAllowed -from ._models_py3 import CustomAlertRule -from ._models_py3 import DenylistCustomAlertRule -from ._models_py3 import DeviceSecurityGroup -from ._models_py3 import DeviceSecurityGroupList -from ._models_py3 import DirectMethodInvokesNotInAllowedRange -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import FailedLocalLoginsNotInAllowedRange -from ._models_py3 import FileUploadsNotInAllowedRange -from ._models_py3 import HttpC2DMessagesNotInAllowedRange -from ._models_py3 import HttpC2DRejectedMessagesNotInAllowedRange -from ._models_py3 import HttpD2CMessagesNotInAllowedRange -from ._models_py3 import IoTSecurityAggregatedAlert -from ._models_py3 import IoTSecurityAggregatedAlertList -from ._models_py3 import IoTSecurityAggregatedAlertPropertiesTopDevicesListItem -from ._models_py3 import IoTSecurityAggregatedRecommendation -from ._models_py3 import IoTSecurityAggregatedRecommendationList -from ._models_py3 import IoTSecurityAlertedDevice -from ._models_py3 import IoTSecurityDeviceAlert -from ._models_py3 import IoTSecurityDeviceRecommendation -from ._models_py3 import IoTSecuritySolutionAnalyticsModel -from ._models_py3 import IoTSecuritySolutionAnalyticsModelList -from ._models_py3 import IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem -from ._models_py3 import IoTSecuritySolutionModel -from ._models_py3 import IoTSecuritySolutionsList -from ._models_py3 import IoTSeverityMetrics -from ._models_py3 import ListCustomAlertRule -from ._models_py3 import LocalUserNotAllowed -from ._models_py3 import MqttC2DMessagesNotInAllowedRange -from ._models_py3 import MqttC2DRejectedMessagesNotInAllowedRange -from ._models_py3 import MqttD2CMessagesNotInAllowedRange -from ._models_py3 import ProcessNotAllowed -from ._models_py3 import QueuePurgesNotInAllowedRange -from ._models_py3 import RecommendationConfigurationProperties -from ._models_py3 import Resource -from ._models_py3 import SystemData -from ._models_py3 import TagsResource -from ._models_py3 import ThresholdCustomAlertRule -from ._models_py3 import TimeWindowCustomAlertRule -from ._models_py3 import TwinUpdatesNotInAllowedRange -from ._models_py3 import UnauthorizedOperationsNotInAllowedRange -from ._models_py3 import UpdateIotSecuritySolutionData -from ._models_py3 import UserDefinedResourcesProperties - -from ._security_center_enums import AdditionalWorkspaceDataType -from ._security_center_enums import AdditionalWorkspaceType -from ._security_center_enums import CreatedByType -from ._security_center_enums import DataSource -from ._security_center_enums import ExportData -from ._security_center_enums import RecommendationConfigStatus -from ._security_center_enums import RecommendationType -from ._security_center_enums import ReportedSeverity -from ._security_center_enums import SecuritySolutionStatus -from ._security_center_enums import UnmaskedIpLoggingStatus -from ._security_center_enums import ValueType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActiveConnectionsNotInAllowedRange", - "AdditionalWorkspacesProperties", - "AllowlistCustomAlertRule", - "AmqpC2DMessagesNotInAllowedRange", - "AmqpC2DRejectedMessagesNotInAllowedRange", - "AmqpD2CMessagesNotInAllowedRange", - "CloudErrorBody", - "ConnectionFromIpNotAllowed", - "ConnectionToIpNotAllowed", - "CustomAlertRule", - "DenylistCustomAlertRule", - "DeviceSecurityGroup", - "DeviceSecurityGroupList", - "DirectMethodInvokesNotInAllowedRange", - "ErrorAdditionalInfo", - "FailedLocalLoginsNotInAllowedRange", - "FileUploadsNotInAllowedRange", - "HttpC2DMessagesNotInAllowedRange", - "HttpC2DRejectedMessagesNotInAllowedRange", - "HttpD2CMessagesNotInAllowedRange", - "IoTSecurityAggregatedAlert", - "IoTSecurityAggregatedAlertList", - "IoTSecurityAggregatedAlertPropertiesTopDevicesListItem", - "IoTSecurityAggregatedRecommendation", - "IoTSecurityAggregatedRecommendationList", - "IoTSecurityAlertedDevice", - "IoTSecurityDeviceAlert", - "IoTSecurityDeviceRecommendation", - "IoTSecuritySolutionAnalyticsModel", - "IoTSecuritySolutionAnalyticsModelList", - "IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem", - "IoTSecuritySolutionModel", - "IoTSecuritySolutionsList", - "IoTSeverityMetrics", - "ListCustomAlertRule", - "LocalUserNotAllowed", - "MqttC2DMessagesNotInAllowedRange", - "MqttC2DRejectedMessagesNotInAllowedRange", - "MqttD2CMessagesNotInAllowedRange", - "ProcessNotAllowed", - "QueuePurgesNotInAllowedRange", - "RecommendationConfigurationProperties", - "Resource", - "SystemData", - "TagsResource", - "ThresholdCustomAlertRule", - "TimeWindowCustomAlertRule", - "TwinUpdatesNotInAllowedRange", - "UnauthorizedOperationsNotInAllowedRange", - "UpdateIotSecuritySolutionData", - "UserDefinedResourcesProperties", - "AdditionalWorkspaceDataType", - "AdditionalWorkspaceType", - "CreatedByType", - "DataSource", - "ExportData", - "RecommendationConfigStatus", - "RecommendationType", - "ReportedSeverity", - "SecuritySolutionStatus", - "UnmaskedIpLoggingStatus", - "ValueType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_models_py3.py deleted file mode 100644 index ab705a25edb9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_models_py3.py +++ /dev/null @@ -1,3032 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CustomAlertRule(_serialization.Model): - """A custom alert rule. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ListCustomAlertRule, ThresholdCustomAlertRule - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - } - - _subtype_map = { - "rule_type": { - "ListCustomAlertRule": "ListCustomAlertRule", - "ThresholdCustomAlertRule": "ThresholdCustomAlertRule", - } - } - - def __init__(self, *, is_enabled: bool, **kwargs: Any) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - """ - super().__init__(**kwargs) - self.display_name = None - self.description = None - self.is_enabled = is_enabled - self.rule_type: Optional[str] = None - - -class ThresholdCustomAlertRule(CustomAlertRule): - """A custom alert rule that checks if a value (depends on the custom alert type) is within the - given range. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - TimeWindowCustomAlertRule - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - } - - _subtype_map = {"rule_type": {"TimeWindowCustomAlertRule": "TimeWindowCustomAlertRule"}} - - def __init__(self, *, is_enabled: bool, min_threshold: int, max_threshold: int, **kwargs: Any) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - """ - super().__init__(is_enabled=is_enabled, **kwargs) - self.rule_type: str = "ThresholdCustomAlertRule" - self.min_threshold = min_threshold - self.max_threshold = max_threshold - - -class TimeWindowCustomAlertRule(ThresholdCustomAlertRule): - """A custom alert rule that checks if the number of activities (depends on the custom alert type) - in a time window is within the given range. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ActiveConnectionsNotInAllowedRange, AmqpC2DMessagesNotInAllowedRange, - AmqpC2DRejectedMessagesNotInAllowedRange, AmqpD2CMessagesNotInAllowedRange, - DirectMethodInvokesNotInAllowedRange, FailedLocalLoginsNotInAllowedRange, - FileUploadsNotInAllowedRange, HttpC2DMessagesNotInAllowedRange, - HttpC2DRejectedMessagesNotInAllowedRange, HttpD2CMessagesNotInAllowedRange, - MqttC2DMessagesNotInAllowedRange, MqttC2DRejectedMessagesNotInAllowedRange, - MqttD2CMessagesNotInAllowedRange, QueuePurgesNotInAllowedRange, TwinUpdatesNotInAllowedRange, - UnauthorizedOperationsNotInAllowedRange - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - _subtype_map = { - "rule_type": { - "ActiveConnectionsNotInAllowedRange": "ActiveConnectionsNotInAllowedRange", - "AmqpC2DMessagesNotInAllowedRange": "AmqpC2DMessagesNotInAllowedRange", - "AmqpC2DRejectedMessagesNotInAllowedRange": "AmqpC2DRejectedMessagesNotInAllowedRange", - "AmqpD2CMessagesNotInAllowedRange": "AmqpD2CMessagesNotInAllowedRange", - "DirectMethodInvokesNotInAllowedRange": "DirectMethodInvokesNotInAllowedRange", - "FailedLocalLoginsNotInAllowedRange": "FailedLocalLoginsNotInAllowedRange", - "FileUploadsNotInAllowedRange": "FileUploadsNotInAllowedRange", - "HttpC2DMessagesNotInAllowedRange": "HttpC2DMessagesNotInAllowedRange", - "HttpC2DRejectedMessagesNotInAllowedRange": "HttpC2DRejectedMessagesNotInAllowedRange", - "HttpD2CMessagesNotInAllowedRange": "HttpD2CMessagesNotInAllowedRange", - "MqttC2DMessagesNotInAllowedRange": "MqttC2DMessagesNotInAllowedRange", - "MqttC2DRejectedMessagesNotInAllowedRange": "MqttC2DRejectedMessagesNotInAllowedRange", - "MqttD2CMessagesNotInAllowedRange": "MqttD2CMessagesNotInAllowedRange", - "QueuePurgesNotInAllowedRange": "QueuePurgesNotInAllowedRange", - "TwinUpdatesNotInAllowedRange": "TwinUpdatesNotInAllowedRange", - "UnauthorizedOperationsNotInAllowedRange": "UnauthorizedOperationsNotInAllowedRange", - } - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, **kwargs) - self.rule_type: str = "TimeWindowCustomAlertRule" - self.time_window_size = time_window_size - - -class ActiveConnectionsNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of active connections is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "ActiveConnectionsNotInAllowedRange" - - -class AdditionalWorkspacesProperties(_serialization.Model): - """Properties of the additional workspaces. - - :ivar workspace: Workspace resource id. - :vartype workspace: str - :ivar type: Workspace type. "Sentinel" - :vartype type: str or ~azure.mgmt.security.v2019_08_01.models.AdditionalWorkspaceType - :ivar data_types: List of data types sent to workspace. - :vartype data_types: list[str or - ~azure.mgmt.security.v2019_08_01.models.AdditionalWorkspaceDataType] - """ - - _attribute_map = { - "workspace": {"key": "workspace", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "data_types": {"key": "dataTypes", "type": "[str]"}, - } - - def __init__( - self, - *, - workspace: Optional[str] = None, - type: Union[str, "_models.AdditionalWorkspaceType"] = "Sentinel", - data_types: Optional[List[Union[str, "_models.AdditionalWorkspaceDataType"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword workspace: Workspace resource id. - :paramtype workspace: str - :keyword type: Workspace type. "Sentinel" - :paramtype type: str or ~azure.mgmt.security.v2019_08_01.models.AdditionalWorkspaceType - :keyword data_types: List of data types sent to workspace. - :paramtype data_types: list[str or - ~azure.mgmt.security.v2019_08_01.models.AdditionalWorkspaceDataType] - """ - super().__init__(**kwargs) - self.workspace = workspace - self.type = type - self.data_types = data_types - - -class ListCustomAlertRule(CustomAlertRule): - """A List custom alert rule. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AllowlistCustomAlertRule, DenylistCustomAlertRule - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and - "String". - :vartype value_type: str or ~azure.mgmt.security.v2019_08_01.models.ValueType - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "value_type": {"readonly": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "value_type": {"key": "valueType", "type": "str"}, - } - - _subtype_map = { - "rule_type": { - "AllowlistCustomAlertRule": "AllowlistCustomAlertRule", - "DenylistCustomAlertRule": "DenylistCustomAlertRule", - } - } - - def __init__(self, *, is_enabled: bool, **kwargs: Any) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - """ - super().__init__(is_enabled=is_enabled, **kwargs) - self.rule_type: str = "ListCustomAlertRule" - self.value_type = None - - -class AllowlistCustomAlertRule(ListCustomAlertRule): - """A custom alert rule that checks if a value (depends on the custom alert type) is allowed. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ConnectionFromIpNotAllowed, ConnectionToIpNotAllowed, LocalUserNotAllowed, ProcessNotAllowed - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and - "String". - :vartype value_type: str or ~azure.mgmt.security.v2019_08_01.models.ValueType - :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. - Required. - :vartype allowlist_values: list[str] - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "value_type": {"readonly": True}, - "allowlist_values": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "value_type": {"key": "valueType", "type": "str"}, - "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, - } - - _subtype_map = { - "rule_type": { - "ConnectionFromIpNotAllowed": "ConnectionFromIpNotAllowed", - "ConnectionToIpNotAllowed": "ConnectionToIpNotAllowed", - "LocalUserNotAllowed": "LocalUserNotAllowed", - "ProcessNotAllowed": "ProcessNotAllowed", - } - } - - def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword allowlist_values: The values to allow. The format of the values depends on the rule - type. Required. - :paramtype allowlist_values: list[str] - """ - super().__init__(is_enabled=is_enabled, **kwargs) - self.rule_type: str = "AllowlistCustomAlertRule" - self.allowlist_values = allowlist_values - - -class AmqpC2DMessagesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of cloud to device messages (AMQP protocol) is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "AmqpC2DMessagesNotInAllowedRange" - - -class AmqpC2DRejectedMessagesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of rejected cloud to device messages (AMQP protocol) is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "AmqpC2DRejectedMessagesNotInAllowedRange" - - -class AmqpD2CMessagesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of device to cloud messages (AMQP protocol) is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "AmqpD2CMessagesNotInAllowedRange" - - -class CloudErrorBody(_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.security.v2019_08_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2019_08_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ConnectionFromIpNotAllowed(AllowlistCustomAlertRule): - """Inbound connection from an ip that isn't allowed. Allow list consists of ipv4 or ipv6 range in - CIDR notation. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and - "String". - :vartype value_type: str or ~azure.mgmt.security.v2019_08_01.models.ValueType - :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. - Required. - :vartype allowlist_values: list[str] - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "value_type": {"readonly": True}, - "allowlist_values": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "value_type": {"key": "valueType", "type": "str"}, - "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, - } - - def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword allowlist_values: The values to allow. The format of the values depends on the rule - type. Required. - :paramtype allowlist_values: list[str] - """ - super().__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) - self.rule_type: str = "ConnectionFromIpNotAllowed" - - -class ConnectionToIpNotAllowed(AllowlistCustomAlertRule): - """Outbound connection to an ip that isn't allowed. Allow list consists of ipv4 or ipv6 range in - CIDR notation. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and - "String". - :vartype value_type: str or ~azure.mgmt.security.v2019_08_01.models.ValueType - :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. - Required. - :vartype allowlist_values: list[str] - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "value_type": {"readonly": True}, - "allowlist_values": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "value_type": {"key": "valueType", "type": "str"}, - "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, - } - - def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword allowlist_values: The values to allow. The format of the values depends on the rule - type. Required. - :paramtype allowlist_values: list[str] - """ - super().__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) - self.rule_type: str = "ConnectionToIpNotAllowed" - - -class DenylistCustomAlertRule(ListCustomAlertRule): - """A custom alert rule that checks if a value (depends on the custom alert type) is denied. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and - "String". - :vartype value_type: str or ~azure.mgmt.security.v2019_08_01.models.ValueType - :ivar denylist_values: The values to deny. The format of the values depends on the rule type. - Required. - :vartype denylist_values: list[str] - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "value_type": {"readonly": True}, - "denylist_values": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "value_type": {"key": "valueType", "type": "str"}, - "denylist_values": {"key": "denylistValues", "type": "[str]"}, - } - - def __init__(self, *, is_enabled: bool, denylist_values: List[str], **kwargs: Any) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword denylist_values: The values to deny. The format of the values depends on the rule - type. Required. - :paramtype denylist_values: list[str] - """ - super().__init__(is_enabled=is_enabled, **kwargs) - self.rule_type: str = "DenylistCustomAlertRule" - self.denylist_values = denylist_values - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DeviceSecurityGroup(Resource): - """The device security group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar threshold_rules: The list of custom alert threshold rules. - :vartype threshold_rules: - list[~azure.mgmt.security.v2019_08_01.models.ThresholdCustomAlertRule] - :ivar time_window_rules: The list of custom alert time-window rules. - :vartype time_window_rules: - list[~azure.mgmt.security.v2019_08_01.models.TimeWindowCustomAlertRule] - :ivar allowlist_rules: The allow-list custom alert rules. - :vartype allowlist_rules: - list[~azure.mgmt.security.v2019_08_01.models.AllowlistCustomAlertRule] - :ivar denylist_rules: The deny-list custom alert rules. - :vartype denylist_rules: list[~azure.mgmt.security.v2019_08_01.models.DenylistCustomAlertRule] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "threshold_rules": {"key": "properties.thresholdRules", "type": "[ThresholdCustomAlertRule]"}, - "time_window_rules": {"key": "properties.timeWindowRules", "type": "[TimeWindowCustomAlertRule]"}, - "allowlist_rules": {"key": "properties.allowlistRules", "type": "[AllowlistCustomAlertRule]"}, - "denylist_rules": {"key": "properties.denylistRules", "type": "[DenylistCustomAlertRule]"}, - } - - def __init__( - self, - *, - threshold_rules: Optional[List["_models.ThresholdCustomAlertRule"]] = None, - time_window_rules: Optional[List["_models.TimeWindowCustomAlertRule"]] = None, - allowlist_rules: Optional[List["_models.AllowlistCustomAlertRule"]] = None, - denylist_rules: Optional[List["_models.DenylistCustomAlertRule"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword threshold_rules: The list of custom alert threshold rules. - :paramtype threshold_rules: - list[~azure.mgmt.security.v2019_08_01.models.ThresholdCustomAlertRule] - :keyword time_window_rules: The list of custom alert time-window rules. - :paramtype time_window_rules: - list[~azure.mgmt.security.v2019_08_01.models.TimeWindowCustomAlertRule] - :keyword allowlist_rules: The allow-list custom alert rules. - :paramtype allowlist_rules: - list[~azure.mgmt.security.v2019_08_01.models.AllowlistCustomAlertRule] - :keyword denylist_rules: The deny-list custom alert rules. - :paramtype denylist_rules: - list[~azure.mgmt.security.v2019_08_01.models.DenylistCustomAlertRule] - """ - super().__init__(**kwargs) - self.threshold_rules = threshold_rules - self.time_window_rules = time_window_rules - self.allowlist_rules = allowlist_rules - self.denylist_rules = denylist_rules - - -class DeviceSecurityGroupList(_serialization.Model): - """List of device security groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of device security group objects. - :vartype value: list[~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DeviceSecurityGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.DeviceSecurityGroup"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of device security group objects. - :paramtype value: list[~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class DirectMethodInvokesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of direct method invokes is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "DirectMethodInvokesNotInAllowedRange" - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class FailedLocalLoginsNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of failed local logins is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "FailedLocalLoginsNotInAllowedRange" - - -class FileUploadsNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of file uploads is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "FileUploadsNotInAllowedRange" - - -class HttpC2DMessagesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of cloud to device messages (HTTP protocol) is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "HttpC2DMessagesNotInAllowedRange" - - -class HttpC2DRejectedMessagesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of rejected cloud to device messages (HTTP protocol) is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "HttpC2DRejectedMessagesNotInAllowedRange" - - -class HttpD2CMessagesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of device to cloud messages (HTTP protocol) is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "HttpD2CMessagesNotInAllowedRange" - - -class TagsResource(_serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class IoTSecurityAggregatedAlert(Resource, TagsResource): # pylint: disable=too-many-instance-attributes - """Security Solution Aggregated Alert information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar alert_type: Name of the alert type. - :vartype alert_type: str - :ivar alert_display_name: Display name of the alert type. - :vartype alert_display_name: str - :ivar aggregated_date_utc: Date of detection. - :vartype aggregated_date_utc: ~datetime.date - :ivar vendor_name: Name of the organization that raised the alert. - :vartype vendor_name: str - :ivar reported_severity: Assessed alert severity. Known values are: "Informational", "Low", - "Medium", and "High". - :vartype reported_severity: str or ~azure.mgmt.security.v2019_08_01.models.ReportedSeverity - :ivar remediation_steps: Recommended steps for remediation. - :vartype remediation_steps: str - :ivar description: Description of the suspected vulnerability and meaning. - :vartype description: str - :ivar count: Number of alerts occurrences within the aggregated time window. - :vartype count: int - :ivar effected_resource_type: Azure resource ID of the resource that received the alerts. - :vartype effected_resource_type: str - :ivar system_source: The type of the alerted resource (Azure, Non-Azure). - :vartype system_source: str - :ivar action_taken: IoT Security solution alert response. - :vartype action_taken: str - :ivar log_analytics_query: Log analytics query for getting the list of affected devices/alerts. - :vartype log_analytics_query: str - :ivar top_devices_list: 10 devices with the highest number of occurrences of this alert type, - on this day. - :vartype top_devices_list: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedAlertPropertiesTopDevicesListItem] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "alert_type": {"readonly": True}, - "alert_display_name": {"readonly": True}, - "aggregated_date_utc": {"readonly": True}, - "vendor_name": {"readonly": True}, - "reported_severity": {"readonly": True}, - "remediation_steps": {"readonly": True}, - "description": {"readonly": True}, - "count": {"readonly": True}, - "effected_resource_type": {"readonly": True}, - "system_source": {"readonly": True}, - "action_taken": {"readonly": True}, - "log_analytics_query": {"readonly": True}, - "top_devices_list": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "alert_type": {"key": "properties.alertType", "type": "str"}, - "alert_display_name": {"key": "properties.alertDisplayName", "type": "str"}, - "aggregated_date_utc": {"key": "properties.aggregatedDateUtc", "type": "date"}, - "vendor_name": {"key": "properties.vendorName", "type": "str"}, - "reported_severity": {"key": "properties.reportedSeverity", "type": "str"}, - "remediation_steps": {"key": "properties.remediationSteps", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "count": {"key": "properties.count", "type": "int"}, - "effected_resource_type": {"key": "properties.effectedResourceType", "type": "str"}, - "system_source": {"key": "properties.systemSource", "type": "str"}, - "action_taken": {"key": "properties.actionTaken", "type": "str"}, - "log_analytics_query": {"key": "properties.logAnalyticsQuery", "type": "str"}, - "top_devices_list": { - "key": "properties.topDevicesList", - "type": "[IoTSecurityAggregatedAlertPropertiesTopDevicesListItem]", - }, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(tags=tags, **kwargs) - self.tags = tags - self.alert_type = None - self.alert_display_name = None - self.aggregated_date_utc = None - self.vendor_name = None - self.reported_severity = None - self.remediation_steps = None - self.description = None - self.count = None - self.effected_resource_type = None - self.system_source = None - self.action_taken = None - self.log_analytics_query = None - self.top_devices_list = None - self.id = None - self.name = None - self.type = None - - -class IoTSecurityAggregatedAlertList(_serialization.Model): - """List of IoT Security solution aggregated alert data. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: List of aggregated alerts data. Required. - :vartype value: list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedAlert] - :ivar next_link: When there is too much alert data for one page, use this URI to fetch the next - page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[IoTSecurityAggregatedAlert]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.IoTSecurityAggregatedAlert"], **kwargs: Any) -> None: - """ - :keyword value: List of aggregated alerts data. Required. - :paramtype value: list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedAlert] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class IoTSecurityAggregatedAlertPropertiesTopDevicesListItem(_serialization.Model): # pylint: disable=name-too-long - """IoTSecurityAggregatedAlertPropertiesTopDevicesListItem. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar device_id: Name of the device. - :vartype device_id: str - :ivar alerts_count: Number of alerts raised for this device. - :vartype alerts_count: int - :ivar last_occurrence: Most recent time this alert was raised for this device, on this day. - :vartype last_occurrence: str - """ - - _validation = { - "device_id": {"readonly": True}, - "alerts_count": {"readonly": True}, - "last_occurrence": {"readonly": True}, - } - - _attribute_map = { - "device_id": {"key": "deviceId", "type": "str"}, - "alerts_count": {"key": "alertsCount", "type": "int"}, - "last_occurrence": {"key": "lastOccurrence", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.device_id = None - self.alerts_count = None - self.last_occurrence = None - - -class IoTSecurityAggregatedRecommendation(Resource, TagsResource): # pylint: disable=too-many-instance-attributes - """IoT Security solution recommendation information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar recommendation_name: Name of the recommendation. - :vartype recommendation_name: str - :ivar recommendation_display_name: Display name of the recommendation type. - :vartype recommendation_display_name: str - :ivar description: Description of the suspected vulnerability and meaning. - :vartype description: str - :ivar recommendation_type_id: Recommendation-type GUID. - :vartype recommendation_type_id: str - :ivar detected_by: Name of the organization that made the recommendation. - :vartype detected_by: str - :ivar remediation_steps: Recommended steps for remediation. - :vartype remediation_steps: str - :ivar reported_severity: Assessed recommendation severity. Known values are: "Informational", - "Low", "Medium", and "High". - :vartype reported_severity: str or ~azure.mgmt.security.v2019_08_01.models.ReportedSeverity - :ivar healthy_devices: Number of healthy devices within the IoT Security solution. - :vartype healthy_devices: int - :ivar unhealthy_device_count: Number of unhealthy devices within the IoT Security solution. - :vartype unhealthy_device_count: int - :ivar log_analytics_query: Log analytics query for getting the list of affected devices/alerts. - :vartype log_analytics_query: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "recommendation_display_name": {"readonly": True}, - "description": {"readonly": True}, - "recommendation_type_id": {"readonly": True}, - "detected_by": {"readonly": True}, - "remediation_steps": {"readonly": True}, - "reported_severity": {"readonly": True}, - "healthy_devices": {"readonly": True}, - "unhealthy_device_count": {"readonly": True}, - "log_analytics_query": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "recommendation_name": {"key": "properties.recommendationName", "type": "str"}, - "recommendation_display_name": {"key": "properties.recommendationDisplayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "recommendation_type_id": {"key": "properties.recommendationTypeId", "type": "str"}, - "detected_by": {"key": "properties.detectedBy", "type": "str"}, - "remediation_steps": {"key": "properties.remediationSteps", "type": "str"}, - "reported_severity": {"key": "properties.reportedSeverity", "type": "str"}, - "healthy_devices": {"key": "properties.healthyDevices", "type": "int"}, - "unhealthy_device_count": {"key": "properties.unhealthyDeviceCount", "type": "int"}, - "log_analytics_query": {"key": "properties.logAnalyticsQuery", "type": "str"}, - } - - def __init__( - self, *, tags: Optional[Dict[str, str]] = None, recommendation_name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword recommendation_name: Name of the recommendation. - :paramtype recommendation_name: str - """ - super().__init__(tags=tags, **kwargs) - self.tags = tags - self.recommendation_name = recommendation_name - self.recommendation_display_name = None - self.description = None - self.recommendation_type_id = None - self.detected_by = None - self.remediation_steps = None - self.reported_severity = None - self.healthy_devices = None - self.unhealthy_device_count = None - self.log_analytics_query = None - self.id = None - self.name = None - self.type = None - - -class IoTSecurityAggregatedRecommendationList(_serialization.Model): - """List of IoT Security solution aggregated recommendations. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: List of aggregated recommendations data. Required. - :vartype value: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedRecommendation] - :ivar next_link: When there is too much alert data for one page, use this URI to fetch the next - page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[IoTSecurityAggregatedRecommendation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.IoTSecurityAggregatedRecommendation"], **kwargs: Any) -> None: - """ - :keyword value: List of aggregated recommendations data. Required. - :paramtype value: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedRecommendation] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class IoTSecurityAlertedDevice(_serialization.Model): - """Statistical information about the number of alerts per device during last set number of days. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar device_id: Device identifier. - :vartype device_id: str - :ivar alerts_count: Number of alerts raised for this device. - :vartype alerts_count: int - """ - - _validation = { - "device_id": {"readonly": True}, - "alerts_count": {"readonly": True}, - } - - _attribute_map = { - "device_id": {"key": "deviceId", "type": "str"}, - "alerts_count": {"key": "alertsCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.device_id = None - self.alerts_count = None - - -class IoTSecurityDeviceAlert(_serialization.Model): - """Statistical information about the number of alerts per alert type during last set number of - days. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar alert_display_name: Display name of the alert. - :vartype alert_display_name: str - :ivar reported_severity: Assessed Alert severity. Known values are: "Informational", "Low", - "Medium", and "High". - :vartype reported_severity: str or ~azure.mgmt.security.v2019_08_01.models.ReportedSeverity - :ivar alerts_count: Number of alerts raised for this alert type. - :vartype alerts_count: int - """ - - _validation = { - "alert_display_name": {"readonly": True}, - "reported_severity": {"readonly": True}, - "alerts_count": {"readonly": True}, - } - - _attribute_map = { - "alert_display_name": {"key": "alertDisplayName", "type": "str"}, - "reported_severity": {"key": "reportedSeverity", "type": "str"}, - "alerts_count": {"key": "alertsCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.alert_display_name = None - self.reported_severity = None - self.alerts_count = None - - -class IoTSecurityDeviceRecommendation(_serialization.Model): - """Statistical information about the number of recommendations per device, per recommendation - type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendation_display_name: Display name of the recommendation. - :vartype recommendation_display_name: str - :ivar reported_severity: Assessed recommendation severity. Known values are: "Informational", - "Low", "Medium", and "High". - :vartype reported_severity: str or ~azure.mgmt.security.v2019_08_01.models.ReportedSeverity - :ivar devices_count: Number of devices with this recommendation. - :vartype devices_count: int - """ - - _validation = { - "recommendation_display_name": {"readonly": True}, - "reported_severity": {"readonly": True}, - "devices_count": {"readonly": True}, - } - - _attribute_map = { - "recommendation_display_name": {"key": "recommendationDisplayName", "type": "str"}, - "reported_severity": {"key": "reportedSeverity", "type": "str"}, - "devices_count": {"key": "devicesCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.recommendation_display_name = None - self.reported_severity = None - self.devices_count = None - - -class IoTSecuritySolutionAnalyticsModel(Resource): - """Security analytics of your IoT Security solution. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar metrics: Security analytics of your IoT Security solution. - :vartype metrics: ~azure.mgmt.security.v2019_08_01.models.IoTSeverityMetrics - :ivar unhealthy_device_count: Number of unhealthy devices within your IoT Security solution. - :vartype unhealthy_device_count: int - :ivar devices_metrics: List of device metrics by the aggregation date. - :vartype devices_metrics: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem] - :ivar top_alerted_devices: List of the 3 devices with the most alerts. - :vartype top_alerted_devices: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAlertedDevice] - :ivar most_prevalent_device_alerts: List of the 3 most prevalent device alerts. - :vartype most_prevalent_device_alerts: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityDeviceAlert] - :ivar most_prevalent_device_recommendations: List of the 3 most prevalent device - recommendations. - :vartype most_prevalent_device_recommendations: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityDeviceRecommendation] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "metrics": {"readonly": True}, - "unhealthy_device_count": {"readonly": True}, - "devices_metrics": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "metrics": {"key": "properties.metrics", "type": "IoTSeverityMetrics"}, - "unhealthy_device_count": {"key": "properties.unhealthyDeviceCount", "type": "int"}, - "devices_metrics": { - "key": "properties.devicesMetrics", - "type": "[IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem]", - }, - "top_alerted_devices": {"key": "properties.topAlertedDevices", "type": "[IoTSecurityAlertedDevice]"}, - "most_prevalent_device_alerts": { - "key": "properties.mostPrevalentDeviceAlerts", - "type": "[IoTSecurityDeviceAlert]", - }, - "most_prevalent_device_recommendations": { - "key": "properties.mostPrevalentDeviceRecommendations", - "type": "[IoTSecurityDeviceRecommendation]", - }, - } - - def __init__( - self, - *, - top_alerted_devices: Optional[List["_models.IoTSecurityAlertedDevice"]] = None, - most_prevalent_device_alerts: Optional[List["_models.IoTSecurityDeviceAlert"]] = None, - most_prevalent_device_recommendations: Optional[List["_models.IoTSecurityDeviceRecommendation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword top_alerted_devices: List of the 3 devices with the most alerts. - :paramtype top_alerted_devices: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAlertedDevice] - :keyword most_prevalent_device_alerts: List of the 3 most prevalent device alerts. - :paramtype most_prevalent_device_alerts: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityDeviceAlert] - :keyword most_prevalent_device_recommendations: List of the 3 most prevalent device - recommendations. - :paramtype most_prevalent_device_recommendations: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecurityDeviceRecommendation] - """ - super().__init__(**kwargs) - self.metrics = None - self.unhealthy_device_count = None - self.devices_metrics = None - self.top_alerted_devices = top_alerted_devices - self.most_prevalent_device_alerts = most_prevalent_device_alerts - self.most_prevalent_device_recommendations = most_prevalent_device_recommendations - - -class IoTSecuritySolutionAnalyticsModelList(_serialization.Model): - """List of Security analytics of your IoT Security solution. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: List of Security analytics of your IoT Security solution. Required. - :vartype value: list[~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModel] - :ivar next_link: When there is too much alert data for one page, use this URI to fetch the next - page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[IoTSecuritySolutionAnalyticsModel]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.IoTSecuritySolutionAnalyticsModel"], **kwargs: Any) -> None: - """ - :keyword value: List of Security analytics of your IoT Security solution. Required. - :paramtype value: - list[~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModel] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem( - _serialization.Model -): # pylint: disable=name-too-long - """IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem. - - :ivar date: Aggregation of IoT Security solution device alert metrics by date. - :vartype date: ~datetime.datetime - :ivar devices_metrics: Device alert count by severity. - :vartype devices_metrics: ~azure.mgmt.security.v2019_08_01.models.IoTSeverityMetrics - """ - - _attribute_map = { - "date": {"key": "date", "type": "iso-8601"}, - "devices_metrics": {"key": "devicesMetrics", "type": "IoTSeverityMetrics"}, - } - - def __init__( - self, - *, - date: Optional[datetime.datetime] = None, - devices_metrics: Optional["_models.IoTSeverityMetrics"] = None, - **kwargs: Any - ) -> None: - """ - :keyword date: Aggregation of IoT Security solution device alert metrics by date. - :paramtype date: ~datetime.datetime - :keyword devices_metrics: Device alert count by severity. - :paramtype devices_metrics: ~azure.mgmt.security.v2019_08_01.models.IoTSeverityMetrics - """ - super().__init__(**kwargs) - self.date = date - self.devices_metrics = devices_metrics - - -class IoTSecuritySolutionModel(Resource, TagsResource): # pylint: disable=too-many-instance-attributes - """IoT Security solution configuration and resource information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: The resource location. - :vartype location: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2019_08_01.models.SystemData - :ivar workspace: Workspace resource ID. - :vartype workspace: str - :ivar display_name: Resource display name. - :vartype display_name: str - :ivar status: Status of the IoT Security solution. Known values are: "Enabled" and "Disabled". - :vartype status: str or ~azure.mgmt.security.v2019_08_01.models.SecuritySolutionStatus - :ivar export: List of additional options for exporting to workspace data. - :vartype export: list[str or ~azure.mgmt.security.v2019_08_01.models.ExportData] - :ivar disabled_data_sources: Disabled data sources. Disabling these data sources compromises - the system. - :vartype disabled_data_sources: list[str or ~azure.mgmt.security.v2019_08_01.models.DataSource] - :ivar iot_hubs: IoT Hub resource IDs. - :vartype iot_hubs: list[str] - :ivar user_defined_resources: Properties of the IoT Security solution's user defined resources. - :vartype user_defined_resources: - ~azure.mgmt.security.v2019_08_01.models.UserDefinedResourcesProperties - :ivar auto_discovered_resources: List of resources that were automatically discovered as - relevant to the security solution. - :vartype auto_discovered_resources: list[str] - :ivar recommendations_configuration: List of the configuration status for each recommendation - type. - :vartype recommendations_configuration: - list[~azure.mgmt.security.v2019_08_01.models.RecommendationConfigurationProperties] - :ivar unmasked_ip_logging_status: Unmasked IP address logging status. Known values are: - "Disabled" and "Enabled". - :vartype unmasked_ip_logging_status: str or - ~azure.mgmt.security.v2019_08_01.models.UnmaskedIpLoggingStatus - :ivar additional_workspaces: List of additional workspaces. - :vartype additional_workspaces: - list[~azure.mgmt.security.v2019_08_01.models.AdditionalWorkspacesProperties] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "auto_discovered_resources": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "workspace": {"key": "properties.workspace", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "export": {"key": "properties.export", "type": "[str]"}, - "disabled_data_sources": {"key": "properties.disabledDataSources", "type": "[str]"}, - "iot_hubs": {"key": "properties.iotHubs", "type": "[str]"}, - "user_defined_resources": {"key": "properties.userDefinedResources", "type": "UserDefinedResourcesProperties"}, - "auto_discovered_resources": {"key": "properties.autoDiscoveredResources", "type": "[str]"}, - "recommendations_configuration": { - "key": "properties.recommendationsConfiguration", - "type": "[RecommendationConfigurationProperties]", - }, - "unmasked_ip_logging_status": {"key": "properties.unmaskedIpLoggingStatus", "type": "str"}, - "additional_workspaces": {"key": "properties.additionalWorkspaces", "type": "[AdditionalWorkspacesProperties]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - location: Optional[str] = None, - workspace: Optional[str] = None, - display_name: Optional[str] = None, - status: Union[str, "_models.SecuritySolutionStatus"] = "Enabled", - export: Optional[List[Union[str, "_models.ExportData"]]] = None, - disabled_data_sources: Optional[List[Union[str, "_models.DataSource"]]] = None, - iot_hubs: Optional[List[str]] = None, - user_defined_resources: Optional["_models.UserDefinedResourcesProperties"] = None, - recommendations_configuration: Optional[List["_models.RecommendationConfigurationProperties"]] = None, - unmasked_ip_logging_status: Union[str, "_models.UnmaskedIpLoggingStatus"] = "Disabled", - additional_workspaces: Optional[List["_models.AdditionalWorkspacesProperties"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The resource location. - :paramtype location: str - :keyword workspace: Workspace resource ID. - :paramtype workspace: str - :keyword display_name: Resource display name. - :paramtype display_name: str - :keyword status: Status of the IoT Security solution. Known values are: "Enabled" and - "Disabled". - :paramtype status: str or ~azure.mgmt.security.v2019_08_01.models.SecuritySolutionStatus - :keyword export: List of additional options for exporting to workspace data. - :paramtype export: list[str or ~azure.mgmt.security.v2019_08_01.models.ExportData] - :keyword disabled_data_sources: Disabled data sources. Disabling these data sources compromises - the system. - :paramtype disabled_data_sources: list[str or - ~azure.mgmt.security.v2019_08_01.models.DataSource] - :keyword iot_hubs: IoT Hub resource IDs. - :paramtype iot_hubs: list[str] - :keyword user_defined_resources: Properties of the IoT Security solution's user defined - resources. - :paramtype user_defined_resources: - ~azure.mgmt.security.v2019_08_01.models.UserDefinedResourcesProperties - :keyword recommendations_configuration: List of the configuration status for each - recommendation type. - :paramtype recommendations_configuration: - list[~azure.mgmt.security.v2019_08_01.models.RecommendationConfigurationProperties] - :keyword unmasked_ip_logging_status: Unmasked IP address logging status. Known values are: - "Disabled" and "Enabled". - :paramtype unmasked_ip_logging_status: str or - ~azure.mgmt.security.v2019_08_01.models.UnmaskedIpLoggingStatus - :keyword additional_workspaces: List of additional workspaces. - :paramtype additional_workspaces: - list[~azure.mgmt.security.v2019_08_01.models.AdditionalWorkspacesProperties] - """ - super().__init__(tags=tags, **kwargs) - self.tags = tags - self.location = location - self.system_data = None - self.workspace = workspace - self.display_name = display_name - self.status = status - self.export = export - self.disabled_data_sources = disabled_data_sources - self.iot_hubs = iot_hubs - self.user_defined_resources = user_defined_resources - self.auto_discovered_resources = None - self.recommendations_configuration = recommendations_configuration - self.unmasked_ip_logging_status = unmasked_ip_logging_status - self.additional_workspaces = additional_workspaces - self.id = None - self.name = None - self.type = None - - -class IoTSecuritySolutionsList(_serialization.Model): - """List of IoT Security solutions. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: List of IoT Security solutions. Required. - :vartype value: list[~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[IoTSecuritySolutionModel]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.IoTSecuritySolutionModel"], **kwargs: Any) -> None: - """ - :keyword value: List of IoT Security solutions. Required. - :paramtype value: list[~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class IoTSeverityMetrics(_serialization.Model): - """IoT Security solution analytics severity metrics. - - :ivar high: Count of high severity alerts/recommendations. - :vartype high: int - :ivar medium: Count of medium severity alerts/recommendations. - :vartype medium: int - :ivar low: Count of low severity alerts/recommendations. - :vartype low: int - """ - - _attribute_map = { - "high": {"key": "high", "type": "int"}, - "medium": {"key": "medium", "type": "int"}, - "low": {"key": "low", "type": "int"}, - } - - def __init__( - self, *, high: Optional[int] = None, medium: Optional[int] = None, low: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword high: Count of high severity alerts/recommendations. - :paramtype high: int - :keyword medium: Count of medium severity alerts/recommendations. - :paramtype medium: int - :keyword low: Count of low severity alerts/recommendations. - :paramtype low: int - """ - super().__init__(**kwargs) - self.high = high - self.medium = medium - self.low = low - - -class LocalUserNotAllowed(AllowlistCustomAlertRule): - """Login by a local user that isn't allowed. Allow list consists of login names to allow. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and - "String". - :vartype value_type: str or ~azure.mgmt.security.v2019_08_01.models.ValueType - :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. - Required. - :vartype allowlist_values: list[str] - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "value_type": {"readonly": True}, - "allowlist_values": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "value_type": {"key": "valueType", "type": "str"}, - "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, - } - - def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword allowlist_values: The values to allow. The format of the values depends on the rule - type. Required. - :paramtype allowlist_values: list[str] - """ - super().__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) - self.rule_type: str = "LocalUserNotAllowed" - - -class MqttC2DMessagesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of cloud to device messages (MQTT protocol) is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "MqttC2DMessagesNotInAllowedRange" - - -class MqttC2DRejectedMessagesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of rejected cloud to device messages (MQTT protocol) is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "MqttC2DRejectedMessagesNotInAllowedRange" - - -class MqttD2CMessagesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of device to cloud messages (MQTT protocol) is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "MqttD2CMessagesNotInAllowedRange" - - -class ProcessNotAllowed(AllowlistCustomAlertRule): - """Execution of a process that isn't allowed. Allow list consists of process names to allow. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar value_type: The value type of the items in the list. Known values are: "IpCidr" and - "String". - :vartype value_type: str or ~azure.mgmt.security.v2019_08_01.models.ValueType - :ivar allowlist_values: The values to allow. The format of the values depends on the rule type. - Required. - :vartype allowlist_values: list[str] - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "value_type": {"readonly": True}, - "allowlist_values": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "value_type": {"key": "valueType", "type": "str"}, - "allowlist_values": {"key": "allowlistValues", "type": "[str]"}, - } - - def __init__(self, *, is_enabled: bool, allowlist_values: List[str], **kwargs: Any) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword allowlist_values: The values to allow. The format of the values depends on the rule - type. Required. - :paramtype allowlist_values: list[str] - """ - super().__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) - self.rule_type: str = "ProcessNotAllowed" - - -class QueuePurgesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of device queue purges is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "QueuePurgesNotInAllowedRange" - - -class RecommendationConfigurationProperties(_serialization.Model): - """The type of IoT Security recommendation. - - 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 recommendation_type: The type of IoT Security recommendation. Required. Known values are: - "IoT_ACRAuthentication", "IoT_AgentSendsUnutilizedMessages", "IoT_Baseline", - "IoT_EdgeHubMemOptimize", "IoT_EdgeLoggingOptions", "IoT_InconsistentModuleSettings", - "IoT_InstallAgent", "IoT_IPFilter_DenyAll", "IoT_IPFilter_PermissiveRule", "IoT_OpenPorts", - "IoT_PermissiveFirewallPolicy", "IoT_PermissiveInputFirewallRules", - "IoT_PermissiveOutputFirewallRules", "IoT_PrivilegedDockerOptions", "IoT_SharedCredentials", - and "IoT_VulnerableTLSCipherSuite". - :vartype recommendation_type: str or ~azure.mgmt.security.v2019_08_01.models.RecommendationType - :ivar name: - :vartype name: str - :ivar status: Recommendation status. When the recommendation status is disabled recommendations - are not generated. Known values are: "Disabled" and "Enabled". - :vartype status: str or ~azure.mgmt.security.v2019_08_01.models.RecommendationConfigStatus - """ - - _validation = { - "recommendation_type": {"required": True}, - "name": {"readonly": True}, - "status": {"required": True}, - } - - _attribute_map = { - "recommendation_type": {"key": "recommendationType", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - recommendation_type: Union[str, "_models.RecommendationType"], - status: Union[str, "_models.RecommendationConfigStatus"] = "Enabled", - **kwargs: Any - ) -> None: - """ - :keyword recommendation_type: The type of IoT Security recommendation. Required. Known values - are: "IoT_ACRAuthentication", "IoT_AgentSendsUnutilizedMessages", "IoT_Baseline", - "IoT_EdgeHubMemOptimize", "IoT_EdgeLoggingOptions", "IoT_InconsistentModuleSettings", - "IoT_InstallAgent", "IoT_IPFilter_DenyAll", "IoT_IPFilter_PermissiveRule", "IoT_OpenPorts", - "IoT_PermissiveFirewallPolicy", "IoT_PermissiveInputFirewallRules", - "IoT_PermissiveOutputFirewallRules", "IoT_PrivilegedDockerOptions", "IoT_SharedCredentials", - and "IoT_VulnerableTLSCipherSuite". - :paramtype recommendation_type: str or - ~azure.mgmt.security.v2019_08_01.models.RecommendationType - :keyword status: Recommendation status. When the recommendation status is disabled - recommendations are not generated. Known values are: "Disabled" and "Enabled". - :paramtype status: str or ~azure.mgmt.security.v2019_08_01.models.RecommendationConfigStatus - """ - super().__init__(**kwargs) - self.recommendation_type = recommendation_type - self.name = None - self.status = status - - -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.security.v2019_08_01.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.security.v2019_08_01.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.security.v2019_08_01.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.security.v2019_08_01.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 TwinUpdatesNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of twin updates is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "TwinUpdatesNotInAllowedRange" - - -class UnauthorizedOperationsNotInAllowedRange(TimeWindowCustomAlertRule): - """Number of unauthorized operations is not in allowed range. - - 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 display_name: The display name of the custom alert. - :vartype display_name: str - :ivar description: The description of the custom alert. - :vartype description: str - :ivar is_enabled: Status of the custom alert. Required. - :vartype is_enabled: bool - :ivar rule_type: The type of the custom alert rule. Required. - :vartype rule_type: str - :ivar min_threshold: The minimum threshold. Required. - :vartype min_threshold: int - :ivar max_threshold: The maximum threshold. Required. - :vartype max_threshold: int - :ivar time_window_size: The time window size in iso8601 format. Required. - :vartype time_window_size: ~datetime.timedelta - """ - - _validation = { - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "is_enabled": {"required": True}, - "rule_type": {"required": True}, - "min_threshold": {"required": True}, - "max_threshold": {"required": True}, - "time_window_size": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "min_threshold": {"key": "minThreshold", "type": "int"}, - "max_threshold": {"key": "maxThreshold", "type": "int"}, - "time_window_size": {"key": "timeWindowSize", "type": "duration"}, - } - - def __init__( - self, - *, - is_enabled: bool, - min_threshold: int, - max_threshold: int, - time_window_size: datetime.timedelta, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Status of the custom alert. Required. - :paramtype is_enabled: bool - :keyword min_threshold: The minimum threshold. Required. - :paramtype min_threshold: int - :keyword max_threshold: The maximum threshold. Required. - :paramtype max_threshold: int - :keyword time_window_size: The time window size in iso8601 format. Required. - :paramtype time_window_size: ~datetime.timedelta - """ - super().__init__( - is_enabled=is_enabled, - min_threshold=min_threshold, - max_threshold=max_threshold, - time_window_size=time_window_size, - **kwargs - ) - self.rule_type: str = "UnauthorizedOperationsNotInAllowedRange" - - -class UpdateIotSecuritySolutionData(TagsResource): - """UpdateIotSecuritySolutionData. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar user_defined_resources: Properties of the IoT Security solution's user defined resources. - :vartype user_defined_resources: - ~azure.mgmt.security.v2019_08_01.models.UserDefinedResourcesProperties - :ivar recommendations_configuration: List of the configuration status for each recommendation - type. - :vartype recommendations_configuration: - list[~azure.mgmt.security.v2019_08_01.models.RecommendationConfigurationProperties] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "user_defined_resources": {"key": "properties.userDefinedResources", "type": "UserDefinedResourcesProperties"}, - "recommendations_configuration": { - "key": "properties.recommendationsConfiguration", - "type": "[RecommendationConfigurationProperties]", - }, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - user_defined_resources: Optional["_models.UserDefinedResourcesProperties"] = None, - recommendations_configuration: Optional[List["_models.RecommendationConfigurationProperties"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword user_defined_resources: Properties of the IoT Security solution's user defined - resources. - :paramtype user_defined_resources: - ~azure.mgmt.security.v2019_08_01.models.UserDefinedResourcesProperties - :keyword recommendations_configuration: List of the configuration status for each - recommendation type. - :paramtype recommendations_configuration: - list[~azure.mgmt.security.v2019_08_01.models.RecommendationConfigurationProperties] - """ - super().__init__(tags=tags, **kwargs) - self.user_defined_resources = user_defined_resources - self.recommendations_configuration = recommendations_configuration - - -class UserDefinedResourcesProperties(_serialization.Model): - """Properties of the IoT Security solution's user defined resources. - - All required parameters must be populated in order to send to server. - - :ivar query: Azure Resource Graph query which represents the security solution's user defined - resources. Required to start with "where type != "Microsoft.Devices/IotHubs"". Required. - :vartype query: str - :ivar query_subscriptions: List of Azure subscription ids on which the user defined resources - query should be executed. Required. - :vartype query_subscriptions: list[str] - """ - - _validation = { - "query": {"required": True}, - "query_subscriptions": {"required": True}, - } - - _attribute_map = { - "query": {"key": "query", "type": "str"}, - "query_subscriptions": {"key": "querySubscriptions", "type": "[str]"}, - } - - def __init__(self, *, query: str, query_subscriptions: List[str], **kwargs: Any) -> None: - """ - :keyword query: Azure Resource Graph query which represents the security solution's user - defined resources. Required to start with "where type != "Microsoft.Devices/IotHubs"". - Required. - :paramtype query: str - :keyword query_subscriptions: List of Azure subscription ids on which the user defined - resources query should be executed. Required. - :paramtype query_subscriptions: list[str] - """ - super().__init__(**kwargs) - self.query = query - self.query_subscriptions = query_subscriptions diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_security_center_enums.py deleted file mode 100644 index 97084fc09d52..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_security_center_enums.py +++ /dev/null @@ -1,138 +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 AdditionalWorkspaceDataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Data types sent to workspace.""" - - ALERTS = "Alerts" - RAW_EVENTS = "RawEvents" - - -class AdditionalWorkspaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Workspace type.""" - - SENTINEL = "Sentinel" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class DataSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """DataSource.""" - - TWIN_DATA = "TwinData" - """Devices twin data""" - - -class ExportData(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExportData.""" - - RAW_EVENTS = "RawEvents" - """Agent raw events""" - - -class RecommendationConfigStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Recommendation status. When the recommendation status is disabled recommendations are not - generated. - """ - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class RecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of IoT Security recommendation.""" - - IO_T_ACRAUTHENTICATION = "IoT_ACRAuthentication" - """Authentication schema used for pull an edge module from an ACR repository does not use Service - Principal Authentication.""" - IO_T_AGENT_SENDS_UNUTILIZED_MESSAGES = "IoT_AgentSendsUnutilizedMessages" - """IoT agent message size capacity is currently underutilized, causing an increase in the number - of sent messages. Adjust message intervals for better utilization.""" - IO_T_BASELINE = "IoT_Baseline" - """Identified security related system configuration issues.""" - IO_T_EDGE_HUB_MEM_OPTIMIZE = "IoT_EdgeHubMemOptimize" - """You can optimize Edge Hub memory usage by turning off protocol heads for any protocols not used - by Edge modules in your solution.""" - IO_T_EDGE_LOGGING_OPTIONS = "IoT_EdgeLoggingOptions" - """Logging is disabled for this edge module.""" - IO_T_INCONSISTENT_MODULE_SETTINGS = "IoT_InconsistentModuleSettings" - """A minority within a device security group has inconsistent Edge Module settings with the rest - of their group.""" - IO_T_INSTALL_AGENT = "IoT_InstallAgent" - """Install the Azure Security of Things Agent.""" - IO_T_IPFILTER_DENY_ALL = "IoT_IPFilter_DenyAll" - """IP Filter Configuration should have rules defined for allowed traffic and should deny all other - traffic by default.""" - IO_T_IPFILTER_PERMISSIVE_RULE = "IoT_IPFilter_PermissiveRule" - """An Allow IP Filter rules source IP range is too large. Overly permissive rules might expose - your IoT hub to malicious intenders.""" - IO_T_OPEN_PORTS = "IoT_OpenPorts" - """A listening endpoint was found on the device.""" - IO_T_PERMISSIVE_FIREWALL_POLICY = "IoT_PermissiveFirewallPolicy" - """An Allowed firewall policy was found (INPUT/OUTPUT). The policy should Deny all traffic by - default and define rules to allow necessary communication to/from the device.""" - IO_T_PERMISSIVE_INPUT_FIREWALL_RULES = "IoT_PermissiveInputFirewallRules" - """A rule in the firewall has been found that contains a permissive pattern for a wide range of IP - addresses or Ports.""" - IO_T_PERMISSIVE_OUTPUT_FIREWALL_RULES = "IoT_PermissiveOutputFirewallRules" - """A rule in the firewall has been found that contains a permissive pattern for a wide range of IP - addresses or Ports.""" - IO_T_PRIVILEGED_DOCKER_OPTIONS = "IoT_PrivilegedDockerOptions" - """Edge module is configured to run in privileged mode, with extensive Linux capabilities or with - host-level network access (send/receive data to host machine).""" - IO_T_SHARED_CREDENTIALS = "IoT_SharedCredentials" - """Same authentication credentials to the IoT Hub used by multiple devices. This could indicate an - illegitimate device impersonating a legitimate device. It also exposes the risk of device - impersonation by an attacker.""" - IO_T_VULNERABLE_TLS_CIPHER_SUITE = "IoT_VulnerableTLSCipherSuite" - """Insecure TLS configurations detected. Immediate upgrade recommended.""" - - -class ReportedSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Assessed alert severity.""" - - INFORMATIONAL = "Informational" - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - - -class SecuritySolutionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the IoT Security solution.""" - - ENABLED = "Enabled" - DISABLED = "Disabled" - - -class UnmaskedIpLoggingStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Unmasked IP address logging status.""" - - DISABLED = "Disabled" - """Unmasked IP logging is disabled""" - ENABLED = "Enabled" - """Unmasked IP logging is enabled""" - - -class ValueType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The value type of the items in the list.""" - - IP_CIDR = "IpCidr" - """An IP range in CIDR format (e.g. '192.168.0.1/8').""" - STRING = "String" - """Any string value.""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/__init__.py deleted file mode 100644 index 8f30c8ed00eb..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/__init__.py +++ /dev/null @@ -1,31 +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 ._device_security_groups_operations import DeviceSecurityGroupsOperations -from ._iot_security_solution_analytics_operations import IotSecuritySolutionAnalyticsOperations -from ._iot_security_solutions_analytics_aggregated_alert_operations import ( - IotSecuritySolutionsAnalyticsAggregatedAlertOperations, -) -from ._iot_security_solutions_analytics_recommendation_operations import ( - IotSecuritySolutionsAnalyticsRecommendationOperations, -) -from ._iot_security_solution_operations import IotSecuritySolutionOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DeviceSecurityGroupsOperations", - "IotSecuritySolutionAnalyticsOperations", - "IotSecuritySolutionsAnalyticsAggregatedAlertOperations", - "IotSecuritySolutionsAnalyticsRecommendationOperations", - "IotSecuritySolutionOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_device_security_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_device_security_groups_operations.py deleted file mode 100644 index 88fd7ad9b193..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_device_security_groups_operations.py +++ /dev/null @@ -1,496 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_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", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # 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_id: str, device_security_group_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "deviceSecurityGroupName": _SERIALIZER.url("device_security_group_name", device_security_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(resource_id: str, device_security_group_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-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", "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "deviceSecurityGroupName": _SERIALIZER.url("device_security_group_name", device_security_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - 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_id: str, device_security_group_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "deviceSecurityGroupName": _SERIALIZER.url("device_security_group_name", device_security_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DeviceSecurityGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.SecurityCenter`'s - :attr:`device_security_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, resource_id: str, **kwargs: Any) -> Iterable["_models.DeviceSecurityGroup"]: - """Use this method get the list of device security groups for the specified IoT Hub resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: An iterator like instance of either DeviceSecurityGroup or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.DeviceSecurityGroupList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_id=resource_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DeviceSecurityGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_id: str, device_security_group_name: str, **kwargs: Any) -> _models.DeviceSecurityGroup: - """Use this method to get the device security group for the specified IoT Hub resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :return: DeviceSecurityGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - device_security_group_name=device_security_group_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DeviceSecurityGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_id: str, - device_security_group_name: str, - device_security_group: _models.DeviceSecurityGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DeviceSecurityGroup: - """Use this method to creates or updates the device security group on a specified IoT Hub - resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :param device_security_group: Security group object. Required. - :type device_security_group: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DeviceSecurityGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_id: str, - device_security_group_name: str, - device_security_group: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DeviceSecurityGroup: - """Use this method to creates or updates the device security group on a specified IoT Hub - resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :param device_security_group: Security group object. Required. - :type device_security_group: 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: DeviceSecurityGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_id: str, - device_security_group_name: str, - device_security_group: Union[_models.DeviceSecurityGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DeviceSecurityGroup: - """Use this method to creates or updates the device security group on a specified IoT Hub - resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :param device_security_group: Security group object. Is either a DeviceSecurityGroup type or a - IO[bytes] type. Required. - :type device_security_group: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup or - IO[bytes] - :return: DeviceSecurityGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(device_security_group, (IOBase, bytes)): - _content = device_security_group - else: - _json = self._serialize.body(device_security_group, "DeviceSecurityGroup") - - _request = build_create_or_update_request( - resource_id=resource_id, - device_security_group_name=device_security_group_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DeviceSecurityGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DeviceSecurityGroup", pipeline_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_id: str, device_security_group_name: str, **kwargs: Any - ) -> None: - """User this method to deletes the device security group. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param device_security_group_name: The name of the device security group. Note that the name of - the device security group is case insensitive. Required. - :type device_security_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_id=resource_id, - device_security_group_name=device_security_group_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_analytics_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_analytics_operations.py deleted file mode 100644 index c14ac3bb70d4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_analytics_operations.py +++ /dev/null @@ -1,244 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, solution_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", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_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_get_request(resource_group_name: str, solution_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", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_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) - - -class IotSecuritySolutionAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.SecurityCenter`'s - :attr:`iot_security_solution_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, solution_name: str, **kwargs: Any - ) -> _models.IoTSecuritySolutionAnalyticsModelList: - """Use this method to get IoT security Analytics metrics in an array. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :return: IoTSecuritySolutionAnalyticsModelList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModelList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecuritySolutionAnalyticsModelList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, solution_name: str, **kwargs: Any - ) -> _models.IoTSecuritySolutionAnalyticsModel: - """Use this method to get IoT Security Analytics metrics. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :return: IoTSecuritySolutionAnalyticsModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionAnalyticsModel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecuritySolutionAnalyticsModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_operations.py deleted file mode 100644 index d972d5e0e459..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_operations.py +++ /dev/null @@ -1,830 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_subscription_request( - subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/iotSecuritySolutions" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request( - resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, solution_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", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, solution_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", "2019-08-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.Security/iotSecuritySolutions/{solutionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, solution_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", "2019-08-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.Security/iotSecuritySolutions/{solutionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, solution_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", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class IotSecuritySolutionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.SecurityCenter`'s - :attr:`iot_security_solution` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_subscription( - self, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.IoTSecuritySolutionModel"]: - """Use this method to get the list of IoT Security solutions by subscription. - - :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by - iotHubs. Default value is None. - :type filter: str - :return: An iterator like instance of either IoTSecuritySolutionModel or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("IoTSecuritySolutionsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.IoTSecuritySolutionModel"]: - """Use this method to get the list IoT Security solutions organized by resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by - iotHubs. Default value is None. - :type filter: str - :return: An iterator like instance of either IoTSecuritySolutionModel or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("IoTSecuritySolutionsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, solution_name: str, **kwargs: Any) -> _models.IoTSecuritySolutionModel: - """User this method to get details of a specific IoT Security solution based on solution name. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - solution_name: str, - iot_security_solution_data: _models.IoTSecuritySolutionModel, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to create or update yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param iot_security_solution_data: The security solution data. Required. - :type iot_security_solution_data: - ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - solution_name: str, - iot_security_solution_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to create or update yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param iot_security_solution_data: The security solution data. Required. - :type iot_security_solution_data: 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: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - solution_name: str, - iot_security_solution_data: Union[_models.IoTSecuritySolutionModel, IO[bytes]], - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to create or update yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param iot_security_solution_data: The security solution data. Is either a - IoTSecuritySolutionModel type or a IO[bytes] type. Required. - :type iot_security_solution_data: - ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel or IO[bytes] - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(iot_security_solution_data, (IOBase, bytes)): - _content = iot_security_solution_data - else: - _json = self._serialize.body(iot_security_solution_data, "IoTSecuritySolutionModel") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - solution_name: str, - update_iot_security_solution_data: _models.UpdateIotSecuritySolutionData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to update existing IoT Security solution tags or user defined resources. To - update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param update_iot_security_solution_data: The security solution data. Required. - :type update_iot_security_solution_data: - ~azure.mgmt.security.v2019_08_01.models.UpdateIotSecuritySolutionData - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - solution_name: str, - update_iot_security_solution_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to update existing IoT Security solution tags or user defined resources. To - update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param update_iot_security_solution_data: The security solution data. Required. - :type update_iot_security_solution_data: 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: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - solution_name: str, - update_iot_security_solution_data: Union[_models.UpdateIotSecuritySolutionData, IO[bytes]], - **kwargs: Any - ) -> _models.IoTSecuritySolutionModel: - """Use this method to update existing IoT Security solution tags or user defined resources. To - update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param update_iot_security_solution_data: The security solution data. Is either a - UpdateIotSecuritySolutionData type or a IO[bytes] type. Required. - :type update_iot_security_solution_data: - ~azure.mgmt.security.v2019_08_01.models.UpdateIotSecuritySolutionData or IO[bytes] - :return: IoTSecuritySolutionModel or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(update_iot_security_solution_data, (IOBase, bytes)): - _content = update_iot_security_solution_data - else: - _json = self._serialize.body(update_iot_security_solution_data, "UpdateIotSecuritySolutionData") - - _request = build_update_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecuritySolutionModel", pipeline_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, solution_name: str, **kwargs: Any - ) -> None: - """Use this method to delete yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py deleted file mode 100644 index e93a41081526..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py +++ /dev/null @@ -1,380 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, solution_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, solution_name: str, aggregated_alert_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", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), - "aggregatedAlertName": _SERIALIZER.url("aggregated_alert_name", aggregated_alert_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_dismiss_request( - resource_group_name: str, solution_name: str, aggregated_alert_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", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}/dismiss", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), - "aggregatedAlertName": _SERIALIZER.url("aggregated_alert_name", aggregated_alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class IotSecuritySolutionsAnalyticsAggregatedAlertOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.SecurityCenter`'s - :attr:`iot_security_solutions_analytics_aggregated_alert` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, solution_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IoTSecurityAggregatedAlert"]: - """Use this method to get the aggregated alert list of yours IoT Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param top: Number of results to retrieve. Default value is None. - :type top: int - :return: An iterator like instance of either IoTSecurityAggregatedAlert or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedAlert] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecurityAggregatedAlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("IoTSecurityAggregatedAlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, solution_name: str, aggregated_alert_name: str, **kwargs: Any - ) -> _models.IoTSecurityAggregatedAlert: - """Use this method to get a single the aggregated alert of yours IoT Security solution. This - aggregation is performed by alert name. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param aggregated_alert_name: Identifier of the aggregated alert. Required. - :type aggregated_alert_name: str - :return: IoTSecurityAggregatedAlert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedAlert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecurityAggregatedAlert] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - aggregated_alert_name=aggregated_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecurityAggregatedAlert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def dismiss( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, solution_name: str, aggregated_alert_name: str, **kwargs: Any - ) -> None: - """Use this method to dismiss an aggregated IoT Security Solution Alert. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param aggregated_alert_name: Identifier of the aggregated alert. Required. - :type aggregated_alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dismiss_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - aggregated_alert_name=aggregated_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_recommendation_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_recommendation_operations.py deleted file mode 100644 index d903da5ccbbd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_recommendation_operations.py +++ /dev/null @@ -1,295 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - solution_name: str, - aggregated_recommendation_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", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations/{aggregatedRecommendationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), - "aggregatedRecommendationName": _SERIALIZER.url( - "aggregated_recommendation_name", aggregated_recommendation_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_list_request( - resource_group_name: str, solution_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class IotSecuritySolutionsAnalyticsRecommendationOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2019_08_01.SecurityCenter`'s - :attr:`iot_security_solutions_analytics_recommendation` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, resource_group_name: str, solution_name: str, aggregated_recommendation_name: str, **kwargs: Any - ) -> _models.IoTSecurityAggregatedRecommendation: - """Use this method to get the aggregated security analytics recommendation of yours IoT Security - solution. This aggregation is performed by recommendation name. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param aggregated_recommendation_name: Name of the recommendation aggregated for this query. - Required. - :type aggregated_recommendation_name: str - :return: IoTSecurityAggregatedRecommendation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedRecommendation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecurityAggregatedRecommendation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - aggregated_recommendation_name=aggregated_recommendation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IoTSecurityAggregatedRecommendation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, solution_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IoTSecurityAggregatedRecommendation"]: - """Use this method to get the list of aggregated security analytics recommendations of yours IoT - Security solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. Required. - :type solution_name: str - :param top: Number of results to retrieve. Default value is None. - :type top: int - :return: An iterator like instance of either IoTSecurityAggregatedRecommendation or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedRecommendation] - :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._api_version or "2019-08-01")) - cls: ClsType[_models.IoTSecurityAggregatedRecommendationList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - solution_name=solution_name, - subscription_id=self._config.subscription_id, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("IoTSecurityAggregatedRecommendationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_configuration.py deleted file mode 100644 index 298019993d43..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2020-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_metadata.json deleted file mode 100644 index bea94ec13e71..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_metadata.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "chosen_version": "2020-01-01", - "total_api_version_list": ["2020-01-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "adaptive_network_hardenings": "AdaptiveNetworkHardeningsOperations", - "allowed_connections": "AllowedConnectionsOperations", - "adaptive_application_controls": "AdaptiveApplicationControlsOperations", - "assessments_metadata": "AssessmentsMetadataOperations", - "assessments": "AssessmentsOperations", - "discovered_security_solutions": "DiscoveredSecuritySolutionsOperations", - "external_security_solutions": "ExternalSecuritySolutionsOperations", - "jit_network_access_policies": "JitNetworkAccessPoliciesOperations", - "secure_scores": "SecureScoresOperations", - "secure_score_controls": "SecureScoreControlsOperations", - "secure_score_control_definitions": "SecureScoreControlDefinitionsOperations", - "security_solutions": "SecuritySolutionsOperations", - "security_solutions_reference_data": "SecuritySolutionsReferenceDataOperations", - "server_vulnerability_assessment": "ServerVulnerabilityAssessmentOperations", - "topology": "TopologyOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_security_center.py deleted file mode 100644 index dd669a12dafc..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_security_center.py +++ /dev/null @@ -1,207 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AdaptiveApplicationControlsOperations, - AdaptiveNetworkHardeningsOperations, - AllowedConnectionsOperations, - AssessmentsMetadataOperations, - AssessmentsOperations, - DiscoveredSecuritySolutionsOperations, - ExternalSecuritySolutionsOperations, - JitNetworkAccessPoliciesOperations, - SecureScoreControlDefinitionsOperations, - SecureScoreControlsOperations, - SecureScoresOperations, - SecuritySolutionsOperations, - SecuritySolutionsReferenceDataOperations, - ServerVulnerabilityAssessmentOperations, - TopologyOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar adaptive_network_hardenings: AdaptiveNetworkHardeningsOperations operations - :vartype adaptive_network_hardenings: - azure.mgmt.security.v2020_01_01.operations.AdaptiveNetworkHardeningsOperations - :ivar allowed_connections: AllowedConnectionsOperations operations - :vartype allowed_connections: - azure.mgmt.security.v2020_01_01.operations.AllowedConnectionsOperations - :ivar adaptive_application_controls: AdaptiveApplicationControlsOperations operations - :vartype adaptive_application_controls: - azure.mgmt.security.v2020_01_01.operations.AdaptiveApplicationControlsOperations - :ivar assessments_metadata: AssessmentsMetadataOperations operations - :vartype assessments_metadata: - azure.mgmt.security.v2020_01_01.operations.AssessmentsMetadataOperations - :ivar assessments: AssessmentsOperations operations - :vartype assessments: azure.mgmt.security.v2020_01_01.operations.AssessmentsOperations - :ivar discovered_security_solutions: DiscoveredSecuritySolutionsOperations operations - :vartype discovered_security_solutions: - azure.mgmt.security.v2020_01_01.operations.DiscoveredSecuritySolutionsOperations - :ivar external_security_solutions: ExternalSecuritySolutionsOperations operations - :vartype external_security_solutions: - azure.mgmt.security.v2020_01_01.operations.ExternalSecuritySolutionsOperations - :ivar jit_network_access_policies: JitNetworkAccessPoliciesOperations operations - :vartype jit_network_access_policies: - azure.mgmt.security.v2020_01_01.operations.JitNetworkAccessPoliciesOperations - :ivar secure_scores: SecureScoresOperations operations - :vartype secure_scores: azure.mgmt.security.v2020_01_01.operations.SecureScoresOperations - :ivar secure_score_controls: SecureScoreControlsOperations operations - :vartype secure_score_controls: - azure.mgmt.security.v2020_01_01.operations.SecureScoreControlsOperations - :ivar secure_score_control_definitions: SecureScoreControlDefinitionsOperations operations - :vartype secure_score_control_definitions: - azure.mgmt.security.v2020_01_01.operations.SecureScoreControlDefinitionsOperations - :ivar security_solutions: SecuritySolutionsOperations operations - :vartype security_solutions: - azure.mgmt.security.v2020_01_01.operations.SecuritySolutionsOperations - :ivar security_solutions_reference_data: SecuritySolutionsReferenceDataOperations operations - :vartype security_solutions_reference_data: - azure.mgmt.security.v2020_01_01.operations.SecuritySolutionsReferenceDataOperations - :ivar server_vulnerability_assessment: ServerVulnerabilityAssessmentOperations operations - :vartype server_vulnerability_assessment: - azure.mgmt.security.v2020_01_01.operations.ServerVulnerabilityAssessmentOperations - :ivar topology: TopologyOperations operations - :vartype topology: azure.mgmt.security.v2020_01_01.operations.TopologyOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.adaptive_network_hardenings = AdaptiveNetworkHardeningsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.allowed_connections = AllowedConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.adaptive_application_controls = AdaptiveApplicationControlsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.assessments_metadata = AssessmentsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.assessments = AssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.external_security_solutions = ExternalSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.secure_scores = SecureScoresOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.secure_score_controls = SecureScoreControlsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.secure_score_control_definitions = SecureScoreControlDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.security_solutions = SecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.server_vulnerability_assessment = ServerVulnerabilityAssessmentOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.topology = TopologyOperations(self._client, self._config, self._serialize, self._deserialize, "2020-01-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_configuration.py deleted file mode 100644 index bd9bd2f3d025..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2020-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_security_center.py deleted file mode 100644 index 9fe84135e96c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_security_center.py +++ /dev/null @@ -1,209 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AdaptiveApplicationControlsOperations, - AdaptiveNetworkHardeningsOperations, - AllowedConnectionsOperations, - AssessmentsMetadataOperations, - AssessmentsOperations, - DiscoveredSecuritySolutionsOperations, - ExternalSecuritySolutionsOperations, - JitNetworkAccessPoliciesOperations, - SecureScoreControlDefinitionsOperations, - SecureScoreControlsOperations, - SecureScoresOperations, - SecuritySolutionsOperations, - SecuritySolutionsReferenceDataOperations, - ServerVulnerabilityAssessmentOperations, - TopologyOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar adaptive_network_hardenings: AdaptiveNetworkHardeningsOperations operations - :vartype adaptive_network_hardenings: - azure.mgmt.security.v2020_01_01.aio.operations.AdaptiveNetworkHardeningsOperations - :ivar allowed_connections: AllowedConnectionsOperations operations - :vartype allowed_connections: - azure.mgmt.security.v2020_01_01.aio.operations.AllowedConnectionsOperations - :ivar adaptive_application_controls: AdaptiveApplicationControlsOperations operations - :vartype adaptive_application_controls: - azure.mgmt.security.v2020_01_01.aio.operations.AdaptiveApplicationControlsOperations - :ivar assessments_metadata: AssessmentsMetadataOperations operations - :vartype assessments_metadata: - azure.mgmt.security.v2020_01_01.aio.operations.AssessmentsMetadataOperations - :ivar assessments: AssessmentsOperations operations - :vartype assessments: azure.mgmt.security.v2020_01_01.aio.operations.AssessmentsOperations - :ivar discovered_security_solutions: DiscoveredSecuritySolutionsOperations operations - :vartype discovered_security_solutions: - azure.mgmt.security.v2020_01_01.aio.operations.DiscoveredSecuritySolutionsOperations - :ivar external_security_solutions: ExternalSecuritySolutionsOperations operations - :vartype external_security_solutions: - azure.mgmt.security.v2020_01_01.aio.operations.ExternalSecuritySolutionsOperations - :ivar jit_network_access_policies: JitNetworkAccessPoliciesOperations operations - :vartype jit_network_access_policies: - azure.mgmt.security.v2020_01_01.aio.operations.JitNetworkAccessPoliciesOperations - :ivar secure_scores: SecureScoresOperations operations - :vartype secure_scores: azure.mgmt.security.v2020_01_01.aio.operations.SecureScoresOperations - :ivar secure_score_controls: SecureScoreControlsOperations operations - :vartype secure_score_controls: - azure.mgmt.security.v2020_01_01.aio.operations.SecureScoreControlsOperations - :ivar secure_score_control_definitions: SecureScoreControlDefinitionsOperations operations - :vartype secure_score_control_definitions: - azure.mgmt.security.v2020_01_01.aio.operations.SecureScoreControlDefinitionsOperations - :ivar security_solutions: SecuritySolutionsOperations operations - :vartype security_solutions: - azure.mgmt.security.v2020_01_01.aio.operations.SecuritySolutionsOperations - :ivar security_solutions_reference_data: SecuritySolutionsReferenceDataOperations operations - :vartype security_solutions_reference_data: - azure.mgmt.security.v2020_01_01.aio.operations.SecuritySolutionsReferenceDataOperations - :ivar server_vulnerability_assessment: ServerVulnerabilityAssessmentOperations operations - :vartype server_vulnerability_assessment: - azure.mgmt.security.v2020_01_01.aio.operations.ServerVulnerabilityAssessmentOperations - :ivar topology: TopologyOperations operations - :vartype topology: azure.mgmt.security.v2020_01_01.aio.operations.TopologyOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.adaptive_network_hardenings = AdaptiveNetworkHardeningsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.allowed_connections = AllowedConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.adaptive_application_controls = AdaptiveApplicationControlsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.assessments_metadata = AssessmentsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.assessments = AssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.external_security_solutions = ExternalSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.secure_scores = SecureScoresOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.secure_score_controls = SecureScoreControlsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.secure_score_control_definitions = SecureScoreControlDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.security_solutions = SecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.server_vulnerability_assessment = ServerVulnerabilityAssessmentOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01" - ) - self.topology = TopologyOperations(self._client, self._config, self._serialize, self._deserialize, "2020-01-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/__init__.py deleted file mode 100644 index a3d32683f78c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/__init__.py +++ /dev/null @@ -1,47 +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 ._adaptive_network_hardenings_operations import AdaptiveNetworkHardeningsOperations -from ._allowed_connections_operations import AllowedConnectionsOperations -from ._adaptive_application_controls_operations import AdaptiveApplicationControlsOperations -from ._assessments_metadata_operations import AssessmentsMetadataOperations -from ._assessments_operations import AssessmentsOperations -from ._discovered_security_solutions_operations import DiscoveredSecuritySolutionsOperations -from ._external_security_solutions_operations import ExternalSecuritySolutionsOperations -from ._jit_network_access_policies_operations import JitNetworkAccessPoliciesOperations -from ._secure_scores_operations import SecureScoresOperations -from ._secure_score_controls_operations import SecureScoreControlsOperations -from ._secure_score_control_definitions_operations import SecureScoreControlDefinitionsOperations -from ._security_solutions_operations import SecuritySolutionsOperations -from ._security_solutions_reference_data_operations import SecuritySolutionsReferenceDataOperations -from ._server_vulnerability_assessment_operations import ServerVulnerabilityAssessmentOperations -from ._topology_operations import TopologyOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdaptiveNetworkHardeningsOperations", - "AllowedConnectionsOperations", - "AdaptiveApplicationControlsOperations", - "AssessmentsMetadataOperations", - "AssessmentsOperations", - "DiscoveredSecuritySolutionsOperations", - "ExternalSecuritySolutionsOperations", - "JitNetworkAccessPoliciesOperations", - "SecureScoresOperations", - "SecureScoreControlsOperations", - "SecureScoreControlDefinitionsOperations", - "SecuritySolutionsOperations", - "SecuritySolutionsReferenceDataOperations", - "ServerVulnerabilityAssessmentOperations", - "TopologyOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_application_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_application_controls_operations.py deleted file mode 100644 index f5110571025a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_application_controls_operations.py +++ /dev/null @@ -1,361 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._adaptive_application_controls_operations import ( - build_delete_request, - build_get_request, - build_list_request, - build_put_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AdaptiveApplicationControlsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`adaptive_application_controls` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list( - self, include_path_recommendations: Optional[bool] = None, summary: Optional[bool] = None, **kwargs: Any - ) -> _models.AdaptiveApplicationControlGroups: - """Gets a list of application control machine groups for the subscription. - - :param include_path_recommendations: Include the policy rules. Default value is None. - :type include_path_recommendations: bool - :param summary: Return output in a summarized form. Default value is None. - :type summary: bool - :return: AdaptiveApplicationControlGroups or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroups - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.AdaptiveApplicationControlGroups] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - include_path_recommendations=include_path_recommendations, - summary=summary, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdaptiveApplicationControlGroups", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, asc_location: str, group_name: str, **kwargs: Any) -> _models.AdaptiveApplicationControlGroup: - """Gets an application control VM/server group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :return: AdaptiveApplicationControlGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.AdaptiveApplicationControlGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - asc_location=asc_location, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdaptiveApplicationControlGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def put( - self, - asc_location: str, - group_name: str, - body: _models.AdaptiveApplicationControlGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AdaptiveApplicationControlGroup: - """Update an application control machine group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :param body: Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AdaptiveApplicationControlGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put( - self, - asc_location: str, - group_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AdaptiveApplicationControlGroup: - """Update an application control machine group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AdaptiveApplicationControlGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def put( - self, - asc_location: str, - group_name: str, - body: Union[_models.AdaptiveApplicationControlGroup, IO[bytes]], - **kwargs: Any - ) -> _models.AdaptiveApplicationControlGroup: - """Update an application control machine group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :param body: Is either a AdaptiveApplicationControlGroup type or a IO[bytes] type. Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup or - IO[bytes] - :return: AdaptiveApplicationControlGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdaptiveApplicationControlGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "AdaptiveApplicationControlGroup") - - _request = build_put_request( - asc_location=asc_location, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdaptiveApplicationControlGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, asc_location: str, group_name: str, **kwargs: Any - ) -> None: - """Delete an application control machine group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - asc_location=asc_location, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_network_hardenings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_network_hardenings_operations.py deleted file mode 100644 index 5ec9c8ffa455..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_network_hardenings_operations.py +++ /dev/null @@ -1,458 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._adaptive_network_hardenings_operations import ( - build_enforce_request, - build_get_request, - build_list_by_extended_resource_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AdaptiveNetworkHardeningsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`adaptive_network_hardenings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_extended_resource( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AdaptiveNetworkHardening"]: - """Gets a list of Adaptive Network Hardenings resources in scope of an extended resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either AdaptiveNetworkHardening or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardening] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.AdaptiveNetworkHardeningsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_extended_resource_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AdaptiveNetworkHardeningsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - **kwargs: Any - ) -> _models.AdaptiveNetworkHardening: - """Gets a single Adaptive Network Hardening resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. Required. - :type adaptive_network_hardening_resource_name: str - :return: AdaptiveNetworkHardening or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardening - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.AdaptiveNetworkHardening] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - adaptive_network_hardening_resource_name=adaptive_network_hardening_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdaptiveNetworkHardening", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _enforce_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - body: Union[_models.AdaptiveNetworkHardeningEnforceRequest, IO[bytes]], - **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - adaptive_network_hardening_enforce_action: Literal["enforce"] = kwargs.pop( - "adaptive_network_hardening_enforce_action", "enforce" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "AdaptiveNetworkHardeningEnforceRequest") - - _request = build_enforce_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - adaptive_network_hardening_resource_name=adaptive_network_hardening_resource_name, - subscription_id=self._config.subscription_id, - adaptive_network_hardening_enforce_action=adaptive_network_hardening_enforce_action, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def begin_enforce( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - body: _models.AdaptiveNetworkHardeningEnforceRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Enforces the given rules on the NSG(s) listed in the request. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. Required. - :type adaptive_network_hardening_resource_name: str - :param body: Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardeningEnforceRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_enforce( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Enforces the given rules on the NSG(s) listed in the request. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. Required. - :type adaptive_network_hardening_resource_name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_enforce( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - body: Union[_models.AdaptiveNetworkHardeningEnforceRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Enforces the given rules on the NSG(s) listed in the request. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. Required. - :type adaptive_network_hardening_resource_name: str - :param body: Is either a AdaptiveNetworkHardeningEnforceRequest type or a IO[bytes] type. - Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardeningEnforceRequest or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - adaptive_network_hardening_enforce_action: Literal["enforce"] = kwargs.pop( - "adaptive_network_hardening_enforce_action", "enforce" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._enforce_initial( # type: ignore - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - adaptive_network_hardening_resource_name=adaptive_network_hardening_resource_name, - body=body, - adaptive_network_hardening_enforce_action=adaptive_network_hardening_enforce_action, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_allowed_connections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_allowed_connections_operations.py deleted file mode 100644 index b0f2377b1028..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_allowed_connections_operations.py +++ /dev/null @@ -1,294 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._allowed_connections_operations import ( - build_get_request, - build_list_by_home_region_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AllowedConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`allowed_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.AllowedConnectionsResource"]: - """Gets the list of all possible traffic between resources for the subscription. - - :return: An iterator like instance of either AllowedConnectionsResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.AllowedConnectionsResource] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.AllowedConnectionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AllowedConnectionsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region( - self, asc_location: str, **kwargs: Any - ) -> AsyncIterable["_models.AllowedConnectionsResource"]: - """Gets the list of all possible traffic between resources for the subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either AllowedConnectionsResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.AllowedConnectionsResource] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.AllowedConnectionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AllowedConnectionsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - asc_location: str, - connection_type: Union[str, _models.ConnectionType], - **kwargs: Any - ) -> _models.AllowedConnectionsResource: - """Gets the list of all possible traffic between resources for the subscription and location, - based on connection type. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param connection_type: The type of allowed connections (Internal, External). Known values are: - "Internal" and "External". Required. - :type connection_type: str or ~azure.mgmt.security.v2020_01_01.models.ConnectionType - :return: AllowedConnectionsResource or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AllowedConnectionsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.AllowedConnectionsResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - connection_type=connection_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AllowedConnectionsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_metadata_operations.py deleted file mode 100644 index 9e29f8555bae..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_metadata_operations.py +++ /dev/null @@ -1,504 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._assessments_metadata_operations import ( - build_create_in_subscription_request, - build_delete_in_subscription_request, - build_get_in_subscription_request, - build_get_request, - build_list_by_subscription_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AssessmentsMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`assessments_metadata` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetadata"]: - """Get metadata information on all assessment types. - - :return: An iterator like instance of either SecurityAssessmentMetadata or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentMetadataList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentMetadataList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityAssessmentMetadata: - """Get metadata information on an assessment type. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) - - _request = build_get_request( - assessment_metadata_name=assessment_metadata_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetadata"]: - """Get metadata information on all assessment types in a specific subscription. - - :return: An iterator like instance of either SecurityAssessmentMetadata or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentMetadataList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentMetadataList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_in_subscription( - self, assessment_metadata_name: str, **kwargs: Any - ) -> _models.SecurityAssessmentMetadata: - """Get metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) - - _request = build_get_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: _models.SecurityAssessmentMetadata, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentMetadata: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Required. - :type assessment_metadata: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentMetadata: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Required. - :type assessment_metadata: 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: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: Union[_models.SecurityAssessmentMetadata, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityAssessmentMetadata: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Is either a SecurityAssessmentMetadata - type or a IO[bytes] type. Required. - :type assessment_metadata: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - or IO[bytes] - :return: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(assessment_metadata, (IOBase, bytes)): - _content = assessment_metadata - else: - _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadata") - - _request = build_create_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_in_subscription( # pylint: disable=inconsistent-return-statements - self, assessment_metadata_name: str, **kwargs: Any - ) -> None: - """Delete metadata information on an assessment type in a specific subscription, will cause the - deletion of all the assessments of that type in that subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_operations.py deleted file mode 100644 index c304e0648eee..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_operations.py +++ /dev/null @@ -1,398 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._assessments_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessment"]: - """Get security assessments on all your scanned resources inside a scope. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either SecurityAssessment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.SecurityAssessment] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_id: str, - assessment_name: str, - expand: Optional[Union[str, _models.ExpandEnum]] = None, - **kwargs: Any - ) -> _models.SecurityAssessment: - """Get a security assessment on your scanned resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param expand: OData expand. Optional. Known values are: "links" and "metadata". Default value - is None. - :type expand: str or ~azure.mgmt.security.v2020_01_01.models.ExpandEnum - :return: SecurityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - assessment_name=assessment_name, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: _models.SecurityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessment: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. - :type assessment: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessment: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. - :type assessment: 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: SecurityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: Union[_models.SecurityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityAssessment: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Is either a - SecurityAssessment type or a IO[bytes] type. Required. - :type assessment: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment or IO[bytes] - :return: SecurityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityAssessment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(assessment, (IOBase, bytes)): - _content = assessment - else: - _json = self._serialize.body(assessment, "SecurityAssessment") - - _request = build_create_or_update_request( - resource_id=resource_id, - assessment_name=assessment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityAssessment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_id: str, assessment_name: str, **kwargs: Any - ) -> None: - """Delete a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_id=resource_id, - assessment_name=assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_discovered_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_discovered_security_solutions_operations.py deleted file mode 100644 index e5dcae4f12e7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_discovered_security_solutions_operations.py +++ /dev/null @@ -1,288 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._discovered_security_solutions_operations import ( - build_get_request, - build_list_by_home_region_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DiscoveredSecuritySolutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`discovered_security_solutions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DiscoveredSecuritySolution"]: - """Gets a list of discovered Security Solutions for the subscription. - - :return: An iterator like instance of either DiscoveredSecuritySolution or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.DiscoveredSecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiscoveredSecuritySolutionList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region( - self, asc_location: str, **kwargs: Any - ) -> AsyncIterable["_models.DiscoveredSecuritySolution"]: - """Gets a list of discovered Security Solutions for the subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either DiscoveredSecuritySolution or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.DiscoveredSecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiscoveredSecuritySolutionList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, asc_location: str, discovered_security_solution_name: str, **kwargs: Any - ) -> _models.DiscoveredSecuritySolution: - """Gets a specific discovered Security Solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param discovered_security_solution_name: Name of a discovered security solution. Required. - :type discovered_security_solution_name: str - :return: DiscoveredSecuritySolution or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.DiscoveredSecuritySolution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - discovered_security_solution_name=discovered_security_solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiscoveredSecuritySolution", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_external_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_external_security_solutions_operations.py deleted file mode 100644 index a794d5290533..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_external_security_solutions_operations.py +++ /dev/null @@ -1,288 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._external_security_solutions_operations import ( - build_get_request, - build_list_by_home_region_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ExternalSecuritySolutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`external_security_solutions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.ExternalSecuritySolution"]: - """Gets a list of external security solutions for the subscription. - - :return: An iterator like instance of either ExternalSecuritySolution or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.ExternalSecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ExternalSecuritySolutionList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region( - self, asc_location: str, **kwargs: Any - ) -> AsyncIterable["_models.ExternalSecuritySolution"]: - """Gets a list of external Security Solutions for the subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either ExternalSecuritySolution or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.ExternalSecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ExternalSecuritySolutionList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, asc_location: str, external_security_solutions_name: str, **kwargs: Any - ) -> _models.ExternalSecuritySolution: - """Gets a specific external Security Solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param external_security_solutions_name: Name of an external security solution. Required. - :type external_security_solutions_name: str - :return: ExternalSecuritySolution or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.ExternalSecuritySolution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - external_security_solutions_name=external_security_solutions_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ExternalSecuritySolution", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_jit_network_access_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_jit_network_access_policies_operations.py deleted file mode 100644 index ac85dbc09c69..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_jit_network_access_policies_operations.py +++ /dev/null @@ -1,826 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._jit_network_access_policies_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_initiate_request, - build_list_by_region_request, - build_list_by_resource_group_and_region_request, - build_list_by_resource_group_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class JitNetworkAccessPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`jit_network_access_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: - """Policies for protecting resources using Just-in-Time access control. - - :return: An iterator like instance of either JitNetworkAccessPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JitNetworkAccessPoliciesList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_region(self, asc_location: str, **kwargs: Any) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either JitNetworkAccessPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JitNetworkAccessPoliciesList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either JitNetworkAccessPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JitNetworkAccessPoliciesList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group_and_region( - self, resource_group_name: str, asc_location: str, **kwargs: Any - ) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either JitNetworkAccessPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_and_region_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JitNetworkAccessPoliciesList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any - ) -> _models.JitNetworkAccessPolicy: - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :return: JitNetworkAccessPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - jit_network_access_policy_name=jit_network_access_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitNetworkAccessPolicy", pipeline_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, - asc_location: str, - jit_network_access_policy_name: str, - body: _models.JitNetworkAccessPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitNetworkAccessPolicy: - """Create a policy for protecting resources using Just-in-Time access control. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JitNetworkAccessPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitNetworkAccessPolicy: - """Create a policy for protecting resources using Just-in-Time access control. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JitNetworkAccessPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: Union[_models.JitNetworkAccessPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.JitNetworkAccessPolicy: - """Create a policy for protecting resources using Just-in-Time access control. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Is either a JitNetworkAccessPolicy type or a IO[bytes] type. Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy or IO[bytes] - :return: JitNetworkAccessPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "JitNetworkAccessPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - jit_network_access_policy_name=jit_network_access_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitNetworkAccessPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any - ) -> None: - """Delete a Just-in-Time access control policy. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - jit_network_access_policy_name=jit_network_access_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def initiate( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: _models.JitNetworkAccessPolicyInitiateRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitNetworkAccessRequest: - """Initiate a JIT access from a specific Just-in-Time policy configuration. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiateRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JitNetworkAccessRequest or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def initiate( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitNetworkAccessRequest: - """Initiate a JIT access from a specific Just-in-Time policy configuration. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JitNetworkAccessRequest or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def initiate( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: Union[_models.JitNetworkAccessPolicyInitiateRequest, IO[bytes]], - **kwargs: Any - ) -> _models.JitNetworkAccessRequest: - """Initiate a JIT access from a specific Just-in-Time policy configuration. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Is either a JitNetworkAccessPolicyInitiateRequest type or a IO[bytes] type. - Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiateRequest or - IO[bytes] - :return: JitNetworkAccessRequest or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - jit_network_access_policy_initiate_type: Literal["initiate"] = kwargs.pop( - "jit_network_access_policy_initiate_type", "initiate" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JitNetworkAccessRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "JitNetworkAccessPolicyInitiateRequest") - - _request = build_initiate_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - jit_network_access_policy_name=jit_network_access_policy_name, - subscription_id=self._config.subscription_id, - jit_network_access_policy_initiate_type=jit_network_access_policy_initiate_type, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitNetworkAccessRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_control_definitions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_control_definitions_operations.py deleted file mode 100644 index ecb3a4365fff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_control_definitions_operations.py +++ /dev/null @@ -1,218 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._secure_score_control_definitions_operations import ( - build_list_by_subscription_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecureScoreControlDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`secure_score_control_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreControlDefinitionItem"]: - """List the available security controls, their assessments, and the max score. - - :return: An iterator like instance of either SecureScoreControlDefinitionItem or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDefinitionItem] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreControlDefinitionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoreControlDefinitionList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreControlDefinitionItem"]: - """For a specified subscription, list the available security controls, their assessments, and the - max score. - - :return: An iterator like instance of either SecureScoreControlDefinitionItem or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDefinitionItem] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreControlDefinitionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoreControlDefinitionList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_controls_operations.py deleted file mode 100644 index 901d43d353e9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_controls_operations.py +++ /dev/null @@ -1,229 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._secure_score_controls_operations import build_list_by_secure_score_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecureScoreControlsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`secure_score_controls` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_secure_score( - self, secure_score_name: str, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SecureScoreControlDetails"]: - """Get all security controls for a specific initiative within a scope. - - :param secure_score_name: The initiative name. For the ASC Default initiative, use 'ascScore' - as in the sample request below. Required. - :type secure_score_name: str - :param expand: OData expand. Optional. "definition" Default value is None. - :type expand: str or ~azure.mgmt.security.v2020_01_01.models.ExpandControlsEnum - :return: An iterator like instance of either SecureScoreControlDetails or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDetails] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreControlList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_secure_score_request( - secure_score_name=secure_score_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoreControlList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list( - self, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SecureScoreControlDetails"]: - """Get all security controls within a scope. - - :param expand: OData expand. Optional. "definition" Default value is None. - :type expand: str or ~azure.mgmt.security.v2020_01_01.models.ExpandControlsEnum - :return: An iterator like instance of either SecureScoreControlDetails or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDetails] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreControlList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoreControlList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_scores_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_scores_operations.py deleted file mode 100644 index ef0f7aa9c823..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_scores_operations.py +++ /dev/null @@ -1,192 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._secure_scores_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecureScoresOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`secure_scores` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreItem"]: - """List secure scores for all your Microsoft Defender for Cloud initiatives within your current - scope. - - :return: An iterator like instance of either SecureScoreItem or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreItem] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoresList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoresList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, secure_score_name: str, **kwargs: Any) -> _models.SecureScoreItem: - """Get secure score for a specific Microsoft Defender for Cloud initiative within your current - scope. For the ASC Default initiative, use 'ascScore'. - - :param secure_score_name: The initiative name. For the ASC Default initiative, use 'ascScore' - as in the sample request below. Required. - :type secure_score_name: str - :return: SecureScoreItem or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecureScoreItem - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreItem] = kwargs.pop("cls", None) - - _request = build_get_request( - secure_score_name=secure_score_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecureScoreItem", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_operations.py deleted file mode 100644 index 90e08c27f3b9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_operations.py +++ /dev/null @@ -1,199 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_solutions_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecuritySolutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`security_solutions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecuritySolution"]: - """Gets a list of Security Solutions for the subscription. - - :return: An iterator like instance of either SecuritySolution or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.SecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecuritySolutionList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, asc_location: str, security_solution_name: str, **kwargs: Any - ) -> _models.SecuritySolution: - """Gets a specific Security Solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param security_solution_name: Name of security solution. Required. - :type security_solution_name: str - :return: SecuritySolution or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecuritySolution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - security_solution_name=security_solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecuritySolution", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_reference_data_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_reference_data_operations.py deleted file mode 100644 index 03f2696b828d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_reference_data_operations.py +++ /dev/null @@ -1,162 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_solutions_reference_data_operations import ( - build_list_by_home_region_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecuritySolutionsReferenceDataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`security_solutions_reference_data` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: - """Gets a list of all supported Security Solutions for the subscription. - - :return: SecuritySolutionsReferenceDataList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceDataList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list_by_home_region(self, asc_location: str, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: - """Gets list of all supported Security Solutions for subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: SecuritySolutionsReferenceDataList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceDataList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_server_vulnerability_assessment_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_server_vulnerability_assessment_operations.py deleted file mode 100644 index 1b2a2e982324..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_server_vulnerability_assessment_operations.py +++ /dev/null @@ -1,371 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Literal, Optional, Type, TypeVar, Union, cast - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._server_vulnerability_assessment_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_extended_resource_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ServerVulnerabilityAssessmentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`server_vulnerability_assessment` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list_by_extended_resource( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsList: - """Gets a list of server vulnerability assessment onboarding statuses on a given resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: ServerVulnerabilityAssessmentsList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessmentsList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.ServerVulnerabilityAssessmentsList] = kwargs.pop("cls", None) - - _request = build_list_by_extended_resource_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServerVulnerabilityAssessmentsList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Gets a server vulnerability assessment onboarding statuses on a given resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - server_vulnerability_assessment=server_vulnerability_assessment, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def create_or_update( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Creating a server vulnerability assessment on a resource, which will onboard a resource for - having a vulnerability assessment on it. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - server_vulnerability_assessment=server_vulnerability_assessment, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - server_vulnerability_assessment=server_vulnerability_assessment, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Removing server vulnerability assessment from a resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_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 {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - server_vulnerability_assessment=server_vulnerability_assessment, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # 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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_topology_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_topology_operations.py deleted file mode 100644 index 96e3416f744b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_topology_operations.py +++ /dev/null @@ -1,280 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._topology_operations import build_get_request, build_list_by_home_region_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TopologyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.aio.SecurityCenter`'s - :attr:`topology` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.TopologyResource"]: - """Gets a list that allows to build a topology view of a subscription. - - :return: An iterator like instance of either TopologyResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.TopologyResource] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.TopologyList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("TopologyList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region(self, asc_location: str, **kwargs: Any) -> AsyncIterable["_models.TopologyResource"]: - """Gets a list that allows to build a topology view of a subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either TopologyResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01.models.TopologyResource] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.TopologyList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("TopologyList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, asc_location: str, topology_resource_name: str, **kwargs: Any - ) -> _models.TopologyResource: - """Gets a specific topology component. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param topology_resource_name: Name of a topology resources collection. Required. - :type topology_resource_name: str - :return: TopologyResource or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.TopologyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.TopologyResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - topology_resource_name=topology_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TopologyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/__init__.py deleted file mode 100644 index 696464205ce0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/__init__.py +++ /dev/null @@ -1,237 +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 ._models_py3 import AadConnectivityState -from ._models_py3 import AadExternalSecuritySolution -from ._models_py3 import AadSolutionProperties -from ._models_py3 import AdaptiveApplicationControlGroup -from ._models_py3 import AdaptiveApplicationControlGroups -from ._models_py3 import AdaptiveApplicationControlIssueSummary -from ._models_py3 import AdaptiveNetworkHardening -from ._models_py3 import AdaptiveNetworkHardeningEnforceRequest -from ._models_py3 import AdaptiveNetworkHardeningsList -from ._models_py3 import AllowedConnectionsList -from ._models_py3 import AllowedConnectionsResource -from ._models_py3 import AssessmentLinks -from ._models_py3 import AssessmentStatus -from ._models_py3 import AtaExternalSecuritySolution -from ._models_py3 import AtaSolutionProperties -from ._models_py3 import AzureResourceDetails -from ._models_py3 import AzureResourceLink -from ._models_py3 import CefExternalSecuritySolution -from ._models_py3 import CefSolutionProperties -from ._models_py3 import CloudErrorBody -from ._models_py3 import ConnectableResource -from ._models_py3 import ConnectedResource -from ._models_py3 import ConnectedWorkspace -from ._models_py3 import DiscoveredSecuritySolution -from ._models_py3 import DiscoveredSecuritySolutionList -from ._models_py3 import EffectiveNetworkSecurityGroups -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ExternalSecuritySolution -from ._models_py3 import ExternalSecuritySolutionKind -from ._models_py3 import ExternalSecuritySolutionList -from ._models_py3 import ExternalSecuritySolutionProperties -from ._models_py3 import JitNetworkAccessPoliciesList -from ._models_py3 import JitNetworkAccessPolicy -from ._models_py3 import JitNetworkAccessPolicyInitiatePort -from ._models_py3 import JitNetworkAccessPolicyInitiateRequest -from ._models_py3 import JitNetworkAccessPolicyInitiateVirtualMachine -from ._models_py3 import JitNetworkAccessPolicyVirtualMachine -from ._models_py3 import JitNetworkAccessPortRule -from ._models_py3 import JitNetworkAccessRequest -from ._models_py3 import JitNetworkAccessRequestPort -from ._models_py3 import JitNetworkAccessRequestVirtualMachine -from ._models_py3 import Kind -from ._models_py3 import Location -from ._models_py3 import OnPremiseResourceDetails -from ._models_py3 import OnPremiseSqlResourceDetails -from ._models_py3 import PathRecommendation -from ._models_py3 import ProtectionMode -from ._models_py3 import PublisherInfo -from ._models_py3 import Resource -from ._models_py3 import ResourceDetails -from ._models_py3 import Rule -from ._models_py3 import SecureScoreControlDefinitionItem -from ._models_py3 import SecureScoreControlDefinitionList -from ._models_py3 import SecureScoreControlDefinitionSource -from ._models_py3 import SecureScoreControlDetails -from ._models_py3 import SecureScoreControlList -from ._models_py3 import SecureScoreControlScore -from ._models_py3 import SecureScoreItem -from ._models_py3 import SecureScoresList -from ._models_py3 import SecurityAssessment -from ._models_py3 import SecurityAssessmentList -from ._models_py3 import SecurityAssessmentMetadata -from ._models_py3 import SecurityAssessmentMetadataList -from ._models_py3 import SecurityAssessmentMetadataPartnerData -from ._models_py3 import SecurityAssessmentMetadataProperties -from ._models_py3 import SecurityAssessmentPartnerData -from ._models_py3 import SecuritySolution -from ._models_py3 import SecuritySolutionList -from ._models_py3 import SecuritySolutionsReferenceData -from ._models_py3 import SecuritySolutionsReferenceDataList -from ._models_py3 import ServerVulnerabilityAssessment -from ._models_py3 import ServerVulnerabilityAssessmentsList -from ._models_py3 import TopologyList -from ._models_py3 import TopologyResource -from ._models_py3 import TopologySingleResource -from ._models_py3 import TopologySingleResourceChild -from ._models_py3 import TopologySingleResourceParent -from ._models_py3 import UserRecommendation -from ._models_py3 import VmRecommendation - -from ._security_center_enums import AadConnectivityStateEnum -from ._security_center_enums import AdaptiveApplicationControlIssue -from ._security_center_enums import AssessmentStatusCode -from ._security_center_enums import AssessmentType -from ._security_center_enums import Categories -from ._security_center_enums import ConfigurationStatus -from ._security_center_enums import ConnectionType -from ._security_center_enums import ControlType -from ._security_center_enums import Direction -from ._security_center_enums import EnforcementMode -from ._security_center_enums import EnforcementSupport -from ._security_center_enums import ExpandControlsEnum -from ._security_center_enums import ExpandEnum -from ._security_center_enums import ExternalSecuritySolutionKindEnum -from ._security_center_enums import FileType -from ._security_center_enums import ImplementationEffort -from ._security_center_enums import ProtocolEnum -from ._security_center_enums import ProvisioningState -from ._security_center_enums import RecommendationAction -from ._security_center_enums import RecommendationStatus -from ._security_center_enums import RecommendationType -from ._security_center_enums import SecurityFamily -from ._security_center_enums import ServerVulnerabilityAssessmentPropertiesProvisioningState -from ._security_center_enums import Severity -from ._security_center_enums import Source -from ._security_center_enums import SourceSystem -from ._security_center_enums import Status -from ._security_center_enums import StatusReason -from ._security_center_enums import Threats -from ._security_center_enums import TransportProtocol -from ._security_center_enums import UserImpact -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AadConnectivityState", - "AadExternalSecuritySolution", - "AadSolutionProperties", - "AdaptiveApplicationControlGroup", - "AdaptiveApplicationControlGroups", - "AdaptiveApplicationControlIssueSummary", - "AdaptiveNetworkHardening", - "AdaptiveNetworkHardeningEnforceRequest", - "AdaptiveNetworkHardeningsList", - "AllowedConnectionsList", - "AllowedConnectionsResource", - "AssessmentLinks", - "AssessmentStatus", - "AtaExternalSecuritySolution", - "AtaSolutionProperties", - "AzureResourceDetails", - "AzureResourceLink", - "CefExternalSecuritySolution", - "CefSolutionProperties", - "CloudErrorBody", - "ConnectableResource", - "ConnectedResource", - "ConnectedWorkspace", - "DiscoveredSecuritySolution", - "DiscoveredSecuritySolutionList", - "EffectiveNetworkSecurityGroups", - "ErrorAdditionalInfo", - "ExternalSecuritySolution", - "ExternalSecuritySolutionKind", - "ExternalSecuritySolutionList", - "ExternalSecuritySolutionProperties", - "JitNetworkAccessPoliciesList", - "JitNetworkAccessPolicy", - "JitNetworkAccessPolicyInitiatePort", - "JitNetworkAccessPolicyInitiateRequest", - "JitNetworkAccessPolicyInitiateVirtualMachine", - "JitNetworkAccessPolicyVirtualMachine", - "JitNetworkAccessPortRule", - "JitNetworkAccessRequest", - "JitNetworkAccessRequestPort", - "JitNetworkAccessRequestVirtualMachine", - "Kind", - "Location", - "OnPremiseResourceDetails", - "OnPremiseSqlResourceDetails", - "PathRecommendation", - "ProtectionMode", - "PublisherInfo", - "Resource", - "ResourceDetails", - "Rule", - "SecureScoreControlDefinitionItem", - "SecureScoreControlDefinitionList", - "SecureScoreControlDefinitionSource", - "SecureScoreControlDetails", - "SecureScoreControlList", - "SecureScoreControlScore", - "SecureScoreItem", - "SecureScoresList", - "SecurityAssessment", - "SecurityAssessmentList", - "SecurityAssessmentMetadata", - "SecurityAssessmentMetadataList", - "SecurityAssessmentMetadataPartnerData", - "SecurityAssessmentMetadataProperties", - "SecurityAssessmentPartnerData", - "SecuritySolution", - "SecuritySolutionList", - "SecuritySolutionsReferenceData", - "SecuritySolutionsReferenceDataList", - "ServerVulnerabilityAssessment", - "ServerVulnerabilityAssessmentsList", - "TopologyList", - "TopologyResource", - "TopologySingleResource", - "TopologySingleResourceChild", - "TopologySingleResourceParent", - "UserRecommendation", - "VmRecommendation", - "AadConnectivityStateEnum", - "AdaptiveApplicationControlIssue", - "AssessmentStatusCode", - "AssessmentType", - "Categories", - "ConfigurationStatus", - "ConnectionType", - "ControlType", - "Direction", - "EnforcementMode", - "EnforcementSupport", - "ExpandControlsEnum", - "ExpandEnum", - "ExternalSecuritySolutionKindEnum", - "FileType", - "ImplementationEffort", - "ProtocolEnum", - "ProvisioningState", - "RecommendationAction", - "RecommendationStatus", - "RecommendationType", - "SecurityFamily", - "ServerVulnerabilityAssessmentPropertiesProvisioningState", - "Severity", - "Source", - "SourceSystem", - "Status", - "StatusReason", - "Threats", - "TransportProtocol", - "UserImpact", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_models_py3.py deleted file mode 100644 index fa0c2aba10dc..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_models_py3.py +++ /dev/null @@ -1,3749 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AadConnectivityState(_serialization.Model): - """Describes an Azure resource with kind. - - :ivar connectivity_state: The connectivity state of the external AAD solution. Known values - are: "Discovered", "NotLicensed", and "Connected". - :vartype connectivity_state: str or - ~azure.mgmt.security.v2020_01_01.models.AadConnectivityStateEnum - """ - - _attribute_map = { - "connectivity_state": {"key": "connectivityState", "type": "str"}, - } - - def __init__( - self, *, connectivity_state: Optional[Union[str, "_models.AadConnectivityStateEnum"]] = None, **kwargs: Any - ) -> None: - """ - :keyword connectivity_state: The connectivity state of the external AAD solution. Known values - are: "Discovered", "NotLicensed", and "Connected". - :paramtype connectivity_state: str or - ~azure.mgmt.security.v2020_01_01.models.AadConnectivityStateEnum - """ - super().__init__(**kwargs) - self.connectivity_state = connectivity_state - - -class Location(_serialization.Model): - """Describes an Azure resource with location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location where the resource is stored. - :vartype location: str - """ - - _validation = { - "location": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location = None - - -class ExternalSecuritySolutionKind(_serialization.Model): - """Describes an Azure resource with kind. - - :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :vartype kind: str or ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - """ - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__( - self, *, kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, **kwargs: Any - ) -> None: - """ - :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :paramtype kind: str or - ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - """ - super().__init__(**kwargs) - self.kind = kind - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ExternalSecuritySolution(Resource, ExternalSecuritySolutionKind, Location): - """Represents a security solution external to Microsoft Defender for Cloud which sends information - to an OMS workspace and whose data is displayed by Microsoft Defender for Cloud. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :vartype kind: str or ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, *, kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, **kwargs: Any - ) -> None: - """ - :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :paramtype kind: str or - ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - """ - super().__init__(kind=kind, **kwargs) - self.location = None - self.kind = kind - self.id = None - self.name = None - self.type = None - - -class AadExternalSecuritySolution(ExternalSecuritySolution): - """Represents an AAD identity protection solution which sends logs to an OMS workspace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :vartype kind: str or ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: The external security solution properties for AAD solutions. - :vartype properties: ~azure.mgmt.security.v2020_01_01.models.AadSolutionProperties - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "AadSolutionProperties"}, - } - - def __init__( - self, - *, - kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, - properties: Optional["_models.AadSolutionProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :paramtype kind: str or - ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - :keyword properties: The external security solution properties for AAD solutions. - :paramtype properties: ~azure.mgmt.security.v2020_01_01.models.AadSolutionProperties - """ - super().__init__(kind=kind, **kwargs) - self.properties = properties - - -class ExternalSecuritySolutionProperties(_serialization.Model): - """The solution properties (correspond to the solution kind). - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar device_vendor: - :vartype device_vendor: str - :ivar device_type: - :vartype device_type: str - :ivar workspace: Represents an OMS workspace to which the solution is connected. - :vartype workspace: ~azure.mgmt.security.v2020_01_01.models.ConnectedWorkspace - """ - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "device_vendor": {"key": "deviceVendor", "type": "str"}, - "device_type": {"key": "deviceType", "type": "str"}, - "workspace": {"key": "workspace", "type": "ConnectedWorkspace"}, - } - - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - device_vendor: Optional[str] = None, - device_type: Optional[str] = None, - workspace: Optional["_models.ConnectedWorkspace"] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword device_vendor: - :paramtype device_vendor: str - :keyword device_type: - :paramtype device_type: str - :keyword workspace: Represents an OMS workspace to which the solution is connected. - :paramtype workspace: ~azure.mgmt.security.v2020_01_01.models.ConnectedWorkspace - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.device_vendor = device_vendor - self.device_type = device_type - self.workspace = workspace - - -class AadSolutionProperties(ExternalSecuritySolutionProperties, AadConnectivityState): - """The external security solution properties for AAD solutions. - - :ivar connectivity_state: The connectivity state of the external AAD solution. Known values - are: "Discovered", "NotLicensed", and "Connected". - :vartype connectivity_state: str or - ~azure.mgmt.security.v2020_01_01.models.AadConnectivityStateEnum - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar device_vendor: - :vartype device_vendor: str - :ivar device_type: - :vartype device_type: str - :ivar workspace: Represents an OMS workspace to which the solution is connected. - :vartype workspace: ~azure.mgmt.security.v2020_01_01.models.ConnectedWorkspace - """ - - _attribute_map = { - "connectivity_state": {"key": "connectivityState", "type": "str"}, - "additional_properties": {"key": "", "type": "{object}"}, - "device_vendor": {"key": "deviceVendor", "type": "str"}, - "device_type": {"key": "deviceType", "type": "str"}, - "workspace": {"key": "workspace", "type": "ConnectedWorkspace"}, - } - - def __init__( - self, - *, - connectivity_state: Optional[Union[str, "_models.AadConnectivityStateEnum"]] = None, - additional_properties: Optional[Dict[str, Any]] = None, - device_vendor: Optional[str] = None, - device_type: Optional[str] = None, - workspace: Optional["_models.ConnectedWorkspace"] = None, - **kwargs: Any - ) -> None: - """ - :keyword connectivity_state: The connectivity state of the external AAD solution. Known values - are: "Discovered", "NotLicensed", and "Connected". - :paramtype connectivity_state: str or - ~azure.mgmt.security.v2020_01_01.models.AadConnectivityStateEnum - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword device_vendor: - :paramtype device_vendor: str - :keyword device_type: - :paramtype device_type: str - :keyword workspace: Represents an OMS workspace to which the solution is connected. - :paramtype workspace: ~azure.mgmt.security.v2020_01_01.models.ConnectedWorkspace - """ - super().__init__( - additional_properties=additional_properties, - device_vendor=device_vendor, - device_type=device_type, - workspace=workspace, - connectivity_state=connectivity_state, - **kwargs - ) - self.connectivity_state = connectivity_state - self.additional_properties = additional_properties - self.device_vendor = device_vendor - self.device_type = device_type - self.workspace = workspace - - -class AdaptiveApplicationControlGroup(Resource, Location): # pylint: disable=too-many-instance-attributes - """AdaptiveApplicationControlGroup. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar enforcement_mode: The application control policy enforcement/protection mode of the - machine group. Known values are: "Audit", "Enforce", and "None". - :vartype enforcement_mode: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - :ivar protection_mode: The protection mode of the collection/file types. Exe/Msi/Script are - used for Windows, Executable is used for Linux. - :vartype protection_mode: ~azure.mgmt.security.v2020_01_01.models.ProtectionMode - :ivar configuration_status: The configuration status of the machines group or machine or rule. - Known values are: "Configured", "NotConfigured", "InProgress", "Failed", and "NoStatus". - :vartype configuration_status: str or - ~azure.mgmt.security.v2020_01_01.models.ConfigurationStatus - :ivar recommendation_status: The initial recommendation status of the machine group or machine. - Known values are: "Recommended", "NotRecommended", "NotAvailable", and "NoStatus". - :vartype recommendation_status: str or - ~azure.mgmt.security.v2020_01_01.models.RecommendationStatus - :ivar issues: - :vartype issues: - list[~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlIssueSummary] - :ivar source_system: The source type of the machine group. Known values are: "Azure_AppLocker", - "Azure_AuditD", "NonAzure_AppLocker", "NonAzure_AuditD", and "None". - :vartype source_system: str or ~azure.mgmt.security.v2020_01_01.models.SourceSystem - :ivar vm_recommendations: - :vartype vm_recommendations: list[~azure.mgmt.security.v2020_01_01.models.VmRecommendation] - :ivar path_recommendations: - :vartype path_recommendations: list[~azure.mgmt.security.v2020_01_01.models.PathRecommendation] - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "configuration_status": {"readonly": True}, - "recommendation_status": {"readonly": True}, - "issues": {"readonly": True}, - "source_system": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "enforcement_mode": {"key": "properties.enforcementMode", "type": "str"}, - "protection_mode": {"key": "properties.protectionMode", "type": "ProtectionMode"}, - "configuration_status": {"key": "properties.configurationStatus", "type": "str"}, - "recommendation_status": {"key": "properties.recommendationStatus", "type": "str"}, - "issues": {"key": "properties.issues", "type": "[AdaptiveApplicationControlIssueSummary]"}, - "source_system": {"key": "properties.sourceSystem", "type": "str"}, - "vm_recommendations": {"key": "properties.vmRecommendations", "type": "[VmRecommendation]"}, - "path_recommendations": {"key": "properties.pathRecommendations", "type": "[PathRecommendation]"}, - } - - def __init__( - self, - *, - enforcement_mode: Optional[Union[str, "_models.EnforcementMode"]] = None, - protection_mode: Optional["_models.ProtectionMode"] = None, - vm_recommendations: Optional[List["_models.VmRecommendation"]] = None, - path_recommendations: Optional[List["_models.PathRecommendation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword enforcement_mode: The application control policy enforcement/protection mode of the - machine group. Known values are: "Audit", "Enforce", and "None". - :paramtype enforcement_mode: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - :keyword protection_mode: The protection mode of the collection/file types. Exe/Msi/Script are - used for Windows, Executable is used for Linux. - :paramtype protection_mode: ~azure.mgmt.security.v2020_01_01.models.ProtectionMode - :keyword vm_recommendations: - :paramtype vm_recommendations: list[~azure.mgmt.security.v2020_01_01.models.VmRecommendation] - :keyword path_recommendations: - :paramtype path_recommendations: - list[~azure.mgmt.security.v2020_01_01.models.PathRecommendation] - """ - super().__init__(**kwargs) - self.location = None - self.enforcement_mode = enforcement_mode - self.protection_mode = protection_mode - self.configuration_status = None - self.recommendation_status = None - self.issues = None - self.source_system = None - self.vm_recommendations = vm_recommendations - self.path_recommendations = path_recommendations - self.id = None - self.name = None - self.type = None - - -class AdaptiveApplicationControlGroups(_serialization.Model): - """Represents a list of VM/server groups and set of rules that are Recommended by Microsoft - Defender for Cloud to be allowed. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AdaptiveApplicationControlGroup]"}, - } - - def __init__( - self, *, value: Optional[List["_models.AdaptiveApplicationControlGroup"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: - :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup] - """ - super().__init__(**kwargs) - self.value = value - - -class AdaptiveApplicationControlIssueSummary(_serialization.Model): - """Represents a summary of the alerts of the machine group. - - :ivar issue: An alert that machines within a group can have. Known values are: - "ViolationsAudited", "ViolationsBlocked", "MsiAndScriptViolationsAudited", - "MsiAndScriptViolationsBlocked", "ExecutableViolationsAudited", and "RulesViolatedManually". - :vartype issue: str or ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlIssue - :ivar number_of_vms: The number of machines in the group that have this alert. - :vartype number_of_vms: float - """ - - _attribute_map = { - "issue": {"key": "issue", "type": "str"}, - "number_of_vms": {"key": "numberOfVms", "type": "float"}, - } - - def __init__( - self, - *, - issue: Optional[Union[str, "_models.AdaptiveApplicationControlIssue"]] = None, - number_of_vms: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword issue: An alert that machines within a group can have. Known values are: - "ViolationsAudited", "ViolationsBlocked", "MsiAndScriptViolationsAudited", - "MsiAndScriptViolationsBlocked", "ExecutableViolationsAudited", and "RulesViolatedManually". - :paramtype issue: str or - ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlIssue - :keyword number_of_vms: The number of machines in the group that have this alert. - :paramtype number_of_vms: float - """ - super().__init__(**kwargs) - self.issue = issue - self.number_of_vms = number_of_vms - - -class AdaptiveNetworkHardening(Resource): - """The resource whose properties describes the Adaptive Network Hardening settings for some Azure - resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar rules: The security rules which are recommended to be effective on the VM. - :vartype rules: list[~azure.mgmt.security.v2020_01_01.models.Rule] - :ivar rules_calculation_time: The UTC time on which the rules were calculated. - :vartype rules_calculation_time: ~datetime.datetime - :ivar effective_network_security_groups: The Network Security Groups effective on the network - interfaces of the protected resource. - :vartype effective_network_security_groups: - list[~azure.mgmt.security.v2020_01_01.models.EffectiveNetworkSecurityGroups] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "rules": {"key": "properties.rules", "type": "[Rule]"}, - "rules_calculation_time": {"key": "properties.rulesCalculationTime", "type": "iso-8601"}, - "effective_network_security_groups": { - "key": "properties.effectiveNetworkSecurityGroups", - "type": "[EffectiveNetworkSecurityGroups]", - }, - } - - def __init__( - self, - *, - rules: Optional[List["_models.Rule"]] = None, - rules_calculation_time: Optional[datetime.datetime] = None, - effective_network_security_groups: Optional[List["_models.EffectiveNetworkSecurityGroups"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword rules: The security rules which are recommended to be effective on the VM. - :paramtype rules: list[~azure.mgmt.security.v2020_01_01.models.Rule] - :keyword rules_calculation_time: The UTC time on which the rules were calculated. - :paramtype rules_calculation_time: ~datetime.datetime - :keyword effective_network_security_groups: The Network Security Groups effective on the - network interfaces of the protected resource. - :paramtype effective_network_security_groups: - list[~azure.mgmt.security.v2020_01_01.models.EffectiveNetworkSecurityGroups] - """ - super().__init__(**kwargs) - self.rules = rules - self.rules_calculation_time = rules_calculation_time - self.effective_network_security_groups = effective_network_security_groups - - -class AdaptiveNetworkHardeningEnforceRequest(_serialization.Model): - """AdaptiveNetworkHardeningEnforceRequest. - - All required parameters must be populated in order to send to server. - - :ivar rules: The rules to enforce. Required. - :vartype rules: list[~azure.mgmt.security.v2020_01_01.models.Rule] - :ivar network_security_groups: The Azure resource IDs of the effective network security groups - that will be updated with the created security rules from the Adaptive Network Hardening rules. - Required. - :vartype network_security_groups: list[str] - """ - - _validation = { - "rules": {"required": True}, - "network_security_groups": {"required": True}, - } - - _attribute_map = { - "rules": {"key": "rules", "type": "[Rule]"}, - "network_security_groups": {"key": "networkSecurityGroups", "type": "[str]"}, - } - - def __init__(self, *, rules: List["_models.Rule"], network_security_groups: List[str], **kwargs: Any) -> None: - """ - :keyword rules: The rules to enforce. Required. - :paramtype rules: list[~azure.mgmt.security.v2020_01_01.models.Rule] - :keyword network_security_groups: The Azure resource IDs of the effective network security - groups that will be updated with the created security rules from the Adaptive Network Hardening - rules. Required. - :paramtype network_security_groups: list[str] - """ - super().__init__(**kwargs) - self.rules = rules - self.network_security_groups = network_security_groups - - -class AdaptiveNetworkHardeningsList(_serialization.Model): - """Response for ListAdaptiveNetworkHardenings API service call. - - :ivar value: A list of Adaptive Network Hardenings resources. - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardening] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AdaptiveNetworkHardening]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AdaptiveNetworkHardening"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: A list of Adaptive Network Hardenings resources. - :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardening] - :keyword next_link: The URL to get the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AllowedConnectionsList(_serialization.Model): - """List of all possible traffic between Azure resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.AllowedConnectionsResource] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AllowedConnectionsResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class AllowedConnectionsResource(Resource, Location): - """The resource whose properties describes the allowed traffic between Azure resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar calculated_date_time: The UTC time on which the allowed connections resource was - calculated. - :vartype calculated_date_time: ~datetime.datetime - :ivar connectable_resources: List of connectable resources. - :vartype connectable_resources: - list[~azure.mgmt.security.v2020_01_01.models.ConnectableResource] - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "calculated_date_time": {"readonly": True}, - "connectable_resources": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "calculated_date_time": {"key": "properties.calculatedDateTime", "type": "iso-8601"}, - "connectable_resources": {"key": "properties.connectableResources", "type": "[ConnectableResource]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location = None - self.calculated_date_time = None - self.connectable_resources = None - self.id = None - self.name = None - self.type = None - - -class AssessmentLinks(_serialization.Model): - """Links relevant to the assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar azure_portal_uri: Link to assessment in Azure Portal. - :vartype azure_portal_uri: str - """ - - _validation = { - "azure_portal_uri": {"readonly": True}, - } - - _attribute_map = { - "azure_portal_uri": {"key": "azurePortalUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.azure_portal_uri = None - - -class AssessmentStatus(_serialization.Model): - """The result of the assessment. - - All required parameters must be populated in order to send to server. - - :ivar code: Programmatic code for the status of the assessment. Required. Known values are: - "Healthy", "Unhealthy", and "NotApplicable". - :vartype code: str or ~azure.mgmt.security.v2020_01_01.models.AssessmentStatusCode - :ivar cause: Programmatic code for the cause of the assessment status. - :vartype cause: str - :ivar description: Human readable description of the assessment status. - :vartype description: str - """ - - _validation = { - "code": {"required": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "cause": {"key": "cause", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - code: Union[str, "_models.AssessmentStatusCode"], - cause: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: Programmatic code for the status of the assessment. Required. Known values are: - "Healthy", "Unhealthy", and "NotApplicable". - :paramtype code: str or ~azure.mgmt.security.v2020_01_01.models.AssessmentStatusCode - :keyword cause: Programmatic code for the cause of the assessment status. - :paramtype cause: str - :keyword description: Human readable description of the assessment status. - :paramtype description: str - """ - super().__init__(**kwargs) - self.code = code - self.cause = cause - self.description = description - - -class AtaExternalSecuritySolution(ExternalSecuritySolution): - """Represents an ATA security solution which sends logs to an OMS workspace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :vartype kind: str or ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: The external security solution properties for ATA solutions. - :vartype properties: ~azure.mgmt.security.v2020_01_01.models.AtaSolutionProperties - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "AtaSolutionProperties"}, - } - - def __init__( - self, - *, - kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, - properties: Optional["_models.AtaSolutionProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :paramtype kind: str or - ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - :keyword properties: The external security solution properties for ATA solutions. - :paramtype properties: ~azure.mgmt.security.v2020_01_01.models.AtaSolutionProperties - """ - super().__init__(kind=kind, **kwargs) - self.properties = properties - - -class AtaSolutionProperties(ExternalSecuritySolutionProperties): - """The external security solution properties for ATA solutions. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar device_vendor: - :vartype device_vendor: str - :ivar device_type: - :vartype device_type: str - :ivar workspace: Represents an OMS workspace to which the solution is connected. - :vartype workspace: ~azure.mgmt.security.v2020_01_01.models.ConnectedWorkspace - :ivar last_event_received: - :vartype last_event_received: str - """ - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "device_vendor": {"key": "deviceVendor", "type": "str"}, - "device_type": {"key": "deviceType", "type": "str"}, - "workspace": {"key": "workspace", "type": "ConnectedWorkspace"}, - "last_event_received": {"key": "lastEventReceived", "type": "str"}, - } - - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - device_vendor: Optional[str] = None, - device_type: Optional[str] = None, - workspace: Optional["_models.ConnectedWorkspace"] = None, - last_event_received: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword device_vendor: - :paramtype device_vendor: str - :keyword device_type: - :paramtype device_type: str - :keyword workspace: Represents an OMS workspace to which the solution is connected. - :paramtype workspace: ~azure.mgmt.security.v2020_01_01.models.ConnectedWorkspace - :keyword last_event_received: - :paramtype last_event_received: str - """ - super().__init__( - additional_properties=additional_properties, - device_vendor=device_vendor, - device_type=device_type, - workspace=workspace, - **kwargs - ) - self.last_event_received = last_event_received - - -class ResourceDetails(_serialization.Model): - """Details of the resource that was assessed. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureResourceDetails, OnPremiseResourceDetails - - All required parameters must be populated in order to send to server. - - :ivar source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2020_01_01.models.Source - """ - - _validation = { - "source": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - } - - _subtype_map = {"source": {"Azure": "AzureResourceDetails", "OnPremise": "OnPremiseResourceDetails"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.source: Optional[str] = None - - -class AzureResourceDetails(ResourceDetails): - """Details of the Azure resource that was assessed. - - 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 source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2020_01_01.models.Source - :ivar id: Azure resource Id of the assessed resource. - :vartype id: str - """ - - _validation = { - "source": {"required": True}, - "id": {"readonly": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.source: str = "Azure" - self.id = None - - -class AzureResourceLink(_serialization.Model): - """Describes an Azure resource with kind. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - - -class CefExternalSecuritySolution(ExternalSecuritySolution): - """Represents a security solution which sends CEF logs to an OMS workspace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :vartype kind: str or ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: The external security solution properties for CEF solutions. - :vartype properties: ~azure.mgmt.security.v2020_01_01.models.CefSolutionProperties - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "CefSolutionProperties"}, - } - - def __init__( - self, - *, - kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, - properties: Optional["_models.CefSolutionProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". - :paramtype kind: str or - ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolutionKindEnum - :keyword properties: The external security solution properties for CEF solutions. - :paramtype properties: ~azure.mgmt.security.v2020_01_01.models.CefSolutionProperties - """ - super().__init__(kind=kind, **kwargs) - self.properties = properties - - -class CefSolutionProperties(ExternalSecuritySolutionProperties): - """The external security solution properties for CEF solutions. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar device_vendor: - :vartype device_vendor: str - :ivar device_type: - :vartype device_type: str - :ivar workspace: Represents an OMS workspace to which the solution is connected. - :vartype workspace: ~azure.mgmt.security.v2020_01_01.models.ConnectedWorkspace - :ivar hostname: - :vartype hostname: str - :ivar agent: - :vartype agent: str - :ivar last_event_received: - :vartype last_event_received: str - """ - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "device_vendor": {"key": "deviceVendor", "type": "str"}, - "device_type": {"key": "deviceType", "type": "str"}, - "workspace": {"key": "workspace", "type": "ConnectedWorkspace"}, - "hostname": {"key": "hostname", "type": "str"}, - "agent": {"key": "agent", "type": "str"}, - "last_event_received": {"key": "lastEventReceived", "type": "str"}, - } - - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - device_vendor: Optional[str] = None, - device_type: Optional[str] = None, - workspace: Optional["_models.ConnectedWorkspace"] = None, - hostname: Optional[str] = None, - agent: Optional[str] = None, - last_event_received: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword device_vendor: - :paramtype device_vendor: str - :keyword device_type: - :paramtype device_type: str - :keyword workspace: Represents an OMS workspace to which the solution is connected. - :paramtype workspace: ~azure.mgmt.security.v2020_01_01.models.ConnectedWorkspace - :keyword hostname: - :paramtype hostname: str - :keyword agent: - :paramtype agent: str - :keyword last_event_received: - :paramtype last_event_received: str - """ - super().__init__( - additional_properties=additional_properties, - device_vendor=device_vendor, - device_type=device_type, - workspace=workspace, - **kwargs - ) - self.hostname = hostname - self.agent = agent - self.last_event_received = last_event_received - - -class CloudErrorBody(_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.security.v2020_01_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2020_01_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ConnectableResource(_serialization.Model): - """Describes the allowed inbound and outbound traffic of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The Azure resource id. - :vartype id: str - :ivar inbound_connected_resources: The list of Azure resources that the resource has inbound - allowed connection from. - :vartype inbound_connected_resources: - list[~azure.mgmt.security.v2020_01_01.models.ConnectedResource] - :ivar outbound_connected_resources: The list of Azure resources that the resource has outbound - allowed connection to. - :vartype outbound_connected_resources: - list[~azure.mgmt.security.v2020_01_01.models.ConnectedResource] - """ - - _validation = { - "id": {"readonly": True}, - "inbound_connected_resources": {"readonly": True}, - "outbound_connected_resources": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "inbound_connected_resources": {"key": "inboundConnectedResources", "type": "[ConnectedResource]"}, - "outbound_connected_resources": {"key": "outboundConnectedResources", "type": "[ConnectedResource]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.inbound_connected_resources = None - self.outbound_connected_resources = None - - -class ConnectedResource(_serialization.Model): - """Describes properties of a connected resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar connected_resource_id: The Azure resource id of the connected resource. - :vartype connected_resource_id: str - :ivar tcp_ports: The allowed tcp ports. - :vartype tcp_ports: str - :ivar udp_ports: The allowed udp ports. - :vartype udp_ports: str - """ - - _validation = { - "connected_resource_id": {"readonly": True}, - "tcp_ports": {"readonly": True}, - "udp_ports": {"readonly": True}, - } - - _attribute_map = { - "connected_resource_id": {"key": "connectedResourceId", "type": "str"}, - "tcp_ports": {"key": "tcpPorts", "type": "str"}, - "udp_ports": {"key": "udpPorts", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.connected_resource_id = None - self.tcp_ports = None - self.udp_ports = None - - -class ConnectedWorkspace(_serialization.Model): - """Represents an OMS workspace to which the solution is connected. - - :ivar id: Azure resource ID of the connected OMS workspace. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Azure resource ID of the connected OMS workspace. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class DiscoveredSecuritySolution(Resource, Location): - """DiscoveredSecuritySolution. - - 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 location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar security_family: The security family of the discovered solution. Required. Known values - are: "Waf", "Ngfw", "SaasWaf", and "Va". - :vartype security_family: str or ~azure.mgmt.security.v2020_01_01.models.SecurityFamily - :ivar offer: The security solutions' image offer. Required. - :vartype offer: str - :ivar publisher: The security solutions' image publisher. Required. - :vartype publisher: str - :ivar sku: The security solutions' image sku. Required. - :vartype sku: str - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "security_family": {"required": True}, - "offer": {"required": True}, - "publisher": {"required": True}, - "sku": {"required": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "security_family": {"key": "properties.securityFamily", "type": "str"}, - "offer": {"key": "properties.offer", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "sku": {"key": "properties.sku", "type": "str"}, - } - - def __init__( - self, - *, - security_family: Union[str, "_models.SecurityFamily"], - offer: str, - publisher: str, - sku: str, - **kwargs: Any - ) -> None: - """ - :keyword security_family: The security family of the discovered solution. Required. Known - values are: "Waf", "Ngfw", "SaasWaf", and "Va". - :paramtype security_family: str or ~azure.mgmt.security.v2020_01_01.models.SecurityFamily - :keyword offer: The security solutions' image offer. Required. - :paramtype offer: str - :keyword publisher: The security solutions' image publisher. Required. - :paramtype publisher: str - :keyword sku: The security solutions' image sku. Required. - :paramtype sku: str - """ - super().__init__(**kwargs) - self.location = None - self.security_family = security_family - self.offer = offer - self.publisher = publisher - self.sku = sku - self.id = None - self.name = None - self.type = None - - -class DiscoveredSecuritySolutionList(_serialization.Model): - """DiscoveredSecuritySolutionList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiscoveredSecuritySolution]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.DiscoveredSecuritySolution"]] = None, **kwargs: Any) -> None: - """ - :keyword value: - :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class EffectiveNetworkSecurityGroups(_serialization.Model): - """Describes the Network Security Groups effective on a network interface. - - :ivar network_interface: The Azure resource ID of the network interface. - :vartype network_interface: str - :ivar network_security_groups: The Network Security Groups effective on the network interface. - :vartype network_security_groups: list[str] - """ - - _attribute_map = { - "network_interface": {"key": "networkInterface", "type": "str"}, - "network_security_groups": {"key": "networkSecurityGroups", "type": "[str]"}, - } - - def __init__( - self, - *, - network_interface: Optional[str] = None, - network_security_groups: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interface: The Azure resource ID of the network interface. - :paramtype network_interface: str - :keyword network_security_groups: The Network Security Groups effective on the network - interface. - :paramtype network_security_groups: list[str] - """ - super().__init__(**kwargs) - self.network_interface = network_interface - self.network_security_groups = network_security_groups - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ExternalSecuritySolutionList(_serialization.Model): - """ExternalSecuritySolutionList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ExternalSecuritySolution]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.ExternalSecuritySolution"]] = None, **kwargs: Any) -> None: - """ - :keyword value: - :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class JitNetworkAccessPoliciesList(_serialization.Model): - """JitNetworkAccessPoliciesList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[JitNetworkAccessPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.JitNetworkAccessPolicy"]] = None, **kwargs: Any) -> None: - """ - :keyword value: - :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class Kind(_serialization.Model): - """Describes an Azure resource with kind. - - :ivar kind: Kind of the resource. - :vartype kind: str - """ - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__(self, *, kind: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword kind: Kind of the resource. - :paramtype kind: str - """ - super().__init__(**kwargs) - self.kind = kind - - -class JitNetworkAccessPolicy(Resource, Kind, Location): - """JitNetworkAccessPolicy. - - 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 location: Location where the resource is stored. - :vartype location: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar virtual_machines: Configurations for Microsoft.Compute/virtualMachines resource type. - Required. - :vartype virtual_machines: - list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyVirtualMachine] - :ivar requests: - :vartype requests: list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest] - :ivar provisioning_state: Gets the provisioning state of the Just-in-Time policy. - :vartype provisioning_state: str - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "virtual_machines": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[JitNetworkAccessPolicyVirtualMachine]"}, - "requests": {"key": "properties.requests", "type": "[JitNetworkAccessRequest]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - virtual_machines: List["_models.JitNetworkAccessPolicyVirtualMachine"], - kind: Optional[str] = None, - requests: Optional[List["_models.JitNetworkAccessRequest"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword virtual_machines: Configurations for Microsoft.Compute/virtualMachines resource type. - Required. - :paramtype virtual_machines: - list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyVirtualMachine] - :keyword requests: - :paramtype requests: list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest] - """ - super().__init__(kind=kind, **kwargs) - self.location = None - self.kind = kind - self.virtual_machines = virtual_machines - self.requests = requests - self.provisioning_state = None - self.id = None - self.name = None - self.type = None - - -class JitNetworkAccessPolicyInitiatePort(_serialization.Model): - """JitNetworkAccessPolicyInitiatePort. - - All required parameters must be populated in order to send to server. - - :ivar number: Required. - :vartype number: int - :ivar allowed_source_address_prefix: Source of the allowed traffic. If omitted, the request - will be for the source IP address of the initiate request. - :vartype allowed_source_address_prefix: str - :ivar end_time_utc: The time to close the request in UTC. Required. - :vartype end_time_utc: ~datetime.datetime - """ - - _validation = { - "number": {"required": True, "maximum": 65535, "minimum": 0}, - "end_time_utc": {"required": True}, - } - - _attribute_map = { - "number": {"key": "number", "type": "int"}, - "allowed_source_address_prefix": {"key": "allowedSourceAddressPrefix", "type": "str"}, - "end_time_utc": {"key": "endTimeUtc", "type": "iso-8601"}, - } - - def __init__( - self, - *, - number: int, - end_time_utc: datetime.datetime, - allowed_source_address_prefix: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword number: Required. - :paramtype number: int - :keyword allowed_source_address_prefix: Source of the allowed traffic. If omitted, the request - will be for the source IP address of the initiate request. - :paramtype allowed_source_address_prefix: str - :keyword end_time_utc: The time to close the request in UTC. Required. - :paramtype end_time_utc: ~datetime.datetime - """ - super().__init__(**kwargs) - self.number = number - self.allowed_source_address_prefix = allowed_source_address_prefix - self.end_time_utc = end_time_utc - - -class JitNetworkAccessPolicyInitiateRequest(_serialization.Model): - """JitNetworkAccessPolicyInitiateRequest. - - All required parameters must be populated in order to send to server. - - :ivar virtual_machines: A list of virtual machines & ports to open access for. Required. - :vartype virtual_machines: - list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiateVirtualMachine] - :ivar justification: The justification for making the initiate request. - :vartype justification: str - """ - - _validation = { - "virtual_machines": {"required": True}, - } - - _attribute_map = { - "virtual_machines": {"key": "virtualMachines", "type": "[JitNetworkAccessPolicyInitiateVirtualMachine]"}, - "justification": {"key": "justification", "type": "str"}, - } - - def __init__( - self, - *, - virtual_machines: List["_models.JitNetworkAccessPolicyInitiateVirtualMachine"], - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword virtual_machines: A list of virtual machines & ports to open access for. Required. - :paramtype virtual_machines: - list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiateVirtualMachine] - :keyword justification: The justification for making the initiate request. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.virtual_machines = virtual_machines - self.justification = justification - - -class JitNetworkAccessPolicyInitiateVirtualMachine(_serialization.Model): # pylint: disable=name-too-long - """JitNetworkAccessPolicyInitiateVirtualMachine. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID of the virtual machine that is linked to this policy. Required. - :vartype id: str - :ivar ports: The ports to open for the resource with the ``id``. Required. - :vartype ports: - list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiatePort] - """ - - _validation = { - "id": {"required": True}, - "ports": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "ports": {"key": "ports", "type": "[JitNetworkAccessPolicyInitiatePort]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - ports: List["_models.JitNetworkAccessPolicyInitiatePort"], - **kwargs: Any - ) -> None: - """ - :keyword id: Resource ID of the virtual machine that is linked to this policy. Required. - :paramtype id: str - :keyword ports: The ports to open for the resource with the ``id``. Required. - :paramtype ports: - list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiatePort] - """ - super().__init__(**kwargs) - self.id = id - self.ports = ports - - -class JitNetworkAccessPolicyVirtualMachine(_serialization.Model): - """JitNetworkAccessPolicyVirtualMachine. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID of the virtual machine that is linked to this policy. Required. - :vartype id: str - :ivar ports: Port configurations for the virtual machine. Required. - :vartype ports: list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPortRule] - :ivar public_ip_address: Public IP address of the Azure Firewall that is linked to this policy, - if applicable. - :vartype public_ip_address: str - """ - - _validation = { - "id": {"required": True}, - "ports": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "ports": {"key": "ports", "type": "[JitNetworkAccessPortRule]"}, - "public_ip_address": {"key": "publicIpAddress", "type": "str"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - ports: List["_models.JitNetworkAccessPortRule"], - public_ip_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource ID of the virtual machine that is linked to this policy. Required. - :paramtype id: str - :keyword ports: Port configurations for the virtual machine. Required. - :paramtype ports: list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPortRule] - :keyword public_ip_address: Public IP address of the Azure Firewall that is linked to this - policy, if applicable. - :paramtype public_ip_address: str - """ - super().__init__(**kwargs) - self.id = id - self.ports = ports - self.public_ip_address = public_ip_address - - -class JitNetworkAccessPortRule(_serialization.Model): - """JitNetworkAccessPortRule. - - All required parameters must be populated in order to send to server. - - :ivar number: Required. - :vartype number: int - :ivar protocol: Required. Known values are: "TCP", "UDP", and "*". - :vartype protocol: str or ~azure.mgmt.security.v2020_01_01.models.ProtocolEnum - :ivar allowed_source_address_prefix: Mutually exclusive with the "allowedSourceAddressPrefixes" - parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16". - :vartype allowed_source_address_prefix: str - :ivar allowed_source_address_prefixes: Mutually exclusive with the "allowedSourceAddressPrefix" - parameter. - :vartype allowed_source_address_prefixes: list[str] - :ivar max_request_access_duration: Maximum duration requests can be made for. In ISO 8601 - duration format. Minimum 5 minutes, maximum 1 day. Required. - :vartype max_request_access_duration: str - """ - - _validation = { - "number": {"required": True, "maximum": 65535, "minimum": 0}, - "protocol": {"required": True}, - "max_request_access_duration": {"required": True}, - } - - _attribute_map = { - "number": {"key": "number", "type": "int"}, - "protocol": {"key": "protocol", "type": "str"}, - "allowed_source_address_prefix": {"key": "allowedSourceAddressPrefix", "type": "str"}, - "allowed_source_address_prefixes": {"key": "allowedSourceAddressPrefixes", "type": "[str]"}, - "max_request_access_duration": {"key": "maxRequestAccessDuration", "type": "str"}, - } - - def __init__( - self, - *, - number: int, - protocol: Union[str, "_models.ProtocolEnum"], - max_request_access_duration: str, - allowed_source_address_prefix: Optional[str] = None, - allowed_source_address_prefixes: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword number: Required. - :paramtype number: int - :keyword protocol: Required. Known values are: "TCP", "UDP", and "*". - :paramtype protocol: str or ~azure.mgmt.security.v2020_01_01.models.ProtocolEnum - :keyword allowed_source_address_prefix: Mutually exclusive with the - "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for example - "192.168.0.3" or "192.168.0.0/16". - :paramtype allowed_source_address_prefix: str - :keyword allowed_source_address_prefixes: Mutually exclusive with the - "allowedSourceAddressPrefix" parameter. - :paramtype allowed_source_address_prefixes: list[str] - :keyword max_request_access_duration: Maximum duration requests can be made for. In ISO 8601 - duration format. Minimum 5 minutes, maximum 1 day. Required. - :paramtype max_request_access_duration: str - """ - super().__init__(**kwargs) - self.number = number - self.protocol = protocol - self.allowed_source_address_prefix = allowed_source_address_prefix - self.allowed_source_address_prefixes = allowed_source_address_prefixes - self.max_request_access_duration = max_request_access_duration - - -class JitNetworkAccessRequest(_serialization.Model): - """JitNetworkAccessRequest. - - All required parameters must be populated in order to send to server. - - :ivar virtual_machines: Required. - :vartype virtual_machines: - list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequestVirtualMachine] - :ivar start_time_utc: The start time of the request in UTC. Required. - :vartype start_time_utc: ~datetime.datetime - :ivar requestor: The identity of the person who made the request. Required. - :vartype requestor: str - :ivar justification: The justification for making the initiate request. - :vartype justification: str - """ - - _validation = { - "virtual_machines": {"required": True}, - "start_time_utc": {"required": True}, - "requestor": {"required": True}, - } - - _attribute_map = { - "virtual_machines": {"key": "virtualMachines", "type": "[JitNetworkAccessRequestVirtualMachine]"}, - "start_time_utc": {"key": "startTimeUtc", "type": "iso-8601"}, - "requestor": {"key": "requestor", "type": "str"}, - "justification": {"key": "justification", "type": "str"}, - } - - def __init__( - self, - *, - virtual_machines: List["_models.JitNetworkAccessRequestVirtualMachine"], - start_time_utc: datetime.datetime, - requestor: str, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword virtual_machines: Required. - :paramtype virtual_machines: - list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequestVirtualMachine] - :keyword start_time_utc: The start time of the request in UTC. Required. - :paramtype start_time_utc: ~datetime.datetime - :keyword requestor: The identity of the person who made the request. Required. - :paramtype requestor: str - :keyword justification: The justification for making the initiate request. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.virtual_machines = virtual_machines - self.start_time_utc = start_time_utc - self.requestor = requestor - self.justification = justification - - -class JitNetworkAccessRequestPort(_serialization.Model): - """JitNetworkAccessRequestPort. - - All required parameters must be populated in order to send to server. - - :ivar number: Required. - :vartype number: int - :ivar allowed_source_address_prefix: Mutually exclusive with the "allowedSourceAddressPrefixes" - parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16". - :vartype allowed_source_address_prefix: str - :ivar allowed_source_address_prefixes: Mutually exclusive with the "allowedSourceAddressPrefix" - parameter. - :vartype allowed_source_address_prefixes: list[str] - :ivar end_time_utc: The date & time at which the request ends in UTC. Required. - :vartype end_time_utc: ~datetime.datetime - :ivar status: The status of the port. Required. Known values are: "Revoked" and "Initiated". - :vartype status: str or ~azure.mgmt.security.v2020_01_01.models.Status - :ivar status_reason: A description of why the ``status`` has its value. Required. Known values - are: "Expired", "UserRequested", and "NewerRequestInitiated". - :vartype status_reason: str or ~azure.mgmt.security.v2020_01_01.models.StatusReason - :ivar mapped_port: The port which is mapped to this port's ``number`` in the Azure Firewall, if - applicable. - :vartype mapped_port: int - """ - - _validation = { - "number": {"required": True, "maximum": 65535, "minimum": 0}, - "end_time_utc": {"required": True}, - "status": {"required": True}, - "status_reason": {"required": True}, - } - - _attribute_map = { - "number": {"key": "number", "type": "int"}, - "allowed_source_address_prefix": {"key": "allowedSourceAddressPrefix", "type": "str"}, - "allowed_source_address_prefixes": {"key": "allowedSourceAddressPrefixes", "type": "[str]"}, - "end_time_utc": {"key": "endTimeUtc", "type": "iso-8601"}, - "status": {"key": "status", "type": "str"}, - "status_reason": {"key": "statusReason", "type": "str"}, - "mapped_port": {"key": "mappedPort", "type": "int"}, - } - - def __init__( - self, - *, - number: int, - end_time_utc: datetime.datetime, - status: Union[str, "_models.Status"], - status_reason: Union[str, "_models.StatusReason"], - allowed_source_address_prefix: Optional[str] = None, - allowed_source_address_prefixes: Optional[List[str]] = None, - mapped_port: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword number: Required. - :paramtype number: int - :keyword allowed_source_address_prefix: Mutually exclusive with the - "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for example - "192.168.0.3" or "192.168.0.0/16". - :paramtype allowed_source_address_prefix: str - :keyword allowed_source_address_prefixes: Mutually exclusive with the - "allowedSourceAddressPrefix" parameter. - :paramtype allowed_source_address_prefixes: list[str] - :keyword end_time_utc: The date & time at which the request ends in UTC. Required. - :paramtype end_time_utc: ~datetime.datetime - :keyword status: The status of the port. Required. Known values are: "Revoked" and "Initiated". - :paramtype status: str or ~azure.mgmt.security.v2020_01_01.models.Status - :keyword status_reason: A description of why the ``status`` has its value. Required. Known - values are: "Expired", "UserRequested", and "NewerRequestInitiated". - :paramtype status_reason: str or ~azure.mgmt.security.v2020_01_01.models.StatusReason - :keyword mapped_port: The port which is mapped to this port's ``number`` in the Azure Firewall, - if applicable. - :paramtype mapped_port: int - """ - super().__init__(**kwargs) - self.number = number - self.allowed_source_address_prefix = allowed_source_address_prefix - self.allowed_source_address_prefixes = allowed_source_address_prefixes - self.end_time_utc = end_time_utc - self.status = status - self.status_reason = status_reason - self.mapped_port = mapped_port - - -class JitNetworkAccessRequestVirtualMachine(_serialization.Model): - """JitNetworkAccessRequestVirtualMachine. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID of the virtual machine that is linked to this policy. Required. - :vartype id: str - :ivar ports: The ports that were opened for the virtual machine. Required. - :vartype ports: list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequestPort] - """ - - _validation = { - "id": {"required": True}, - "ports": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "ports": {"key": "ports", "type": "[JitNetworkAccessRequestPort]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - ports: List["_models.JitNetworkAccessRequestPort"], - **kwargs: Any - ) -> None: - """ - :keyword id: Resource ID of the virtual machine that is linked to this policy. Required. - :paramtype id: str - :keyword ports: The ports that were opened for the virtual machine. Required. - :paramtype ports: list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequestPort] - """ - super().__init__(**kwargs) - self.id = id - self.ports = ports - - -class OnPremiseResourceDetails(ResourceDetails): - """Details of the On Premise resource that was assessed. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - OnPremiseSqlResourceDetails - - All required parameters must be populated in order to send to server. - - :ivar source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2020_01_01.models.Source - :ivar workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :vartype workspace_id: str - :ivar vmuuid: The unique Id of the machine. Required. - :vartype vmuuid: str - :ivar source_computer_id: The oms agent Id installed on the machine. Required. - :vartype source_computer_id: str - :ivar machine_name: The name of the machine. Required. - :vartype machine_name: str - """ - - _validation = { - "source": {"required": True}, - "workspace_id": {"required": True}, - "vmuuid": {"required": True}, - "source_computer_id": {"required": True}, - "machine_name": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "vmuuid": {"key": "vmuuid", "type": "str"}, - "source_computer_id": {"key": "sourceComputerId", "type": "str"}, - "machine_name": {"key": "machineName", "type": "str"}, - } - - _subtype_map = {"source": {"OnPremiseSql": "OnPremiseSqlResourceDetails"}} - - def __init__( - self, *, workspace_id: str, vmuuid: str, source_computer_id: str, machine_name: str, **kwargs: Any - ) -> None: - """ - :keyword workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :paramtype workspace_id: str - :keyword vmuuid: The unique Id of the machine. Required. - :paramtype vmuuid: str - :keyword source_computer_id: The oms agent Id installed on the machine. Required. - :paramtype source_computer_id: str - :keyword machine_name: The name of the machine. Required. - :paramtype machine_name: str - """ - super().__init__(**kwargs) - self.source: str = "OnPremise" - self.workspace_id = workspace_id - self.vmuuid = vmuuid - self.source_computer_id = source_computer_id - self.machine_name = machine_name - - -class OnPremiseSqlResourceDetails(OnPremiseResourceDetails): - """Details of the On Premise Sql resource that was assessed. - - All required parameters must be populated in order to send to server. - - :ivar source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2020_01_01.models.Source - :ivar workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :vartype workspace_id: str - :ivar vmuuid: The unique Id of the machine. Required. - :vartype vmuuid: str - :ivar source_computer_id: The oms agent Id installed on the machine. Required. - :vartype source_computer_id: str - :ivar machine_name: The name of the machine. Required. - :vartype machine_name: str - :ivar server_name: The Sql server name installed on the machine. Required. - :vartype server_name: str - :ivar database_name: The Sql database name installed on the machine. Required. - :vartype database_name: str - """ - - _validation = { - "source": {"required": True}, - "workspace_id": {"required": True}, - "vmuuid": {"required": True}, - "source_computer_id": {"required": True}, - "machine_name": {"required": True}, - "server_name": {"required": True}, - "database_name": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "vmuuid": {"key": "vmuuid", "type": "str"}, - "source_computer_id": {"key": "sourceComputerId", "type": "str"}, - "machine_name": {"key": "machineName", "type": "str"}, - "server_name": {"key": "serverName", "type": "str"}, - "database_name": {"key": "databaseName", "type": "str"}, - } - - def __init__( - self, - *, - workspace_id: str, - vmuuid: str, - source_computer_id: str, - machine_name: str, - server_name: str, - database_name: str, - **kwargs: Any - ) -> None: - """ - :keyword workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :paramtype workspace_id: str - :keyword vmuuid: The unique Id of the machine. Required. - :paramtype vmuuid: str - :keyword source_computer_id: The oms agent Id installed on the machine. Required. - :paramtype source_computer_id: str - :keyword machine_name: The name of the machine. Required. - :paramtype machine_name: str - :keyword server_name: The Sql server name installed on the machine. Required. - :paramtype server_name: str - :keyword database_name: The Sql database name installed on the machine. Required. - :paramtype database_name: str - """ - super().__init__( - workspace_id=workspace_id, - vmuuid=vmuuid, - source_computer_id=source_computer_id, - machine_name=machine_name, - **kwargs - ) - self.source: str = "OnPremiseSql" - self.server_name = server_name - self.database_name = database_name - - -class PathRecommendation(_serialization.Model): - """Represents a path that is recommended to be allowed and its properties. - - :ivar path: The full path of the file, or an identifier of the application. - :vartype path: str - :ivar action: The recommendation action of the machine or rule. Known values are: - "Recommended", "Add", and "Remove". - :vartype action: str or ~azure.mgmt.security.v2020_01_01.models.RecommendationAction - :ivar type: The type of the rule to be allowed. Known values are: "File", "FileHash", - "PublisherSignature", "ProductSignature", "BinarySignature", and "VersionAndAboveSignature". - :vartype type: str or ~azure.mgmt.security.v2020_01_01.models.RecommendationType - :ivar publisher_info: Represents the publisher information of a process/rule. - :vartype publisher_info: ~azure.mgmt.security.v2020_01_01.models.PublisherInfo - :ivar common: Whether the application is commonly run on the machine. - :vartype common: bool - :ivar user_sids: - :vartype user_sids: list[str] - :ivar usernames: - :vartype usernames: list[~azure.mgmt.security.v2020_01_01.models.UserRecommendation] - :ivar file_type: The type of the file (for Linux files - Executable is used). Known values are: - "Exe", "Dll", "Msi", "Script", "Executable", and "Unknown". - :vartype file_type: str or ~azure.mgmt.security.v2020_01_01.models.FileType - :ivar configuration_status: The configuration status of the machines group or machine or rule. - Known values are: "Configured", "NotConfigured", "InProgress", "Failed", and "NoStatus". - :vartype configuration_status: str or - ~azure.mgmt.security.v2020_01_01.models.ConfigurationStatus - """ - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "action": {"key": "action", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "publisher_info": {"key": "publisherInfo", "type": "PublisherInfo"}, - "common": {"key": "common", "type": "bool"}, - "user_sids": {"key": "userSids", "type": "[str]"}, - "usernames": {"key": "usernames", "type": "[UserRecommendation]"}, - "file_type": {"key": "fileType", "type": "str"}, - "configuration_status": {"key": "configurationStatus", "type": "str"}, - } - - def __init__( - self, - *, - path: Optional[str] = None, - action: Optional[Union[str, "_models.RecommendationAction"]] = None, - type: Optional[Union[str, "_models.RecommendationType"]] = None, - publisher_info: Optional["_models.PublisherInfo"] = None, - common: Optional[bool] = None, - user_sids: Optional[List[str]] = None, - usernames: Optional[List["_models.UserRecommendation"]] = None, - file_type: Optional[Union[str, "_models.FileType"]] = None, - configuration_status: Optional[Union[str, "_models.ConfigurationStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword path: The full path of the file, or an identifier of the application. - :paramtype path: str - :keyword action: The recommendation action of the machine or rule. Known values are: - "Recommended", "Add", and "Remove". - :paramtype action: str or ~azure.mgmt.security.v2020_01_01.models.RecommendationAction - :keyword type: The type of the rule to be allowed. Known values are: "File", "FileHash", - "PublisherSignature", "ProductSignature", "BinarySignature", and "VersionAndAboveSignature". - :paramtype type: str or ~azure.mgmt.security.v2020_01_01.models.RecommendationType - :keyword publisher_info: Represents the publisher information of a process/rule. - :paramtype publisher_info: ~azure.mgmt.security.v2020_01_01.models.PublisherInfo - :keyword common: Whether the application is commonly run on the machine. - :paramtype common: bool - :keyword user_sids: - :paramtype user_sids: list[str] - :keyword usernames: - :paramtype usernames: list[~azure.mgmt.security.v2020_01_01.models.UserRecommendation] - :keyword file_type: The type of the file (for Linux files - Executable is used). Known values - are: "Exe", "Dll", "Msi", "Script", "Executable", and "Unknown". - :paramtype file_type: str or ~azure.mgmt.security.v2020_01_01.models.FileType - :keyword configuration_status: The configuration status of the machines group or machine or - rule. Known values are: "Configured", "NotConfigured", "InProgress", "Failed", and "NoStatus". - :paramtype configuration_status: str or - ~azure.mgmt.security.v2020_01_01.models.ConfigurationStatus - """ - super().__init__(**kwargs) - self.path = path - self.action = action - self.type = type - self.publisher_info = publisher_info - self.common = common - self.user_sids = user_sids - self.usernames = usernames - self.file_type = file_type - self.configuration_status = configuration_status - - -class ProtectionMode(_serialization.Model): - """The protection mode of the collection/file types. Exe/Msi/Script are used for Windows, - Executable is used for Linux. - - :ivar exe: The application control policy enforcement/protection mode of the machine group. - Known values are: "Audit", "Enforce", and "None". - :vartype exe: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - :ivar msi: The application control policy enforcement/protection mode of the machine group. - Known values are: "Audit", "Enforce", and "None". - :vartype msi: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - :ivar script: The application control policy enforcement/protection mode of the machine group. - Known values are: "Audit", "Enforce", and "None". - :vartype script: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - :ivar executable: The application control policy enforcement/protection mode of the machine - group. Known values are: "Audit", "Enforce", and "None". - :vartype executable: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - """ - - _attribute_map = { - "exe": {"key": "exe", "type": "str"}, - "msi": {"key": "msi", "type": "str"}, - "script": {"key": "script", "type": "str"}, - "executable": {"key": "executable", "type": "str"}, - } - - def __init__( - self, - *, - exe: Optional[Union[str, "_models.EnforcementMode"]] = None, - msi: Optional[Union[str, "_models.EnforcementMode"]] = None, - script: Optional[Union[str, "_models.EnforcementMode"]] = None, - executable: Optional[Union[str, "_models.EnforcementMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword exe: The application control policy enforcement/protection mode of the machine group. - Known values are: "Audit", "Enforce", and "None". - :paramtype exe: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - :keyword msi: The application control policy enforcement/protection mode of the machine group. - Known values are: "Audit", "Enforce", and "None". - :paramtype msi: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - :keyword script: The application control policy enforcement/protection mode of the machine - group. Known values are: "Audit", "Enforce", and "None". - :paramtype script: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - :keyword executable: The application control policy enforcement/protection mode of the machine - group. Known values are: "Audit", "Enforce", and "None". - :paramtype executable: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementMode - """ - super().__init__(**kwargs) - self.exe = exe - self.msi = msi - self.script = script - self.executable = executable - - -class PublisherInfo(_serialization.Model): - """Represents the publisher information of a process/rule. - - :ivar publisher_name: The Subject field of the x.509 certificate used to sign the code, using - the following fields - O = Organization, L = Locality, S = State or Province, and C = Country. - :vartype publisher_name: str - :ivar product_name: The product name taken from the file's version resource. - :vartype product_name: str - :ivar binary_name: The "OriginalName" field taken from the file's version resource. - :vartype binary_name: str - :ivar version: The binary file version taken from the file's version resource. - :vartype version: str - """ - - _attribute_map = { - "publisher_name": {"key": "publisherName", "type": "str"}, - "product_name": {"key": "productName", "type": "str"}, - "binary_name": {"key": "binaryName", "type": "str"}, - "version": {"key": "version", "type": "str"}, - } - - def __init__( - self, - *, - publisher_name: Optional[str] = None, - product_name: Optional[str] = None, - binary_name: Optional[str] = None, - version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher_name: The Subject field of the x.509 certificate used to sign the code, - using the following fields - O = Organization, L = Locality, S = State or Province, and C = - Country. - :paramtype publisher_name: str - :keyword product_name: The product name taken from the file's version resource. - :paramtype product_name: str - :keyword binary_name: The "OriginalName" field taken from the file's version resource. - :paramtype binary_name: str - :keyword version: The binary file version taken from the file's version resource. - :paramtype version: str - """ - super().__init__(**kwargs) - self.publisher_name = publisher_name - self.product_name = product_name - self.binary_name = binary_name - self.version = version - - -class Rule(_serialization.Model): - """Describes remote addresses that is recommended to communicate with the Azure resource on some - (Protocol, Port, Direction). All other remote addresses are recommended to be blocked. - - :ivar name: The name of the rule. - :vartype name: str - :ivar direction: The rule's direction. Known values are: "Inbound" and "Outbound". - :vartype direction: str or ~azure.mgmt.security.v2020_01_01.models.Direction - :ivar destination_port: The rule's destination port. - :vartype destination_port: int - :ivar protocols: The rule's transport protocols. - :vartype protocols: list[str or ~azure.mgmt.security.v2020_01_01.models.TransportProtocol] - :ivar ip_addresses: The remote IP addresses that should be able to communicate with the Azure - resource on the rule's destination port and protocol. - :vartype ip_addresses: list[str] - """ - - _validation = { - "destination_port": {"maximum": 65535, "minimum": 0}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "direction": {"key": "direction", "type": "str"}, - "destination_port": {"key": "destinationPort", "type": "int"}, - "protocols": {"key": "protocols", "type": "[str]"}, - "ip_addresses": {"key": "ipAddresses", "type": "[str]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - direction: Optional[Union[str, "_models.Direction"]] = None, - destination_port: Optional[int] = None, - protocols: Optional[List[Union[str, "_models.TransportProtocol"]]] = None, - ip_addresses: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the rule. - :paramtype name: str - :keyword direction: The rule's direction. Known values are: "Inbound" and "Outbound". - :paramtype direction: str or ~azure.mgmt.security.v2020_01_01.models.Direction - :keyword destination_port: The rule's destination port. - :paramtype destination_port: int - :keyword protocols: The rule's transport protocols. - :paramtype protocols: list[str or ~azure.mgmt.security.v2020_01_01.models.TransportProtocol] - :keyword ip_addresses: The remote IP addresses that should be able to communicate with the - Azure resource on the rule's destination port and protocol. - :paramtype ip_addresses: list[str] - """ - super().__init__(**kwargs) - self.name = name - self.direction = direction - self.destination_port = destination_port - self.protocols = protocols - self.ip_addresses = ip_addresses - - -class SecureScoreControlDefinitionItem(Resource): - """Information about the security control. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: User friendly display name of the control. - :vartype display_name: str - :ivar description: User friendly description of the control. - :vartype description: str - :ivar max_score: Maximum control score (0..10). - :vartype max_score: int - :ivar source: Source object from which the control was created. - :vartype source: ~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDefinitionSource - :ivar assessment_definitions: Array of assessments metadata IDs that are included in this - security control. - :vartype assessment_definitions: - list[~azure.mgmt.security.v2020_01_01.models.AzureResourceLink] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"readonly": True}, - "description": {"readonly": True, "max_length": 256}, - "max_score": {"readonly": True, "maximum": 10, "minimum": 0}, - "source": {"readonly": True}, - "assessment_definitions": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "max_score": {"key": "properties.maxScore", "type": "int"}, - "source": {"key": "properties.source", "type": "SecureScoreControlDefinitionSource"}, - "assessment_definitions": {"key": "properties.assessmentDefinitions", "type": "[AzureResourceLink]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.display_name = None - self.description = None - self.max_score = None - self.source = None - self.assessment_definitions = None - - -class SecureScoreControlDefinitionList(_serialization.Model): - """List of security controls definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of security controls definition in this page. - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDefinitionItem] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecureScoreControlDefinitionItem]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecureScoreControlDefinitionSource(_serialization.Model): - """The type of the security control (For example, BuiltIn). - - :ivar source_type: The type of security control (for example, BuiltIn). Known values are: - "BuiltIn" and "Custom". - :vartype source_type: str or ~azure.mgmt.security.v2020_01_01.models.ControlType - """ - - _attribute_map = { - "source_type": {"key": "sourceType", "type": "str"}, - } - - def __init__(self, *, source_type: Optional[Union[str, "_models.ControlType"]] = None, **kwargs: Any) -> None: - """ - :keyword source_type: The type of security control (for example, BuiltIn). Known values are: - "BuiltIn" and "Custom". - :paramtype source_type: str or ~azure.mgmt.security.v2020_01_01.models.ControlType - """ - super().__init__(**kwargs) - self.source_type = source_type - - -class SecureScoreControlDetails(Resource): # pylint: disable=too-many-instance-attributes - """Details of the security control, its score, and the health status of the relevant resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: User friendly display name of the control. - :vartype display_name: str - :ivar healthy_resource_count: Number of healthy resources in the control. - :vartype healthy_resource_count: int - :ivar unhealthy_resource_count: Number of unhealthy resources in the control. - :vartype unhealthy_resource_count: int - :ivar not_applicable_resource_count: Number of not applicable resources in the control. - :vartype not_applicable_resource_count: int - :ivar weight: The relative weight for this specific control in each of your subscriptions. Used - when calculating an aggregated score for this control across all of your subscriptions. - :vartype weight: int - :ivar definition: Information about the security control. - :vartype definition: ~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDefinitionItem - :ivar max: Maximum score available. - :vartype max: int - :ivar current: Current score. - :vartype current: float - :ivar percentage: Ratio of the current score divided by the maximum. Rounded to 4 digits after - the decimal point. - :vartype percentage: float - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"readonly": True}, - "healthy_resource_count": {"readonly": True}, - "unhealthy_resource_count": {"readonly": True}, - "not_applicable_resource_count": {"readonly": True}, - "weight": {"readonly": True, "minimum": 0}, - "max": {"readonly": True, "minimum": 0}, - "current": {"readonly": True, "minimum": 0}, - "percentage": {"readonly": True, "maximum": 1, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "healthy_resource_count": {"key": "properties.healthyResourceCount", "type": "int"}, - "unhealthy_resource_count": {"key": "properties.unhealthyResourceCount", "type": "int"}, - "not_applicable_resource_count": {"key": "properties.notApplicableResourceCount", "type": "int"}, - "weight": {"key": "properties.weight", "type": "int"}, - "definition": {"key": "properties.definition", "type": "SecureScoreControlDefinitionItem"}, - "max": {"key": "properties.score.max", "type": "int"}, - "current": {"key": "properties.score.current", "type": "float"}, - "percentage": {"key": "properties.score.percentage", "type": "float"}, - } - - def __init__( - self, *, definition: Optional["_models.SecureScoreControlDefinitionItem"] = None, **kwargs: Any - ) -> None: - """ - :keyword definition: Information about the security control. - :paramtype definition: ~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDefinitionItem - """ - super().__init__(**kwargs) - self.display_name = None - self.healthy_resource_count = None - self.unhealthy_resource_count = None - self.not_applicable_resource_count = None - self.weight = None - self.definition = definition - self.max = None - self.current = None - self.percentage = None - - -class SecureScoreControlList(_serialization.Model): - """List of security controls. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of security controls in this page. - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDetails] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecureScoreControlDetails]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecureScoreControlScore(_serialization.Model): - """Calculation result data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar max: Maximum control score (0..10). - :vartype max: int - :ivar current: Actual score for the control = (achieved points / total points) * max score. if - total points is zeroed, the return number is 0.00. - :vartype current: float - :ivar percentage: Ratio of the current score divided by the maximum. Rounded to 4 digits after - the decimal point. - :vartype percentage: float - """ - - _validation = { - "max": {"readonly": True, "maximum": 10, "minimum": 0}, - "current": {"readonly": True, "maximum": 10, "minimum": 0}, - "percentage": {"readonly": True, "maximum": 1, "minimum": 0}, - } - - _attribute_map = { - "max": {"key": "max", "type": "int"}, - "current": {"key": "current", "type": "float"}, - "percentage": {"key": "percentage", "type": "float"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.max = None - self.current = None - self.percentage = None - - -class SecureScoreItem(Resource): - """Secure score item data model. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: The initiative’s name. - :vartype display_name: str - :ivar weight: The relative weight for each subscription. Used when calculating an aggregated - secure score for multiple subscriptions. - :vartype weight: int - :ivar max: Maximum score available. - :vartype max: int - :ivar current: Current score. - :vartype current: float - :ivar percentage: Ratio of the current score divided by the maximum. Rounded to 4 digits after - the decimal point. - :vartype percentage: float - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"readonly": True}, - "weight": {"readonly": True, "minimum": 0}, - "max": {"readonly": True, "minimum": 0}, - "current": {"readonly": True, "minimum": 0}, - "percentage": {"readonly": True, "maximum": 1, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "weight": {"key": "properties.weight", "type": "int"}, - "max": {"key": "properties.score.max", "type": "int"}, - "current": {"key": "properties.score.current", "type": "float"}, - "percentage": {"key": "properties.score.percentage", "type": "float"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.display_name = None - self.weight = None - self.max = None - self.current = None - self.percentage = None - - -class SecureScoresList(_serialization.Model): - """List of secure scores. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of secure scores in this page. - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.SecureScoreItem] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecureScoreItem]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityAssessment(Resource): - """Security assessment on a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar resource_details: Details of the resource that was assessed. - :vartype resource_details: ~azure.mgmt.security.v2020_01_01.models.ResourceDetails - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :ivar status: The result of the assessment. - :vartype status: ~azure.mgmt.security.v2020_01_01.models.AssessmentStatus - :ivar additional_data: Additional data regarding the assessment. - :vartype additional_data: dict[str, str] - :ivar links: Links relevant to the assessment. - :vartype links: ~azure.mgmt.security.v2020_01_01.models.AssessmentLinks - :ivar metadata: Describes properties of an assessment metadata. - :vartype metadata: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadataProperties - :ivar partners_data: Data regarding 3rd party partner integration. - :vartype partners_data: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentPartnerData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"readonly": True}, - "links": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "status": {"key": "properties.status", "type": "AssessmentStatus"}, - "additional_data": {"key": "properties.additionalData", "type": "{str}"}, - "links": {"key": "properties.links", "type": "AssessmentLinks"}, - "metadata": {"key": "properties.metadata", "type": "SecurityAssessmentMetadataProperties"}, - "partners_data": {"key": "properties.partnersData", "type": "SecurityAssessmentPartnerData"}, - } - - def __init__( - self, - *, - resource_details: Optional["_models.ResourceDetails"] = None, - status: Optional["_models.AssessmentStatus"] = None, - additional_data: Optional[Dict[str, str]] = None, - metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, - partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_details: Details of the resource that was assessed. - :paramtype resource_details: ~azure.mgmt.security.v2020_01_01.models.ResourceDetails - :keyword status: The result of the assessment. - :paramtype status: ~azure.mgmt.security.v2020_01_01.models.AssessmentStatus - :keyword additional_data: Additional data regarding the assessment. - :paramtype additional_data: dict[str, str] - :keyword metadata: Describes properties of an assessment metadata. - :paramtype metadata: - ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadataProperties - :keyword partners_data: Data regarding 3rd party partner integration. - :paramtype partners_data: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentPartnerData - """ - super().__init__(**kwargs) - self.resource_details = resource_details - self.display_name = None - self.status = status - self.additional_data = additional_data - self.links = None - self.metadata = metadata - self.partners_data = partners_data - - -class SecurityAssessmentList(_serialization.Model): - """Page of a security assessments list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of security assessments in this page. - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.SecurityAssessment] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityAssessment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityAssessmentMetadata(Resource): # pylint: disable=too-many-instance-attributes - """Security assessment metadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :ivar policy_definition_id: Azure resource ID of the policy definition that turns this - assessment calculation on. - :vartype policy_definition_id: str - :ivar description: Human readable description of the assessment. - :vartype description: str - :ivar remediation_description: Human readable description of what you should do to mitigate - this security issue. - :vartype remediation_description: str - :ivar categories: - :vartype categories: list[str or ~azure.mgmt.security.v2020_01_01.models.Categories] - :ivar severity: The severity level of the assessment. Known values are: "Low", "Medium", and - "High". - :vartype severity: str or ~azure.mgmt.security.v2020_01_01.models.Severity - :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and - "High". - :vartype user_impact: str or ~azure.mgmt.security.v2020_01_01.models.UserImpact - :ivar implementation_effort: The implementation effort required to remediate this assessment. - Known values are: "Low", "Moderate", and "High". - :vartype implementation_effort: str or - ~azure.mgmt.security.v2020_01_01.models.ImplementationEffort - :ivar threats: - :vartype threats: list[str or ~azure.mgmt.security.v2020_01_01.models.Threats] - :ivar preview: True if this assessment is in preview release status. - :vartype preview: bool - :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", - "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :vartype assessment_type: str or ~azure.mgmt.security.v2020_01_01.models.AssessmentType - :ivar partner_data: Describes the partner that created the assessment. - :vartype partner_data: - ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadataPartnerData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "policy_definition_id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, - "categories": {"key": "properties.categories", "type": "[str]"}, - "severity": {"key": "properties.severity", "type": "str"}, - "user_impact": {"key": "properties.userImpact", "type": "str"}, - "implementation_effort": {"key": "properties.implementationEffort", "type": "str"}, - "threats": {"key": "properties.threats", "type": "[str]"}, - "preview": {"key": "properties.preview", "type": "bool"}, - "assessment_type": {"key": "properties.assessmentType", "type": "str"}, - "partner_data": {"key": "properties.partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - remediation_description: Optional[str] = None, - categories: Optional[List[Union[str, "_models.Categories"]]] = None, - severity: Optional[Union[str, "_models.Severity"]] = None, - user_impact: Optional[Union[str, "_models.UserImpact"]] = None, - implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, - threats: Optional[List[Union[str, "_models.Threats"]]] = None, - preview: Optional[bool] = None, - assessment_type: Optional[Union[str, "_models.AssessmentType"]] = None, - partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: User friendly display name of the assessment. - :paramtype display_name: str - :keyword description: Human readable description of the assessment. - :paramtype description: str - :keyword remediation_description: Human readable description of what you should do to mitigate - this security issue. - :paramtype remediation_description: str - :keyword categories: - :paramtype categories: list[str or ~azure.mgmt.security.v2020_01_01.models.Categories] - :keyword severity: The severity level of the assessment. Known values are: "Low", "Medium", and - "High". - :paramtype severity: str or ~azure.mgmt.security.v2020_01_01.models.Severity - :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", - and "High". - :paramtype user_impact: str or ~azure.mgmt.security.v2020_01_01.models.UserImpact - :keyword implementation_effort: The implementation effort required to remediate this - assessment. Known values are: "Low", "Moderate", and "High". - :paramtype implementation_effort: str or - ~azure.mgmt.security.v2020_01_01.models.ImplementationEffort - :keyword threats: - :paramtype threats: list[str or ~azure.mgmt.security.v2020_01_01.models.Threats] - :keyword preview: True if this assessment is in preview release status. - :paramtype preview: bool - :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", - "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :paramtype assessment_type: str or ~azure.mgmt.security.v2020_01_01.models.AssessmentType - :keyword partner_data: Describes the partner that created the assessment. - :paramtype partner_data: - ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadataPartnerData - """ - super().__init__(**kwargs) - self.display_name = display_name - self.policy_definition_id = None - self.description = description - self.remediation_description = remediation_description - self.categories = categories - self.severity = severity - self.user_impact = user_impact - self.implementation_effort = implementation_effort - self.threats = threats - self.preview = preview - self.assessment_type = assessment_type - self.partner_data = partner_data - - -class SecurityAssessmentMetadataList(_serialization.Model): - """List of security assessment metadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityAssessmentMetadata]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityAssessmentMetadataPartnerData(_serialization.Model): - """Describes the partner that created the assessment. - - All required parameters must be populated in order to send to server. - - :ivar partner_name: Name of the company of the partner. Required. - :vartype partner_name: str - :ivar product_name: Name of the product of the partner that created the assessment. - :vartype product_name: str - :ivar secret: Secret to authenticate the partner and verify it created the assessment - write - only. Required. - :vartype secret: str - """ - - _validation = { - "partner_name": {"required": True}, - "secret": {"required": True}, - } - - _attribute_map = { - "partner_name": {"key": "partnerName", "type": "str"}, - "product_name": {"key": "productName", "type": "str"}, - "secret": {"key": "secret", "type": "str"}, - } - - def __init__(self, *, partner_name: str, secret: str, product_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword partner_name: Name of the company of the partner. Required. - :paramtype partner_name: str - :keyword product_name: Name of the product of the partner that created the assessment. - :paramtype product_name: str - :keyword secret: Secret to authenticate the partner and verify it created the assessment - - write only. Required. - :paramtype secret: str - """ - super().__init__(**kwargs) - self.partner_name = partner_name - self.product_name = product_name - self.secret = secret - - -class SecurityAssessmentMetadataProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Describes properties of an assessment metadata. - - 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 display_name: User friendly display name of the assessment. Required. - :vartype display_name: str - :ivar policy_definition_id: Azure resource ID of the policy definition that turns this - assessment calculation on. - :vartype policy_definition_id: str - :ivar description: Human readable description of the assessment. - :vartype description: str - :ivar remediation_description: Human readable description of what you should do to mitigate - this security issue. - :vartype remediation_description: str - :ivar categories: - :vartype categories: list[str or ~azure.mgmt.security.v2020_01_01.models.Categories] - :ivar severity: The severity level of the assessment. Required. Known values are: "Low", - "Medium", and "High". - :vartype severity: str or ~azure.mgmt.security.v2020_01_01.models.Severity - :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and - "High". - :vartype user_impact: str or ~azure.mgmt.security.v2020_01_01.models.UserImpact - :ivar implementation_effort: The implementation effort required to remediate this assessment. - Known values are: "Low", "Moderate", and "High". - :vartype implementation_effort: str or - ~azure.mgmt.security.v2020_01_01.models.ImplementationEffort - :ivar threats: - :vartype threats: list[str or ~azure.mgmt.security.v2020_01_01.models.Threats] - :ivar preview: True if this assessment is in preview release status. - :vartype preview: bool - :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Required. Known values are: - "BuiltIn", "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :vartype assessment_type: str or ~azure.mgmt.security.v2020_01_01.models.AssessmentType - :ivar partner_data: Describes the partner that created the assessment. - :vartype partner_data: - ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadataPartnerData - """ - - _validation = { - "display_name": {"required": True}, - "policy_definition_id": {"readonly": True}, - "severity": {"required": True}, - "assessment_type": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "remediation_description": {"key": "remediationDescription", "type": "str"}, - "categories": {"key": "categories", "type": "[str]"}, - "severity": {"key": "severity", "type": "str"}, - "user_impact": {"key": "userImpact", "type": "str"}, - "implementation_effort": {"key": "implementationEffort", "type": "str"}, - "threats": {"key": "threats", "type": "[str]"}, - "preview": {"key": "preview", "type": "bool"}, - "assessment_type": {"key": "assessmentType", "type": "str"}, - "partner_data": {"key": "partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, - } - - def __init__( - self, - *, - display_name: str, - severity: Union[str, "_models.Severity"], - assessment_type: Union[str, "_models.AssessmentType"], - description: Optional[str] = None, - remediation_description: Optional[str] = None, - categories: Optional[List[Union[str, "_models.Categories"]]] = None, - user_impact: Optional[Union[str, "_models.UserImpact"]] = None, - implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, - threats: Optional[List[Union[str, "_models.Threats"]]] = None, - preview: Optional[bool] = None, - partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: User friendly display name of the assessment. Required. - :paramtype display_name: str - :keyword description: Human readable description of the assessment. - :paramtype description: str - :keyword remediation_description: Human readable description of what you should do to mitigate - this security issue. - :paramtype remediation_description: str - :keyword categories: - :paramtype categories: list[str or ~azure.mgmt.security.v2020_01_01.models.Categories] - :keyword severity: The severity level of the assessment. Required. Known values are: "Low", - "Medium", and "High". - :paramtype severity: str or ~azure.mgmt.security.v2020_01_01.models.Severity - :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", - and "High". - :paramtype user_impact: str or ~azure.mgmt.security.v2020_01_01.models.UserImpact - :keyword implementation_effort: The implementation effort required to remediate this - assessment. Known values are: "Low", "Moderate", and "High". - :paramtype implementation_effort: str or - ~azure.mgmt.security.v2020_01_01.models.ImplementationEffort - :keyword threats: - :paramtype threats: list[str or ~azure.mgmt.security.v2020_01_01.models.Threats] - :keyword preview: True if this assessment is in preview release status. - :paramtype preview: bool - :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Required. Known values are: - "BuiltIn", "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :paramtype assessment_type: str or ~azure.mgmt.security.v2020_01_01.models.AssessmentType - :keyword partner_data: Describes the partner that created the assessment. - :paramtype partner_data: - ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadataPartnerData - """ - super().__init__(**kwargs) - self.display_name = display_name - self.policy_definition_id = None - self.description = description - self.remediation_description = remediation_description - self.categories = categories - self.severity = severity - self.user_impact = user_impact - self.implementation_effort = implementation_effort - self.threats = threats - self.preview = preview - self.assessment_type = assessment_type - self.partner_data = partner_data - - -class SecurityAssessmentPartnerData(_serialization.Model): - """Data regarding 3rd party partner integration. - - All required parameters must be populated in order to send to server. - - :ivar partner_name: Name of the company of the partner. Required. - :vartype partner_name: str - :ivar secret: secret to authenticate the partner - write only. Required. - :vartype secret: str - """ - - _validation = { - "partner_name": {"required": True}, - "secret": {"required": True}, - } - - _attribute_map = { - "partner_name": {"key": "partnerName", "type": "str"}, - "secret": {"key": "secret", "type": "str"}, - } - - def __init__(self, *, partner_name: str, secret: str, **kwargs: Any) -> None: - """ - :keyword partner_name: Name of the company of the partner. Required. - :paramtype partner_name: str - :keyword secret: secret to authenticate the partner - write only. Required. - :paramtype secret: str - """ - super().__init__(**kwargs) - self.partner_name = partner_name - self.secret = secret - - -class SecuritySolution(Resource, Location): - """SecuritySolution. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar security_family: The security family of the security solution. Known values are: "Waf", - "Ngfw", "SaasWaf", and "Va". - :vartype security_family: str or ~azure.mgmt.security.v2020_01_01.models.SecurityFamily - :ivar provisioning_state: The security family provisioning State. Known values are: - "Succeeded", "Failed", and "Updating". - :vartype provisioning_state: str or ~azure.mgmt.security.v2020_01_01.models.ProvisioningState - :ivar template: The security solutions' template. - :vartype template: str - :ivar protection_status: The security solutions' status. - :vartype protection_status: str - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "security_family": {"key": "properties.securityFamily", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "template": {"key": "properties.template", "type": "str"}, - "protection_status": {"key": "properties.protectionStatus", "type": "str"}, - } - - def __init__( - self, - *, - security_family: Optional[Union[str, "_models.SecurityFamily"]] = None, - provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, - template: Optional[str] = None, - protection_status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword security_family: The security family of the security solution. Known values are: - "Waf", "Ngfw", "SaasWaf", and "Va". - :paramtype security_family: str or ~azure.mgmt.security.v2020_01_01.models.SecurityFamily - :keyword provisioning_state: The security family provisioning State. Known values are: - "Succeeded", "Failed", and "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.security.v2020_01_01.models.ProvisioningState - :keyword template: The security solutions' template. - :paramtype template: str - :keyword protection_status: The security solutions' status. - :paramtype protection_status: str - """ - super().__init__(**kwargs) - self.location = None - self.security_family = security_family - self.provisioning_state = provisioning_state - self.template = template - self.protection_status = protection_status - self.id = None - self.name = None - self.type = None - - -class SecuritySolutionList(_serialization.Model): - """SecuritySolutionList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.SecuritySolution] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecuritySolution]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.SecuritySolution"]] = None, **kwargs: Any) -> None: - """ - :keyword value: - :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.SecuritySolution] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class SecuritySolutionsReferenceData(Resource, Location): # pylint: disable=too-many-instance-attributes - """SecuritySolutionsReferenceData. - - 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 location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar security_family: The security family of the security solution. Required. Known values - are: "Waf", "Ngfw", "SaasWaf", and "Va". - :vartype security_family: str or ~azure.mgmt.security.v2020_01_01.models.SecurityFamily - :ivar alert_vendor_name: The security solutions' vendor name. Required. - :vartype alert_vendor_name: str - :ivar package_info_url: The security solutions' package info url. Required. - :vartype package_info_url: str - :ivar product_name: The security solutions' product name. Required. - :vartype product_name: str - :ivar publisher: The security solutions' publisher. Required. - :vartype publisher: str - :ivar publisher_display_name: The security solutions' publisher display name. Required. - :vartype publisher_display_name: str - :ivar template: The security solutions' template. Required. - :vartype template: str - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "security_family": {"required": True}, - "alert_vendor_name": {"required": True}, - "package_info_url": {"required": True}, - "product_name": {"required": True}, - "publisher": {"required": True}, - "publisher_display_name": {"required": True}, - "template": {"required": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "security_family": {"key": "properties.securityFamily", "type": "str"}, - "alert_vendor_name": {"key": "properties.alertVendorName", "type": "str"}, - "package_info_url": {"key": "properties.packageInfoUrl", "type": "str"}, - "product_name": {"key": "properties.productName", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "publisher_display_name": {"key": "properties.publisherDisplayName", "type": "str"}, - "template": {"key": "properties.template", "type": "str"}, - } - - def __init__( - self, - *, - security_family: Union[str, "_models.SecurityFamily"], - alert_vendor_name: str, - package_info_url: str, - product_name: str, - publisher: str, - publisher_display_name: str, - template: str, - **kwargs: Any - ) -> None: - """ - :keyword security_family: The security family of the security solution. Required. Known values - are: "Waf", "Ngfw", "SaasWaf", and "Va". - :paramtype security_family: str or ~azure.mgmt.security.v2020_01_01.models.SecurityFamily - :keyword alert_vendor_name: The security solutions' vendor name. Required. - :paramtype alert_vendor_name: str - :keyword package_info_url: The security solutions' package info url. Required. - :paramtype package_info_url: str - :keyword product_name: The security solutions' product name. Required. - :paramtype product_name: str - :keyword publisher: The security solutions' publisher. Required. - :paramtype publisher: str - :keyword publisher_display_name: The security solutions' publisher display name. Required. - :paramtype publisher_display_name: str - :keyword template: The security solutions' template. Required. - :paramtype template: str - """ - super().__init__(**kwargs) - self.location = None - self.security_family = security_family - self.alert_vendor_name = alert_vendor_name - self.package_info_url = package_info_url - self.product_name = product_name - self.publisher = publisher - self.publisher_display_name = publisher_display_name - self.template = template - self.id = None - self.name = None - self.type = None - - -class SecuritySolutionsReferenceDataList(_serialization.Model): - """SecuritySolutionsReferenceDataList. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceData] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[SecuritySolutionsReferenceData]"}, - } - - def __init__( - self, *, value: Optional[List["_models.SecuritySolutionsReferenceData"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: - :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceData] - """ - super().__init__(**kwargs) - self.value = value - - -class ServerVulnerabilityAssessment(Resource): - """Describes the server vulnerability assessment details on a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: The provisioningState of the vulnerability assessment capability on - the VM. Known values are: "Succeeded", "Failed", "Canceled", "Provisioning", and - "Deprovisioning". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessmentPropertiesProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provisioning_state = None - - -class ServerVulnerabilityAssessmentsList(_serialization.Model): - """List of server vulnerability assessments. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ServerVulnerabilityAssessment]"}, - } - - def __init__(self, *, value: Optional[List["_models.ServerVulnerabilityAssessment"]] = None, **kwargs: Any) -> None: - """ - :keyword value: - :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment] - """ - super().__init__(**kwargs) - self.value = value - - -class TopologyList(_serialization.Model): - """TopologyList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2020_01_01.models.TopologyResource] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[TopologyResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class TopologyResource(Resource, Location): - """TopologyResource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar calculated_date_time: The UTC time on which the topology was calculated. - :vartype calculated_date_time: ~datetime.datetime - :ivar topology_resources: Azure resources which are part of this topology resource. - :vartype topology_resources: - list[~azure.mgmt.security.v2020_01_01.models.TopologySingleResource] - """ - - _validation = { - "location": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "calculated_date_time": {"readonly": True}, - "topology_resources": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "calculated_date_time": {"key": "properties.calculatedDateTime", "type": "iso-8601"}, - "topology_resources": {"key": "properties.topologyResources", "type": "[TopologySingleResource]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location = None - self.calculated_date_time = None - self.topology_resources = None - self.id = None - self.name = None - self.type = None - - -class TopologySingleResource(_serialization.Model): - """TopologySingleResource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_id: Azure resource id. - :vartype resource_id: str - :ivar severity: The security severity of the resource. - :vartype severity: str - :ivar recommendations_exist: Indicates if the resource has security recommendations. - :vartype recommendations_exist: bool - :ivar network_zones: Indicates the resource connectivity level to the Internet (InternetFacing, - Internal ,etc.). - :vartype network_zones: str - :ivar topology_score: Score of the resource based on its security severity. - :vartype topology_score: int - :ivar location: The location of this resource. - :vartype location: str - :ivar parents: Azure resources connected to this resource which are in higher level in the - topology view. - :vartype parents: list[~azure.mgmt.security.v2020_01_01.models.TopologySingleResourceParent] - :ivar children: Azure resources connected to this resource which are in lower level in the - topology view. - :vartype children: list[~azure.mgmt.security.v2020_01_01.models.TopologySingleResourceChild] - """ - - _validation = { - "resource_id": {"readonly": True}, - "severity": {"readonly": True}, - "recommendations_exist": {"readonly": True}, - "network_zones": {"readonly": True}, - "topology_score": {"readonly": True}, - "location": {"readonly": True}, - "parents": {"readonly": True}, - "children": {"readonly": True}, - } - - _attribute_map = { - "resource_id": {"key": "resourceId", "type": "str"}, - "severity": {"key": "severity", "type": "str"}, - "recommendations_exist": {"key": "recommendationsExist", "type": "bool"}, - "network_zones": {"key": "networkZones", "type": "str"}, - "topology_score": {"key": "topologyScore", "type": "int"}, - "location": {"key": "location", "type": "str"}, - "parents": {"key": "parents", "type": "[TopologySingleResourceParent]"}, - "children": {"key": "children", "type": "[TopologySingleResourceChild]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_id = None - self.severity = None - self.recommendations_exist = None - self.network_zones = None - self.topology_score = None - self.location = None - self.parents = None - self.children = None - - -class TopologySingleResourceChild(_serialization.Model): - """TopologySingleResourceChild. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_id: Azure resource id which serves as child resource in topology view. - :vartype resource_id: str - """ - - _validation = { - "resource_id": {"readonly": True}, - } - - _attribute_map = { - "resource_id": {"key": "resourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_id = None - - -class TopologySingleResourceParent(_serialization.Model): - """TopologySingleResourceParent. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_id: Azure resource id which serves as parent resource in topology view. - :vartype resource_id: str - """ - - _validation = { - "resource_id": {"readonly": True}, - } - - _attribute_map = { - "resource_id": {"key": "resourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_id = None - - -class UserRecommendation(_serialization.Model): - """Represents a user that is recommended to be allowed for a certain rule. - - :ivar username: Represents a user that is recommended to be allowed for a certain rule. - :vartype username: str - :ivar recommendation_action: The recommendation action of the machine or rule. Known values - are: "Recommended", "Add", and "Remove". - :vartype recommendation_action: str or - ~azure.mgmt.security.v2020_01_01.models.RecommendationAction - """ - - _attribute_map = { - "username": {"key": "username", "type": "str"}, - "recommendation_action": {"key": "recommendationAction", "type": "str"}, - } - - def __init__( - self, - *, - username: Optional[str] = None, - recommendation_action: Optional[Union[str, "_models.RecommendationAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword username: Represents a user that is recommended to be allowed for a certain rule. - :paramtype username: str - :keyword recommendation_action: The recommendation action of the machine or rule. Known values - are: "Recommended", "Add", and "Remove". - :paramtype recommendation_action: str or - ~azure.mgmt.security.v2020_01_01.models.RecommendationAction - """ - super().__init__(**kwargs) - self.username = username - self.recommendation_action = recommendation_action - - -class VmRecommendation(_serialization.Model): - """Represents a machine that is part of a machine group. - - :ivar configuration_status: The configuration status of the machines group or machine or rule. - Known values are: "Configured", "NotConfigured", "InProgress", "Failed", and "NoStatus". - :vartype configuration_status: str or - ~azure.mgmt.security.v2020_01_01.models.ConfigurationStatus - :ivar recommendation_action: The recommendation action of the machine or rule. Known values - are: "Recommended", "Add", and "Remove". - :vartype recommendation_action: str or - ~azure.mgmt.security.v2020_01_01.models.RecommendationAction - :ivar resource_id: The full resource id of the machine. - :vartype resource_id: str - :ivar enforcement_support: The machine supportability of Enforce feature. Known values are: - "Supported", "NotSupported", and "Unknown". - :vartype enforcement_support: str or ~azure.mgmt.security.v2020_01_01.models.EnforcementSupport - """ - - _attribute_map = { - "configuration_status": {"key": "configurationStatus", "type": "str"}, - "recommendation_action": {"key": "recommendationAction", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "enforcement_support": {"key": "enforcementSupport", "type": "str"}, - } - - def __init__( - self, - *, - configuration_status: Optional[Union[str, "_models.ConfigurationStatus"]] = None, - recommendation_action: Optional[Union[str, "_models.RecommendationAction"]] = None, - resource_id: Optional[str] = None, - enforcement_support: Optional[Union[str, "_models.EnforcementSupport"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword configuration_status: The configuration status of the machines group or machine or - rule. Known values are: "Configured", "NotConfigured", "InProgress", "Failed", and "NoStatus". - :paramtype configuration_status: str or - ~azure.mgmt.security.v2020_01_01.models.ConfigurationStatus - :keyword recommendation_action: The recommendation action of the machine or rule. Known values - are: "Recommended", "Add", and "Remove". - :paramtype recommendation_action: str or - ~azure.mgmt.security.v2020_01_01.models.RecommendationAction - :keyword resource_id: The full resource id of the machine. - :paramtype resource_id: str - :keyword enforcement_support: The machine supportability of Enforce feature. Known values are: - "Supported", "NotSupported", and "Unknown". - :paramtype enforcement_support: str or - ~azure.mgmt.security.v2020_01_01.models.EnforcementSupport - """ - super().__init__(**kwargs) - self.configuration_status = configuration_status - self.recommendation_action = recommendation_action - self.resource_id = resource_id - self.enforcement_support = enforcement_support diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_security_center_enums.py deleted file mode 100644 index b1dde3e34bcc..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_security_center_enums.py +++ /dev/null @@ -1,294 +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 AadConnectivityStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The connectivity state of the external AAD solution.""" - - DISCOVERED = "Discovered" - NOT_LICENSED = "NotLicensed" - CONNECTED = "Connected" - - -class AdaptiveApplicationControlIssue(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """An alert that machines within a group can have.""" - - VIOLATIONS_AUDITED = "ViolationsAudited" - VIOLATIONS_BLOCKED = "ViolationsBlocked" - MSI_AND_SCRIPT_VIOLATIONS_AUDITED = "MsiAndScriptViolationsAudited" - MSI_AND_SCRIPT_VIOLATIONS_BLOCKED = "MsiAndScriptViolationsBlocked" - EXECUTABLE_VIOLATIONS_AUDITED = "ExecutableViolationsAudited" - RULES_VIOLATED_MANUALLY = "RulesViolatedManually" - - -class AssessmentStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Programmatic code for the status of the assessment.""" - - HEALTHY = "Healthy" - """The resource is healthy""" - UNHEALTHY = "Unhealthy" - """The resource has a security issue that needs to be addressed""" - NOT_APPLICABLE = "NotApplicable" - """Assessment for this resource did not happen""" - - -class AssessmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """BuiltIn if the assessment based on built-in Azure Policy definition, Custom if the assessment - based on custom Azure Policy definition. - """ - - BUILT_IN = "BuiltIn" - """Microsoft Defender for Cloud managed assessments""" - CUSTOM_POLICY = "CustomPolicy" - """User defined policies that are automatically ingested from Azure Policy to Microsoft Defender - for Cloud""" - CUSTOMER_MANAGED = "CustomerManaged" - """User assessments pushed directly by the user or other third party to Microsoft Defender for - Cloud""" - VERIFIED_PARTNER = "VerifiedPartner" - """An assessment that was created by a verified 3rd party if the user connected it to ASC""" - - -class Categories(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The categories of resource that is at risk when the assessment is unhealthy.""" - - COMPUTE = "Compute" - NETWORKING = "Networking" - DATA = "Data" - IDENTITY_AND_ACCESS = "IdentityAndAccess" - IO_T = "IoT" - - -class ConfigurationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The configuration status of the machines group or machine or rule.""" - - CONFIGURED = "Configured" - NOT_CONFIGURED = "NotConfigured" - IN_PROGRESS = "InProgress" - FAILED = "Failed" - NO_STATUS = "NoStatus" - - -class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ConnectionType.""" - - INTERNAL = "Internal" - EXTERNAL = "External" - - -class ControlType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of security control (for example, BuiltIn).""" - - BUILT_IN = "BuiltIn" - """Microsoft Defender for Cloud managed assessments""" - CUSTOM = "Custom" - """Non Microsoft Defender for Cloud managed assessments""" - - -class Direction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rule's direction.""" - - INBOUND = "Inbound" - OUTBOUND = "Outbound" - - -class EnforcementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The application control policy enforcement/protection mode of the machine group.""" - - AUDIT = "Audit" - ENFORCE = "Enforce" - NONE = "None" - - -class EnforcementSupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The machine supportability of Enforce feature.""" - - SUPPORTED = "Supported" - NOT_SUPPORTED = "NotSupported" - UNKNOWN = "Unknown" - - -class ExpandControlsEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExpandControlsEnum.""" - - DEFINITION = "definition" - """Add definition object for each control""" - - -class ExpandEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExpandEnum.""" - - LINKS = "links" - """All links associated with an assessment""" - METADATA = "metadata" - """Assessment metadata""" - - -class ExternalSecuritySolutionKindEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the external solution.""" - - CEF = "CEF" - ATA = "ATA" - AAD = "AAD" - - -class FileType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the file (for Linux files - Executable is used).""" - - EXE = "Exe" - DLL = "Dll" - MSI = "Msi" - SCRIPT = "Script" - EXECUTABLE = "Executable" - UNKNOWN = "Unknown" - - -class ImplementationEffort(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The implementation effort required to remediate this assessment.""" - - LOW = "Low" - MODERATE = "Moderate" - HIGH = "High" - - -class ProtocolEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ProtocolEnum.""" - - TCP = "TCP" - UDP = "UDP" - ALL = "*" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The security family provisioning State.""" - - SUCCEEDED = "Succeeded" - FAILED = "Failed" - UPDATING = "Updating" - - -class RecommendationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recommendation action of the machine or rule.""" - - RECOMMENDED = "Recommended" - ADD = "Add" - REMOVE = "Remove" - - -class RecommendationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The initial recommendation status of the machine group or machine.""" - - RECOMMENDED = "Recommended" - NOT_RECOMMENDED = "NotRecommended" - NOT_AVAILABLE = "NotAvailable" - NO_STATUS = "NoStatus" - - -class RecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the rule to be allowed.""" - - FILE = "File" - FILE_HASH = "FileHash" - PUBLISHER_SIGNATURE = "PublisherSignature" - PRODUCT_SIGNATURE = "ProductSignature" - BINARY_SIGNATURE = "BinarySignature" - VERSION_AND_ABOVE_SIGNATURE = "VersionAndAboveSignature" - - -class SecurityFamily(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The security family of the discovered solution.""" - - WAF = "Waf" - NGFW = "Ngfw" - SAAS_WAF = "SaasWaf" - VA = "Va" - - -class ServerVulnerabilityAssessmentPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioningState of the vulnerability assessment capability on the VM.""" - - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - PROVISIONING = "Provisioning" - DEPROVISIONING = "Deprovisioning" - - -class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The severity level of the assessment.""" - - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - - -class Source(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The platform where the assessed resource resides.""" - - AZURE = "Azure" - """Resource is in Azure""" - ON_PREMISE = "OnPremise" - """Resource in an on premise machine connected to Azure cloud""" - ON_PREMISE_SQL = "OnPremiseSql" - """SQL Resource in an on premise machine connected to Azure cloud""" - - -class SourceSystem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The source type of the machine group.""" - - AZURE_APP_LOCKER = "Azure_AppLocker" - AZURE_AUDIT_D = "Azure_AuditD" - NON_AZURE_APP_LOCKER = "NonAzure_AppLocker" - NON_AZURE_AUDIT_D = "NonAzure_AuditD" - NONE = "None" - - -class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the port.""" - - REVOKED = "Revoked" - INITIATED = "Initiated" - - -class StatusReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """A description of why the ``status`` has its value.""" - - EXPIRED = "Expired" - USER_REQUESTED = "UserRequested" - NEWER_REQUEST_INITIATED = "NewerRequestInitiated" - - -class Threats(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Threats impact of the assessment.""" - - ACCOUNT_BREACH = "accountBreach" - DATA_EXFILTRATION = "dataExfiltration" - DATA_SPILLAGE = "dataSpillage" - MALICIOUS_INSIDER = "maliciousInsider" - ELEVATION_OF_PRIVILEGE = "elevationOfPrivilege" - THREAT_RESISTANCE = "threatResistance" - MISSING_COVERAGE = "missingCoverage" - DENIAL_OF_SERVICE = "denialOfService" - - -class TransportProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """TransportProtocol.""" - - TCP = "TCP" - UDP = "UDP" - - -class UserImpact(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The user impact of the assessment.""" - - LOW = "Low" - MODERATE = "Moderate" - HIGH = "High" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/__init__.py deleted file mode 100644 index a3d32683f78c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/__init__.py +++ /dev/null @@ -1,47 +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 ._adaptive_network_hardenings_operations import AdaptiveNetworkHardeningsOperations -from ._allowed_connections_operations import AllowedConnectionsOperations -from ._adaptive_application_controls_operations import AdaptiveApplicationControlsOperations -from ._assessments_metadata_operations import AssessmentsMetadataOperations -from ._assessments_operations import AssessmentsOperations -from ._discovered_security_solutions_operations import DiscoveredSecuritySolutionsOperations -from ._external_security_solutions_operations import ExternalSecuritySolutionsOperations -from ._jit_network_access_policies_operations import JitNetworkAccessPoliciesOperations -from ._secure_scores_operations import SecureScoresOperations -from ._secure_score_controls_operations import SecureScoreControlsOperations -from ._secure_score_control_definitions_operations import SecureScoreControlDefinitionsOperations -from ._security_solutions_operations import SecuritySolutionsOperations -from ._security_solutions_reference_data_operations import SecuritySolutionsReferenceDataOperations -from ._server_vulnerability_assessment_operations import ServerVulnerabilityAssessmentOperations -from ._topology_operations import TopologyOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdaptiveNetworkHardeningsOperations", - "AllowedConnectionsOperations", - "AdaptiveApplicationControlsOperations", - "AssessmentsMetadataOperations", - "AssessmentsOperations", - "DiscoveredSecuritySolutionsOperations", - "ExternalSecuritySolutionsOperations", - "JitNetworkAccessPoliciesOperations", - "SecureScoresOperations", - "SecureScoreControlsOperations", - "SecureScoreControlDefinitionsOperations", - "SecuritySolutionsOperations", - "SecuritySolutionsReferenceDataOperations", - "ServerVulnerabilityAssessmentOperations", - "TopologyOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_application_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_application_controls_operations.py deleted file mode 100644 index 0b44a5ac4827..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_application_controls_operations.py +++ /dev/null @@ -1,495 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - subscription_id: str, - *, - include_path_recommendations: Optional[bool] = None, - summary: Optional[bool] = 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applicationWhitelistings" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if include_path_recommendations is not None: - _params["includePathRecommendations"] = _SERIALIZER.query( - "include_path_recommendations", include_path_recommendations, "bool" - ) - if summary is not None: - _params["summary"] = _SERIALIZER.query("summary", summary, "bool") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(asc_location: str, group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "groupName": _SERIALIZER.url("group_name", group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_put_request(asc_location: str, group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-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}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "groupName": _SERIALIZER.url("group_name", group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - 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(asc_location: str, group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "groupName": _SERIALIZER.url("group_name", group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AdaptiveApplicationControlsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`adaptive_application_controls` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, include_path_recommendations: Optional[bool] = None, summary: Optional[bool] = None, **kwargs: Any - ) -> _models.AdaptiveApplicationControlGroups: - """Gets a list of application control machine groups for the subscription. - - :param include_path_recommendations: Include the policy rules. Default value is None. - :type include_path_recommendations: bool - :param summary: Return output in a summarized form. Default value is None. - :type summary: bool - :return: AdaptiveApplicationControlGroups or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroups - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.AdaptiveApplicationControlGroups] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - include_path_recommendations=include_path_recommendations, - summary=summary, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdaptiveApplicationControlGroups", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, asc_location: str, group_name: str, **kwargs: Any) -> _models.AdaptiveApplicationControlGroup: - """Gets an application control VM/server group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :return: AdaptiveApplicationControlGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.AdaptiveApplicationControlGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - asc_location=asc_location, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdaptiveApplicationControlGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def put( - self, - asc_location: str, - group_name: str, - body: _models.AdaptiveApplicationControlGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AdaptiveApplicationControlGroup: - """Update an application control machine group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :param body: Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AdaptiveApplicationControlGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put( - self, - asc_location: str, - group_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AdaptiveApplicationControlGroup: - """Update an application control machine group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AdaptiveApplicationControlGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def put( - self, - asc_location: str, - group_name: str, - body: Union[_models.AdaptiveApplicationControlGroup, IO[bytes]], - **kwargs: Any - ) -> _models.AdaptiveApplicationControlGroup: - """Update an application control machine group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :param body: Is either a AdaptiveApplicationControlGroup type or a IO[bytes] type. Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup or - IO[bytes] - :return: AdaptiveApplicationControlGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdaptiveApplicationControlGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "AdaptiveApplicationControlGroup") - - _request = build_put_request( - asc_location=asc_location, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdaptiveApplicationControlGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, asc_location: str, group_name: str, **kwargs: Any - ) -> None: - """Delete an application control machine group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param group_name: Name of an application control machine group. Required. - :type group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - asc_location=asc_location, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_network_hardenings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_network_hardenings_operations.py deleted file mode 100644 index aa19503ecf1d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_network_hardenings_operations.py +++ /dev/null @@ -1,599 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_extended_resource_request( - resource_group_name: str, - resource_namespace: str, - resource_type: str, - 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), - "resourceName": _SERIALIZER.url("resource_name", 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_get_request( - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "adaptiveNetworkHardeningResourceName": _SERIALIZER.url( - "adaptive_network_hardening_resource_name", adaptive_network_hardening_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_enforce_request( - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_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 {}) - - adaptive_network_hardening_enforce_action: Literal["enforce"] = kwargs.pop( - "adaptive_network_hardening_enforce_action", "enforce" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-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/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "adaptiveNetworkHardeningResourceName": _SERIALIZER.url( - "adaptive_network_hardening_resource_name", adaptive_network_hardening_resource_name, "str" - ), - "adaptiveNetworkHardeningEnforceAction": _SERIALIZER.url( - "adaptive_network_hardening_enforce_action", adaptive_network_hardening_enforce_action, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AdaptiveNetworkHardeningsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`adaptive_network_hardenings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_extended_resource( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.AdaptiveNetworkHardening"]: - """Gets a list of Adaptive Network Hardenings resources in scope of an extended resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either AdaptiveNetworkHardening or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardening] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.AdaptiveNetworkHardeningsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_extended_resource_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AdaptiveNetworkHardeningsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - **kwargs: Any - ) -> _models.AdaptiveNetworkHardening: - """Gets a single Adaptive Network Hardening resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. Required. - :type adaptive_network_hardening_resource_name: str - :return: AdaptiveNetworkHardening or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardening - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.AdaptiveNetworkHardening] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - adaptive_network_hardening_resource_name=adaptive_network_hardening_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdaptiveNetworkHardening", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _enforce_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - body: Union[_models.AdaptiveNetworkHardeningEnforceRequest, IO[bytes]], - **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - adaptive_network_hardening_enforce_action: Literal["enforce"] = kwargs.pop( - "adaptive_network_hardening_enforce_action", "enforce" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "AdaptiveNetworkHardeningEnforceRequest") - - _request = build_enforce_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - adaptive_network_hardening_resource_name=adaptive_network_hardening_resource_name, - subscription_id=self._config.subscription_id, - adaptive_network_hardening_enforce_action=adaptive_network_hardening_enforce_action, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - def begin_enforce( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - body: _models.AdaptiveNetworkHardeningEnforceRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Enforces the given rules on the NSG(s) listed in the request. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. Required. - :type adaptive_network_hardening_resource_name: str - :param body: Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardeningEnforceRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_enforce( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Enforces the given rules on the NSG(s) listed in the request. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. Required. - :type adaptive_network_hardening_resource_name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_enforce( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - body: Union[_models.AdaptiveNetworkHardeningEnforceRequest, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Enforces the given rules on the NSG(s) listed in the request. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. Required. - :type adaptive_network_hardening_resource_name: str - :param body: Is either a AdaptiveNetworkHardeningEnforceRequest type or a IO[bytes] type. - Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardeningEnforceRequest or - IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - adaptive_network_hardening_enforce_action: Literal["enforce"] = kwargs.pop( - "adaptive_network_hardening_enforce_action", "enforce" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._enforce_initial( # type: ignore - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - adaptive_network_hardening_resource_name=adaptive_network_hardening_resource_name, - body=body, - adaptive_network_hardening_enforce_action=adaptive_network_hardening_enforce_action, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_allowed_connections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_allowed_connections_operations.py deleted file mode 100644 index 7385926cbf12..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_allowed_connections_operations.py +++ /dev/null @@ -1,386 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( - resource_group_name: str, - asc_location: str, - connection_type: Union[str, _models.ConnectionType], - 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "connectionType": _SERIALIZER.url("connection_type", connection_type, "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) - - -class AllowedConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`allowed_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.AllowedConnectionsResource"]: - """Gets the list of all possible traffic between resources for the subscription. - - :return: An iterator like instance of either AllowedConnectionsResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.AllowedConnectionsResource] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.AllowedConnectionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AllowedConnectionsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_models.AllowedConnectionsResource"]: - """Gets the list of all possible traffic between resources for the subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either AllowedConnectionsResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.AllowedConnectionsResource] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.AllowedConnectionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AllowedConnectionsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - asc_location: str, - connection_type: Union[str, _models.ConnectionType], - **kwargs: Any - ) -> _models.AllowedConnectionsResource: - """Gets the list of all possible traffic between resources for the subscription and location, - based on connection type. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param connection_type: The type of allowed connections (Internal, External). Known values are: - "Internal" and "External". Required. - :type connection_type: str or ~azure.mgmt.security.v2020_01_01.models.ConnectionType - :return: AllowedConnectionsResource or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.AllowedConnectionsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.AllowedConnectionsResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - connection_type=connection_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AllowedConnectionsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_metadata_operations.py deleted file mode 100644 index 6a0c9a9d4ad6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_metadata_operations.py +++ /dev/null @@ -1,665 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Security/assessmentMetadata") - - # 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_request(assessment_metadata_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}") - path_format_arguments = { - "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_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_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_in_subscription_request( - assessment_metadata_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_create_in_subscription_request( - assessment_metadata_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", "2020-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}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - } - - _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_in_subscription_request( - assessment_metadata_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AssessmentsMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`assessments_metadata` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadata"]: - """Get metadata information on all assessment types. - - :return: An iterator like instance of either SecurityAssessmentMetadata or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentMetadataList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentMetadataList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityAssessmentMetadata: - """Get metadata information on an assessment type. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) - - _request = build_get_request( - assessment_metadata_name=assessment_metadata_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadata"]: - """Get metadata information on all assessment types in a specific subscription. - - :return: An iterator like instance of either SecurityAssessmentMetadata or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentMetadataList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentMetadataList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_in_subscription(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityAssessmentMetadata: - """Get metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) - - _request = build_get_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: _models.SecurityAssessmentMetadata, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentMetadata: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Required. - :type assessment_metadata: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentMetadata: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Required. - :type assessment_metadata: 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: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: Union[_models.SecurityAssessmentMetadata, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityAssessmentMetadata: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Is either a SecurityAssessmentMetadata - type or a IO[bytes] type. Required. - :type assessment_metadata: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - or IO[bytes] - :return: SecurityAssessmentMetadata or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(assessment_metadata, (IOBase, bytes)): - _content = assessment_metadata - else: - _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadata") - - _request = build_create_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_in_subscription( # pylint: disable=inconsistent-return-statements - self, assessment_metadata_name: str, **kwargs: Any - ) -> None: - """Delete metadata information on an assessment type in a specific subscription, will cause the - deletion of all the assessments of that type in that subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_operations.py deleted file mode 100644 index fa43db36667a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_operations.py +++ /dev/null @@ -1,501 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/assessments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_id: str, assessment_name: str, *, expand: Optional[Union[str, _models.ExpandEnum]] = 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(resource_id: str, assessment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-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", "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_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_delete_request(resource_id: str, assessment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> Iterable["_models.SecurityAssessment"]: - """Get security assessments on all your scanned resources inside a scope. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either SecurityAssessment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.SecurityAssessment] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_id: str, - assessment_name: str, - expand: Optional[Union[str, _models.ExpandEnum]] = None, - **kwargs: Any - ) -> _models.SecurityAssessment: - """Get a security assessment on your scanned resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param expand: OData expand. Optional. Known values are: "links" and "metadata". Default value - is None. - :type expand: str or ~azure.mgmt.security.v2020_01_01.models.ExpandEnum - :return: SecurityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecurityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - assessment_name=assessment_name, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: _models.SecurityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessment: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. - :type assessment: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessment: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. - :type assessment: 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: SecurityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: Union[_models.SecurityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityAssessment: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Is either a - SecurityAssessment type or a IO[bytes] type. Required. - :type assessment: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment or IO[bytes] - :return: SecurityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityAssessment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(assessment, (IOBase, bytes)): - _content = assessment - else: - _json = self._serialize.body(assessment, "SecurityAssessment") - - _request = build_create_or_update_request( - resource_id=resource_id, - assessment_name=assessment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityAssessment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityAssessment", pipeline_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_id: str, assessment_name: str, **kwargs: Any - ) -> None: - """Delete a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_id=resource_id, - assessment_name=assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_discovered_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_discovered_security_solutions_operations.py deleted file mode 100644 index a3f605075da7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_discovered_security_solutions_operations.py +++ /dev/null @@ -1,384 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/discoveredSecuritySolutions" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( - resource_group_name: str, - asc_location: str, - discovered_security_solution_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions/{discoveredSecuritySolutionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "discoveredSecuritySolutionName": _SERIALIZER.url( - "discovered_security_solution_name", discovered_security_solution_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) - - -class DiscoveredSecuritySolutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`discovered_security_solutions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DiscoveredSecuritySolution"]: - """Gets a list of discovered Security Solutions for the subscription. - - :return: An iterator like instance of either DiscoveredSecuritySolution or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.DiscoveredSecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiscoveredSecuritySolutionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_models.DiscoveredSecuritySolution"]: - """Gets a list of discovered Security Solutions for the subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either DiscoveredSecuritySolution or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.DiscoveredSecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiscoveredSecuritySolutionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, asc_location: str, discovered_security_solution_name: str, **kwargs: Any - ) -> _models.DiscoveredSecuritySolution: - """Gets a specific discovered Security Solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param discovered_security_solution_name: Name of a discovered security solution. Required. - :type discovered_security_solution_name: str - :return: DiscoveredSecuritySolution or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.DiscoveredSecuritySolution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - discovered_security_solution_name=discovered_security_solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiscoveredSecuritySolution", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_external_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_external_security_solutions_operations.py deleted file mode 100644 index f1a6761434a6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_external_security_solutions_operations.py +++ /dev/null @@ -1,384 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/externalSecuritySolutions" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( - resource_group_name: str, - asc_location: str, - external_security_solutions_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions/{externalSecuritySolutionsName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "externalSecuritySolutionsName": _SERIALIZER.url( - "external_security_solutions_name", external_security_solutions_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) - - -class ExternalSecuritySolutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`external_security_solutions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.ExternalSecuritySolution"]: - """Gets a list of external security solutions for the subscription. - - :return: An iterator like instance of either ExternalSecuritySolution or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.ExternalSecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ExternalSecuritySolutionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_models.ExternalSecuritySolution"]: - """Gets a list of external Security Solutions for the subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either ExternalSecuritySolution or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.ExternalSecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ExternalSecuritySolutionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, asc_location: str, external_security_solutions_name: str, **kwargs: Any - ) -> _models.ExternalSecuritySolution: - """Gets a specific external Security Solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param external_security_solutions_name: Name of an external security solution. Required. - :type external_security_solutions_name: str - :return: ExternalSecuritySolution or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.ExternalSecuritySolution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - external_security_solutions_name=external_security_solutions_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ExternalSecuritySolution", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_jit_network_access_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_jit_network_access_policies_operations.py deleted file mode 100644 index 26a8baeac23d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_jit_network_access_policies_operations.py +++ /dev/null @@ -1,1124 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/jitNetworkAccessPolicies" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_region_request(asc_location: 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/jitNetworkAccessPolicies", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_and_region_request( # pylint: disable=name-too-long - resource_group_name: str, asc_location: 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( - resource_group_name: str, - asc_location: str, - jit_network_access_policy_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "jitNetworkAccessPolicyName": _SERIALIZER.url( - "jit_network_access_policy_name", jit_network_access_policy_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - asc_location: str, - jit_network_access_policy_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", "2020-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.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "jitNetworkAccessPolicyName": _SERIALIZER.url( - "jit_network_access_policy_name", jit_network_access_policy_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_delete_request( - resource_group_name: str, - asc_location: str, - jit_network_access_policy_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "jitNetworkAccessPolicyName": _SERIALIZER.url( - "jit_network_access_policy_name", jit_network_access_policy_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_initiate_request( - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - jit_network_access_policy_initiate_type: Literal["initiate"] = kwargs.pop( - "jit_network_access_policy_initiate_type", "initiate" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-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.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}/{jitNetworkAccessPolicyInitiateType}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "jitNetworkAccessPolicyName": _SERIALIZER.url( - "jit_network_access_policy_name", jit_network_access_policy_name, "str" - ), - "jitNetworkAccessPolicyInitiateType": _SERIALIZER.url( - "jit_network_access_policy_initiate_type", jit_network_access_policy_initiate_type, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class JitNetworkAccessPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`jit_network_access_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.JitNetworkAccessPolicy"]: - """Policies for protecting resources using Just-in-Time access control. - - :return: An iterator like instance of either JitNetworkAccessPolicy or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JitNetworkAccessPoliciesList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_region(self, asc_location: str, **kwargs: Any) -> Iterable["_models.JitNetworkAccessPolicy"]: - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either JitNetworkAccessPolicy or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JitNetworkAccessPoliciesList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.JitNetworkAccessPolicy"]: - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either JitNetworkAccessPolicy or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JitNetworkAccessPoliciesList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group_and_region( - self, resource_group_name: str, asc_location: str, **kwargs: Any - ) -> Iterable["_models.JitNetworkAccessPolicy"]: - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either JitNetworkAccessPolicy or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_and_region_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JitNetworkAccessPoliciesList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any - ) -> _models.JitNetworkAccessPolicy: - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :return: JitNetworkAccessPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - jit_network_access_policy_name=jit_network_access_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitNetworkAccessPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: _models.JitNetworkAccessPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitNetworkAccessPolicy: - """Create a policy for protecting resources using Just-in-Time access control. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JitNetworkAccessPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitNetworkAccessPolicy: - """Create a policy for protecting resources using Just-in-Time access control. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JitNetworkAccessPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: Union[_models.JitNetworkAccessPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.JitNetworkAccessPolicy: - """Create a policy for protecting resources using Just-in-Time access control. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Is either a JitNetworkAccessPolicy type or a IO[bytes] type. Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy or IO[bytes] - :return: JitNetworkAccessPolicy or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "JitNetworkAccessPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - jit_network_access_policy_name=jit_network_access_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitNetworkAccessPolicy", pipeline_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, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any - ) -> None: - """Delete a Just-in-Time access control policy. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - jit_network_access_policy_name=jit_network_access_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - def initiate( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: _models.JitNetworkAccessPolicyInitiateRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitNetworkAccessRequest: - """Initiate a JIT access from a specific Just-in-Time policy configuration. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiateRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JitNetworkAccessRequest or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def initiate( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitNetworkAccessRequest: - """Initiate a JIT access from a specific Just-in-Time policy configuration. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JitNetworkAccessRequest or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def initiate( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - body: Union[_models.JitNetworkAccessPolicyInitiateRequest, IO[bytes]], - **kwargs: Any - ) -> _models.JitNetworkAccessRequest: - """Initiate a JIT access from a specific Just-in-Time policy configuration. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - Required. - :type jit_network_access_policy_name: str - :param body: Is either a JitNetworkAccessPolicyInitiateRequest type or a IO[bytes] type. - Required. - :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiateRequest or - IO[bytes] - :return: JitNetworkAccessRequest or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - jit_network_access_policy_initiate_type: Literal["initiate"] = kwargs.pop( - "jit_network_access_policy_initiate_type", "initiate" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JitNetworkAccessRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "JitNetworkAccessPolicyInitiateRequest") - - _request = build_initiate_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - jit_network_access_policy_name=jit_network_access_policy_name, - subscription_id=self._config.subscription_id, - jit_network_access_policy_initiate_type=jit_network_access_policy_initiate_type, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitNetworkAccessRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_control_definitions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_control_definitions_operations.py deleted file mode 100644 index e37db2ddbc18..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_control_definitions_operations.py +++ /dev/null @@ -1,265 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Security/secureScoreControlDefinitions") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) - - -class SecureScoreControlDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`secure_score_control_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecureScoreControlDefinitionItem"]: - """List the available security controls, their assessments, and the max score. - - :return: An iterator like instance of either SecureScoreControlDefinitionItem or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDefinitionItem] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreControlDefinitionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoreControlDefinitionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SecureScoreControlDefinitionItem"]: - """For a specified subscription, list the available security controls, their assessments, and the - max score. - - :return: An iterator like instance of either SecureScoreControlDefinitionItem or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDefinitionItem] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreControlDefinitionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoreControlDefinitionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_controls_operations.py deleted file mode 100644 index b05b40b84fd8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_controls_operations.py +++ /dev/null @@ -1,302 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_secure_score_request( - secure_score_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.ExpandControlsEnum]] = 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "secureScoreName": _SERIALIZER.url("secure_score_name", secure_score_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - subscription_id: str, *, expand: Optional[Union[str, _models.ExpandControlsEnum]] = 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControls" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class SecureScoreControlsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`secure_score_controls` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_secure_score( - self, secure_score_name: str, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any - ) -> Iterable["_models.SecureScoreControlDetails"]: - """Get all security controls for a specific initiative within a scope. - - :param secure_score_name: The initiative name. For the ASC Default initiative, use 'ascScore' - as in the sample request below. Required. - :type secure_score_name: str - :param expand: OData expand. Optional. "definition" Default value is None. - :type expand: str or ~azure.mgmt.security.v2020_01_01.models.ExpandControlsEnum - :return: An iterator like instance of either SecureScoreControlDetails or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDetails] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreControlList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_secure_score_request( - secure_score_name=secure_score_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoreControlList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list( - self, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any - ) -> Iterable["_models.SecureScoreControlDetails"]: - """Get all security controls within a scope. - - :param expand: OData expand. Optional. "definition" Default value is None. - :type expand: str or ~azure.mgmt.security.v2020_01_01.models.ExpandControlsEnum - :return: An iterator like instance of either SecureScoreControlDetails or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDetails] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreControlList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoreControlList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_scores_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_scores_operations.py deleted file mode 100644 index d490ae664ead..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_scores_operations.py +++ /dev/null @@ -1,248 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(secure_score_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "secureScoreName": _SERIALIZER.url("secure_score_name", secure_score_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) - - -class SecureScoresOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`secure_scores` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecureScoreItem"]: - """List secure scores for all your Microsoft Defender for Cloud initiatives within your current - scope. - - :return: An iterator like instance of either SecureScoreItem or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.SecureScoreItem] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoresList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecureScoresList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, secure_score_name: str, **kwargs: Any) -> _models.SecureScoreItem: - """Get secure score for a specific Microsoft Defender for Cloud initiative within your current - scope. For the ASC Default initiative, use 'ascScore'. - - :param secure_score_name: The initiative name. For the ASC Default initiative, use 'ascScore' - as in the sample request below. Required. - :type secure_score_name: str - :return: SecureScoreItem or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecureScoreItem - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecureScoreItem] = kwargs.pop("cls", None) - - _request = build_get_request( - secure_score_name=secure_score_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecureScoreItem", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_operations.py deleted file mode 100644 index 0f543359de7e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_operations.py +++ /dev/null @@ -1,262 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request( - resource_group_name: str, asc_location: str, security_solution_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "securitySolutionName": _SERIALIZER.url("security_solution_name", security_solution_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) - - -class SecuritySolutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`security_solutions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecuritySolution"]: - """Gets a list of Security Solutions for the subscription. - - :return: An iterator like instance of either SecuritySolution or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.SecuritySolution] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.SecuritySolutionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecuritySolutionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, asc_location: str, security_solution_name: str, **kwargs: Any - ) -> _models.SecuritySolution: - """Gets a specific Security Solution. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param security_solution_name: Name of security solution. Required. - :type security_solution_name: str - :return: SecuritySolution or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecuritySolution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - security_solution_name=security_solution_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecuritySolution", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_reference_data_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_reference_data_operations.py deleted file mode 100644 index 841cc9a078ae..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_reference_data_operations.py +++ /dev/null @@ -1,220 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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) - - -class SecuritySolutionsReferenceDataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`security_solutions_reference_data` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: - """Gets a list of all supported Security Solutions for the subscription. - - :return: SecuritySolutionsReferenceDataList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceDataList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_home_region(self, asc_location: str, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: - """Gets list of all supported Security Solutions for subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: SecuritySolutionsReferenceDataList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceDataList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_server_vulnerability_assessment_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_server_vulnerability_assessment_operations.py deleted file mode 100644 index 234fe401556e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_server_vulnerability_assessment_operations.py +++ /dev/null @@ -1,549 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Literal, Optional, Type, TypeVar, Union, cast - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_extended_resource_request( - resource_group_name: str, - resource_namespace: str, - resource_type: str, - 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), - "resourceName": _SERIALIZER.url("resource_name", 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_get_request( - resource_group_name: str, - resource_namespace: str, - resource_type: str, - 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 {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "serverVulnerabilityAssessment": _SERIALIZER.url( - "server_vulnerability_assessment", server_vulnerability_assessment, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - resource_namespace: str, - resource_type: str, - 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 {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "serverVulnerabilityAssessment": _SERIALIZER.url( - "server_vulnerability_assessment", server_vulnerability_assessment, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - resource_namespace: str, - resource_type: str, - 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 {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "serverVulnerabilityAssessment": _SERIALIZER.url( - "server_vulnerability_assessment", server_vulnerability_assessment, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerVulnerabilityAssessmentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`server_vulnerability_assessment` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_extended_resource( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsList: - """Gets a list of server vulnerability assessment onboarding statuses on a given resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: ServerVulnerabilityAssessmentsList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessmentsList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.ServerVulnerabilityAssessmentsList] = kwargs.pop("cls", None) - - _request = build_list_by_extended_resource_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServerVulnerabilityAssessmentsList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Gets a server vulnerability assessment onboarding statuses on a given resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - server_vulnerability_assessment=server_vulnerability_assessment, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def create_or_update( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Creating a server vulnerability assessment on a resource, which will onboard a resource for - having a vulnerability assessment on it. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - server_vulnerability_assessment=server_vulnerability_assessment, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - server_vulnerability_assessment=server_vulnerability_assessment, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Removing server vulnerability assessment from a resource. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_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 {}) - - server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - server_vulnerability_assessment=server_vulnerability_assessment, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # 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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_topology_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_topology_operations.py deleted file mode 100644 index bae076872e9a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_topology_operations.py +++ /dev/null @@ -1,372 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/topologies") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_home_region_request(asc_location: 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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/topologies", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "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_get_request( - resource_group_name: str, asc_location: str, topology_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", "2020-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/topologies/{topologyResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "topologyResourceName": _SERIALIZER.url("topology_resource_name", topology_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) - - -class TopologyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01.SecurityCenter`'s - :attr:`topology` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.TopologyResource"]: - """Gets a list that allows to build a topology view of a subscription. - - :return: An iterator like instance of either TopologyResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.TopologyResource] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.TopologyList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("TopologyList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_models.TopologyResource"]: - """Gets a list that allows to build a topology view of a subscription and location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either TopologyResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01.models.TopologyResource] - :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._api_version or "2020-01-01")) - cls: ClsType[_models.TopologyList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_home_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("TopologyList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, asc_location: str, topology_resource_name: str, **kwargs: Any - ) -> _models.TopologyResource: - """Gets a specific topology component. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param topology_resource_name: Name of a topology resources collection. Required. - :type topology_resource_name: str - :return: TopologyResource or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01.models.TopologyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) - cls: ClsType[_models.TopologyResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - topology_resource_name=topology_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TopologyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_configuration.py deleted file mode 100644 index 288167daf390..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-01-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", "2020-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_metadata.json deleted file mode 100644 index adac1855666d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2020-01-01-preview", - "total_api_version_list": ["2020-01-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "connectors": "ConnectorsOperations", - "security_contacts": "SecurityContactsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_security_center.py deleted file mode 100644 index ac1dbc89b264..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_security_center.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ConnectorsOperations, SecurityContactsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar connectors: ConnectorsOperations operations - :vartype connectors: azure.mgmt.security.v2020_01_01_preview.operations.ConnectorsOperations - :ivar security_contacts: SecurityContactsOperations operations - :vartype security_contacts: - azure.mgmt.security.v2020_01_01_preview.operations.SecurityContactsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-01-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.connectors = ConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01-preview" - ) - self.security_contacts = SecurityContactsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_configuration.py deleted file mode 100644 index 6659bc7e5cf4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-01-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", "2020-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_security_center.py deleted file mode 100644 index e28ed4b8fec1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_security_center.py +++ /dev/null @@ -1,118 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ConnectorsOperations, SecurityContactsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar connectors: ConnectorsOperations operations - :vartype connectors: - azure.mgmt.security.v2020_01_01_preview.aio.operations.ConnectorsOperations - :ivar security_contacts: SecurityContactsOperations operations - :vartype security_contacts: - azure.mgmt.security.v2020_01_01_preview.aio.operations.SecurityContactsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-01-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.connectors = ConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01-preview" - ) - self.security_contacts = SecurityContactsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-01-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/__init__.py deleted file mode 100644 index 48244779e87d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,21 +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 ._connectors_operations import ConnectorsOperations -from ._security_contacts_operations import SecurityContactsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ConnectorsOperations", - "SecurityContactsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py deleted file mode 100644 index 21678e8b0fb6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py +++ /dev/null @@ -1,375 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._connectors_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01_preview.aio.SecurityCenter`'s - :attr:`connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.ConnectorSetting"]: - """Cloud accounts connectors of a subscription. - - :return: An iterator like instance of either ConnectorSetting or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting] - :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._api_version or "2020-01-01-preview") - ) - cls: ClsType[_models.ConnectorSettingList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ConnectorSettingList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, connector_name: str, **kwargs: Any) -> _models.ConnectorSetting: - """Details of a specific cloud account connector. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :return: ConnectorSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - connector_name=connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ConnectorSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - connector_name: str, - connector_setting: _models.ConnectorSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ConnectorSetting: - """Create a cloud account connector or update an existing one. Connect to your cloud account. For - AWS, use either account credentials or role-based authentication. For GCP, use account - organization credentials. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :param connector_setting: Settings for the cloud account connector. Required. - :type connector_setting: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ConnectorSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - connector_name: str, - connector_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ConnectorSetting: - """Create a cloud account connector or update an existing one. Connect to your cloud account. For - AWS, use either account credentials or role-based authentication. For GCP, use account - organization credentials. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :param connector_setting: Settings for the cloud account connector. Required. - :type connector_setting: 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: ConnectorSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, connector_name: str, connector_setting: Union[_models.ConnectorSetting, IO[bytes]], **kwargs: Any - ) -> _models.ConnectorSetting: - """Create a cloud account connector or update an existing one. Connect to your cloud account. For - AWS, use either account credentials or role-based authentication. For GCP, use account - organization credentials. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :param connector_setting: Settings for the cloud account connector. Is either a - ConnectorSetting type or a IO[bytes] type. Required. - :type connector_setting: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting or - IO[bytes] - :return: ConnectorSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connector_setting, (IOBase, bytes)): - _content = connector_setting - else: - _json = self._serialize.body(connector_setting, "ConnectorSetting") - - _request = build_create_or_update_request( - connector_name=connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ConnectorSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, connector_name: str, **kwargs: Any - ) -> None: - """Delete a cloud account connector from a subscription. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - connector_name=connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_security_contacts_operations.py deleted file mode 100644 index 95f4723da89a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_security_contacts_operations.py +++ /dev/null @@ -1,373 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_contacts_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityContactsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01_preview.aio.SecurityCenter`'s - :attr:`security_contacts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityContact"]: - """List all security contact configurations for the subscription. - - :return: An iterator like instance of either SecurityContact or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact] - :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._api_version or "2020-01-01-preview") - ) - cls: ClsType[_models.SecurityContactList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityContactList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, security_contact_name: str, **kwargs: Any) -> _models.SecurityContact: - """Get Default Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - _request = build_get_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - security_contact_name: str, - security_contact: _models.SecurityContact, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Create security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - security_contact_name: str, - security_contact: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Create security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: 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: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, security_contact_name: str, security_contact: Union[_models.SecurityContact, IO[bytes]], **kwargs: Any - ) -> _models.SecurityContact: - """Create security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Is either a SecurityContact type or a - IO[bytes] type. Required. - :type security_contact: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact or - IO[bytes] - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_contact, (IOBase, bytes)): - _content = security_contact - else: - _json = self._serialize.body(security_contact, "SecurityContact") - - _request = build_create_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, security_contact_name: str, **kwargs: Any - ) -> None: - """Delete security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/__init__.py deleted file mode 100644 index 02d587c315da..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/__init__.py +++ /dev/null @@ -1,65 +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 ._models_py3 import AuthenticationDetailsProperties -from ._models_py3 import AwAssumeRoleAuthenticationDetailsProperties -from ._models_py3 import AwsCredsAuthenticationDetailsProperties -from ._models_py3 import CloudErrorBody -from ._models_py3 import ConnectorSetting -from ._models_py3 import ConnectorSettingList -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import GcpCredentialsDetailsProperties -from ._models_py3 import HybridComputeSettingsProperties -from ._models_py3 import ProxyServerProperties -from ._models_py3 import Resource -from ._models_py3 import SecurityContact -from ._models_py3 import SecurityContactList -from ._models_py3 import SecurityContactPropertiesAlertNotifications -from ._models_py3 import SecurityContactPropertiesNotificationsByRole -from ._models_py3 import ServicePrincipalProperties - -from ._security_center_enums import AuthenticationProvisioningState -from ._security_center_enums import AuthenticationType -from ._security_center_enums import AutoProvision -from ._security_center_enums import HybridComputeProvisioningState -from ._security_center_enums import MinimalSeverity -from ._security_center_enums import PermissionProperty -from ._security_center_enums import Roles -from ._security_center_enums import State -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthenticationDetailsProperties", - "AwAssumeRoleAuthenticationDetailsProperties", - "AwsCredsAuthenticationDetailsProperties", - "CloudErrorBody", - "ConnectorSetting", - "ConnectorSettingList", - "ErrorAdditionalInfo", - "GcpCredentialsDetailsProperties", - "HybridComputeSettingsProperties", - "ProxyServerProperties", - "Resource", - "SecurityContact", - "SecurityContactList", - "SecurityContactPropertiesAlertNotifications", - "SecurityContactPropertiesNotificationsByRole", - "ServicePrincipalProperties", - "AuthenticationProvisioningState", - "AuthenticationType", - "AutoProvision", - "HybridComputeProvisioningState", - "MinimalSeverity", - "PermissionProperty", - "Roles", - "State", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py deleted file mode 100644 index bdf35e325217..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py +++ /dev/null @@ -1,851 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AuthenticationDetailsProperties(_serialization.Model): - """Settings for cloud authentication management. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AwAssumeRoleAuthenticationDetailsProperties, AwsCredsAuthenticationDetailsProperties, - GcpCredentialsDetailsProperties - - 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 authentication_provisioning_state: State of the multi-cloud connector. Known values are: - "Valid", "Invalid", "Expired", and "IncorrectPolicy". - :vartype authentication_provisioning_state: str or - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationProvisioningState - :ivar granted_permissions: The permissions detected in the cloud account. - :vartype granted_permissions: list[str or - ~azure.mgmt.security.v2020_01_01_preview.models.PermissionProperty] - :ivar authentication_type: Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials. - Required. Known values are: "awsCreds", "awsAssumeRole", and "gcpCredentials". - :vartype authentication_type: str or - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationType - """ - - _validation = { - "authentication_provisioning_state": {"readonly": True}, - "granted_permissions": {"readonly": True}, - "authentication_type": {"required": True}, - } - - _attribute_map = { - "authentication_provisioning_state": {"key": "authenticationProvisioningState", "type": "str"}, - "granted_permissions": {"key": "grantedPermissions", "type": "[str]"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - } - - _subtype_map = { - "authentication_type": { - "awsAssumeRole": "AwAssumeRoleAuthenticationDetailsProperties", - "awsCreds": "AwsCredsAuthenticationDetailsProperties", - "gcpCredentials": "GcpCredentialsDetailsProperties", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.authentication_provisioning_state = None - self.granted_permissions = None - self.authentication_type: Optional[str] = None - - -class AwAssumeRoleAuthenticationDetailsProperties(AuthenticationDetailsProperties): # pylint: disable=name-too-long - """AWS cloud account connector based assume role, the role enables delegating access to your AWS - resources. The role is composed of role Amazon Resource Name (ARN) and external ID. For more - details, refer to :code:`Creating - a Role to Delegate Permissions to an IAM User (write only)`. - - 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 authentication_provisioning_state: State of the multi-cloud connector. Known values are: - "Valid", "Invalid", "Expired", and "IncorrectPolicy". - :vartype authentication_provisioning_state: str or - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationProvisioningState - :ivar granted_permissions: The permissions detected in the cloud account. - :vartype granted_permissions: list[str or - ~azure.mgmt.security.v2020_01_01_preview.models.PermissionProperty] - :ivar authentication_type: Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials. - Required. Known values are: "awsCreds", "awsAssumeRole", and "gcpCredentials". - :vartype authentication_type: str or - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationType - :ivar account_id: The ID of the cloud account. - :vartype account_id: str - :ivar aws_assume_role_arn: Assumed role ID is an identifier that you can use to create - temporary security credentials. Required. - :vartype aws_assume_role_arn: str - :ivar aws_external_id: A unique identifier that is required when you assume a role in another - account. Required. - :vartype aws_external_id: str - """ - - _validation = { - "authentication_provisioning_state": {"readonly": True}, - "granted_permissions": {"readonly": True}, - "authentication_type": {"required": True}, - "account_id": {"readonly": True}, - "aws_assume_role_arn": {"required": True}, - "aws_external_id": {"required": True}, - } - - _attribute_map = { - "authentication_provisioning_state": {"key": "authenticationProvisioningState", "type": "str"}, - "granted_permissions": {"key": "grantedPermissions", "type": "[str]"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "account_id": {"key": "accountId", "type": "str"}, - "aws_assume_role_arn": {"key": "awsAssumeRoleArn", "type": "str"}, - "aws_external_id": {"key": "awsExternalId", "type": "str"}, - } - - def __init__(self, *, aws_assume_role_arn: str, aws_external_id: str, **kwargs: Any) -> None: - """ - :keyword aws_assume_role_arn: Assumed role ID is an identifier that you can use to create - temporary security credentials. Required. - :paramtype aws_assume_role_arn: str - :keyword aws_external_id: A unique identifier that is required when you assume a role in - another account. Required. - :paramtype aws_external_id: str - """ - super().__init__(**kwargs) - self.authentication_type: str = "awsAssumeRole" - self.account_id = None - self.aws_assume_role_arn = aws_assume_role_arn - self.aws_external_id = aws_external_id - - -class AwsCredsAuthenticationDetailsProperties(AuthenticationDetailsProperties): - """AWS cloud account connector based credentials, the credentials is composed of access key ID and - secret key, for more details, refer to :code:`Creating an IAM - User in Your AWS Account (write only)`. - - 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 authentication_provisioning_state: State of the multi-cloud connector. Known values are: - "Valid", "Invalid", "Expired", and "IncorrectPolicy". - :vartype authentication_provisioning_state: str or - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationProvisioningState - :ivar granted_permissions: The permissions detected in the cloud account. - :vartype granted_permissions: list[str or - ~azure.mgmt.security.v2020_01_01_preview.models.PermissionProperty] - :ivar authentication_type: Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials. - Required. Known values are: "awsCreds", "awsAssumeRole", and "gcpCredentials". - :vartype authentication_type: str or - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationType - :ivar account_id: The ID of the cloud account. - :vartype account_id: str - :ivar aws_access_key_id: Public key element of the AWS credential object (write only). - Required. - :vartype aws_access_key_id: str - :ivar aws_secret_access_key: Secret key element of the AWS credential object (write only). - Required. - :vartype aws_secret_access_key: str - """ - - _validation = { - "authentication_provisioning_state": {"readonly": True}, - "granted_permissions": {"readonly": True}, - "authentication_type": {"required": True}, - "account_id": {"readonly": True}, - "aws_access_key_id": {"required": True}, - "aws_secret_access_key": {"required": True}, - } - - _attribute_map = { - "authentication_provisioning_state": {"key": "authenticationProvisioningState", "type": "str"}, - "granted_permissions": {"key": "grantedPermissions", "type": "[str]"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "account_id": {"key": "accountId", "type": "str"}, - "aws_access_key_id": {"key": "awsAccessKeyId", "type": "str"}, - "aws_secret_access_key": {"key": "awsSecretAccessKey", "type": "str"}, - } - - def __init__(self, *, aws_access_key_id: str, aws_secret_access_key: str, **kwargs: Any) -> None: - """ - :keyword aws_access_key_id: Public key element of the AWS credential object (write only). - Required. - :paramtype aws_access_key_id: str - :keyword aws_secret_access_key: Secret key element of the AWS credential object (write only). - Required. - :paramtype aws_secret_access_key: str - """ - super().__init__(**kwargs) - self.authentication_type: str = "awsCreds" - self.account_id = None - self.aws_access_key_id = aws_access_key_id - self.aws_secret_access_key = aws_secret_access_key - - -class CloudErrorBody(_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.security.v2020_01_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2020_01_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ConnectorSetting(Resource): - """The connector setting. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar hybrid_compute_settings: Settings for hybrid compute management. These settings are - relevant only for Arc autoProvision (Hybrid Compute). - :vartype hybrid_compute_settings: - ~azure.mgmt.security.v2020_01_01_preview.models.HybridComputeSettingsProperties - :ivar authentication_details: Settings for authentication management, these settings are - relevant only for the cloud connector. - :vartype authentication_details: - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationDetailsProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "hybrid_compute_settings": { - "key": "properties.hybridComputeSettings", - "type": "HybridComputeSettingsProperties", - }, - "authentication_details": { - "key": "properties.authenticationDetails", - "type": "AuthenticationDetailsProperties", - }, - } - - def __init__( - self, - *, - hybrid_compute_settings: Optional["_models.HybridComputeSettingsProperties"] = None, - authentication_details: Optional["_models.AuthenticationDetailsProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword hybrid_compute_settings: Settings for hybrid compute management. These settings are - relevant only for Arc autoProvision (Hybrid Compute). - :paramtype hybrid_compute_settings: - ~azure.mgmt.security.v2020_01_01_preview.models.HybridComputeSettingsProperties - :keyword authentication_details: Settings for authentication management, these settings are - relevant only for the cloud connector. - :paramtype authentication_details: - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationDetailsProperties - """ - super().__init__(**kwargs) - self.hybrid_compute_settings = hybrid_compute_settings - self.authentication_details = authentication_details - - -class ConnectorSettingList(_serialization.Model): - """For a subscription, list of all cloud account connectors and their settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of all the cloud account connector settings. - :vartype value: list[~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ConnectorSetting]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.ConnectorSetting"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of all the cloud account connector settings. - :paramtype value: list[~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class GcpCredentialsDetailsProperties(AuthenticationDetailsProperties): # pylint: disable=too-many-instance-attributes - """GCP cloud account connector based service to service credentials, the credentials are composed - of the organization ID and a JSON API key (write only). - - 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 authentication_provisioning_state: State of the multi-cloud connector. Known values are: - "Valid", "Invalid", "Expired", and "IncorrectPolicy". - :vartype authentication_provisioning_state: str or - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationProvisioningState - :ivar granted_permissions: The permissions detected in the cloud account. - :vartype granted_permissions: list[str or - ~azure.mgmt.security.v2020_01_01_preview.models.PermissionProperty] - :ivar authentication_type: Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials. - Required. Known values are: "awsCreds", "awsAssumeRole", and "gcpCredentials". - :vartype authentication_type: str or - ~azure.mgmt.security.v2020_01_01_preview.models.AuthenticationType - :ivar organization_id: The organization ID of the GCP cloud account. Required. - :vartype organization_id: str - :ivar type: Type field of the API key (write only). Required. - :vartype type: str - :ivar project_id: Project ID field of the API key (write only). Required. - :vartype project_id: str - :ivar private_key_id: Private key ID field of the API key (write only). Required. - :vartype private_key_id: str - :ivar private_key: Private key field of the API key (write only). Required. - :vartype private_key: str - :ivar client_email: Client email field of the API key (write only). Required. - :vartype client_email: str - :ivar client_id: Client ID field of the API key (write only). Required. - :vartype client_id: str - :ivar auth_uri: Auth URI field of the API key (write only). Required. - :vartype auth_uri: str - :ivar token_uri: Token URI field of the API key (write only). Required. - :vartype token_uri: str - :ivar auth_provider_x509_cert_url: Auth provider x509 certificate URL field of the API key - (write only). Required. - :vartype auth_provider_x509_cert_url: str - :ivar client_x509_cert_url: Client x509 certificate URL field of the API key (write only). - Required. - :vartype client_x509_cert_url: str - """ - - _validation = { - "authentication_provisioning_state": {"readonly": True}, - "granted_permissions": {"readonly": True}, - "authentication_type": {"required": True}, - "organization_id": {"required": True}, - "type": {"required": True}, - "project_id": {"required": True}, - "private_key_id": {"required": True}, - "private_key": {"required": True}, - "client_email": {"required": True}, - "client_id": {"required": True}, - "auth_uri": {"required": True}, - "token_uri": {"required": True}, - "auth_provider_x509_cert_url": {"required": True}, - "client_x509_cert_url": {"required": True}, - } - - _attribute_map = { - "authentication_provisioning_state": {"key": "authenticationProvisioningState", "type": "str"}, - "granted_permissions": {"key": "grantedPermissions", "type": "[str]"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "organization_id": {"key": "organizationId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "project_id": {"key": "projectId", "type": "str"}, - "private_key_id": {"key": "privateKeyId", "type": "str"}, - "private_key": {"key": "privateKey", "type": "str"}, - "client_email": {"key": "clientEmail", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - "auth_uri": {"key": "authUri", "type": "str"}, - "token_uri": {"key": "tokenUri", "type": "str"}, - "auth_provider_x509_cert_url": {"key": "authProviderX509CertUrl", "type": "str"}, - "client_x509_cert_url": {"key": "clientX509CertUrl", "type": "str"}, - } - - def __init__( - self, - *, - organization_id: str, - type: str, - project_id: str, - private_key_id: str, - private_key: str, - client_email: str, - client_id: str, - auth_uri: str, - token_uri: str, - auth_provider_x509_cert_url: str, - client_x509_cert_url: str, - **kwargs: Any - ) -> None: - """ - :keyword organization_id: The organization ID of the GCP cloud account. Required. - :paramtype organization_id: str - :keyword type: Type field of the API key (write only). Required. - :paramtype type: str - :keyword project_id: Project ID field of the API key (write only). Required. - :paramtype project_id: str - :keyword private_key_id: Private key ID field of the API key (write only). Required. - :paramtype private_key_id: str - :keyword private_key: Private key field of the API key (write only). Required. - :paramtype private_key: str - :keyword client_email: Client email field of the API key (write only). Required. - :paramtype client_email: str - :keyword client_id: Client ID field of the API key (write only). Required. - :paramtype client_id: str - :keyword auth_uri: Auth URI field of the API key (write only). Required. - :paramtype auth_uri: str - :keyword token_uri: Token URI field of the API key (write only). Required. - :paramtype token_uri: str - :keyword auth_provider_x509_cert_url: Auth provider x509 certificate URL field of the API key - (write only). Required. - :paramtype auth_provider_x509_cert_url: str - :keyword client_x509_cert_url: Client x509 certificate URL field of the API key (write only). - Required. - :paramtype client_x509_cert_url: str - """ - super().__init__(**kwargs) - self.authentication_type: str = "gcpCredentials" - self.organization_id = organization_id - self.type = type - self.project_id = project_id - self.private_key_id = private_key_id - self.private_key = private_key - self.client_email = client_email - self.client_id = client_id - self.auth_uri = auth_uri - self.token_uri = token_uri - self.auth_provider_x509_cert_url = auth_provider_x509_cert_url - self.client_x509_cert_url = client_x509_cert_url - - -class HybridComputeSettingsProperties(_serialization.Model): - """Settings for hybrid compute management. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar hybrid_compute_provisioning_state: State of the service principal and its secret. Known - values are: "Valid", "Invalid", and "Expired". - :vartype hybrid_compute_provisioning_state: str or - ~azure.mgmt.security.v2020_01_01_preview.models.HybridComputeProvisioningState - :ivar auto_provision: Whether or not to automatically install Azure Arc (hybrid compute) agents - on machines. Required. Known values are: "On" and "Off". - :vartype auto_provision: str or ~azure.mgmt.security.v2020_01_01_preview.models.AutoProvision - :ivar resource_group_name: The name of the resource group where Arc (Hybrid Compute) connectors - are connected. - :vartype resource_group_name: str - :ivar region: The location where the metadata of machines will be stored. - :vartype region: str - :ivar proxy_server: For a non-Azure machine that is not connected directly to the internet, - specify a proxy server that the non-Azure machine can use. - :vartype proxy_server: ~azure.mgmt.security.v2020_01_01_preview.models.ProxyServerProperties - :ivar service_principal: An object to access resources that are secured by an Azure AD tenant. - :vartype service_principal: - ~azure.mgmt.security.v2020_01_01_preview.models.ServicePrincipalProperties - """ - - _validation = { - "hybrid_compute_provisioning_state": {"readonly": True}, - "auto_provision": {"required": True}, - } - - _attribute_map = { - "hybrid_compute_provisioning_state": {"key": "hybridComputeProvisioningState", "type": "str"}, - "auto_provision": {"key": "autoProvision", "type": "str"}, - "resource_group_name": {"key": "resourceGroupName", "type": "str"}, - "region": {"key": "region", "type": "str"}, - "proxy_server": {"key": "proxyServer", "type": "ProxyServerProperties"}, - "service_principal": {"key": "servicePrincipal", "type": "ServicePrincipalProperties"}, - } - - def __init__( - self, - *, - auto_provision: Union[str, "_models.AutoProvision"], - resource_group_name: Optional[str] = None, - region: Optional[str] = None, - proxy_server: Optional["_models.ProxyServerProperties"] = None, - service_principal: Optional["_models.ServicePrincipalProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_provision: Whether or not to automatically install Azure Arc (hybrid compute) - agents on machines. Required. Known values are: "On" and "Off". - :paramtype auto_provision: str or ~azure.mgmt.security.v2020_01_01_preview.models.AutoProvision - :keyword resource_group_name: The name of the resource group where Arc (Hybrid Compute) - connectors are connected. - :paramtype resource_group_name: str - :keyword region: The location where the metadata of machines will be stored. - :paramtype region: str - :keyword proxy_server: For a non-Azure machine that is not connected directly to the internet, - specify a proxy server that the non-Azure machine can use. - :paramtype proxy_server: ~azure.mgmt.security.v2020_01_01_preview.models.ProxyServerProperties - :keyword service_principal: An object to access resources that are secured by an Azure AD - tenant. - :paramtype service_principal: - ~azure.mgmt.security.v2020_01_01_preview.models.ServicePrincipalProperties - """ - super().__init__(**kwargs) - self.hybrid_compute_provisioning_state = None - self.auto_provision = auto_provision - self.resource_group_name = resource_group_name - self.region = region - self.proxy_server = proxy_server - self.service_principal = service_principal - - -class ProxyServerProperties(_serialization.Model): - """For a non-Azure machine that is not connected directly to the internet, specify a proxy server - that the non-Azure machine can use. - - :ivar ip: Proxy server IP. - :vartype ip: str - :ivar port: Proxy server port. - :vartype port: str - """ - - _attribute_map = { - "ip": {"key": "ip", "type": "str"}, - "port": {"key": "port", "type": "str"}, - } - - def __init__(self, *, ip: Optional[str] = None, port: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword ip: Proxy server IP. - :paramtype ip: str - :keyword port: Proxy server port. - :paramtype port: str - """ - super().__init__(**kwargs) - self.ip = ip - self.port = port - - -class SecurityContact(Resource): - """Contact details and configurations for notifications coming from Microsoft Defender for Cloud. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar emails: List of email addresses which will get notifications from Microsoft Defender for - Cloud by the configurations defined in this security contact. - :vartype emails: str - :ivar phone: The security contact's phone number. - :vartype phone: str - :ivar alert_notifications: Defines whether to send email notifications about new security - alerts. - :vartype alert_notifications: - ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContactPropertiesAlertNotifications - :ivar notifications_by_role: Defines whether to send email notifications from Microsoft - Defender for Cloud to persons with specific RBAC roles on the subscription. - :vartype notifications_by_role: - ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContactPropertiesNotificationsByRole - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "emails": {"key": "properties.emails", "type": "str"}, - "phone": {"key": "properties.phone", "type": "str"}, - "alert_notifications": { - "key": "properties.alertNotifications", - "type": "SecurityContactPropertiesAlertNotifications", - }, - "notifications_by_role": { - "key": "properties.notificationsByRole", - "type": "SecurityContactPropertiesNotificationsByRole", - }, - } - - def __init__( - self, - *, - emails: Optional[str] = None, - phone: Optional[str] = None, - alert_notifications: Optional["_models.SecurityContactPropertiesAlertNotifications"] = None, - notifications_by_role: Optional["_models.SecurityContactPropertiesNotificationsByRole"] = None, - **kwargs: Any - ) -> None: - """ - :keyword emails: List of email addresses which will get notifications from Microsoft Defender - for Cloud by the configurations defined in this security contact. - :paramtype emails: str - :keyword phone: The security contact's phone number. - :paramtype phone: str - :keyword alert_notifications: Defines whether to send email notifications about new security - alerts. - :paramtype alert_notifications: - ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContactPropertiesAlertNotifications - :keyword notifications_by_role: Defines whether to send email notifications from Microsoft - Defender for Cloud to persons with specific RBAC roles on the subscription. - :paramtype notifications_by_role: - ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContactPropertiesNotificationsByRole - """ - super().__init__(**kwargs) - self.emails = emails - self.phone = phone - self.alert_notifications = alert_notifications - self.notifications_by_role = notifications_by_role - - -class SecurityContactList(_serialization.Model): - """List of security contacts response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of security contacts. - :vartype value: list[~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityContact]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityContactPropertiesAlertNotifications(_serialization.Model): # pylint: disable=name-too-long - """Defines whether to send email notifications about new security alerts. - - :ivar state: Defines if email notifications will be sent about new security alerts. Known - values are: "On" and "Off". - :vartype state: str or ~azure.mgmt.security.v2020_01_01_preview.models.State - :ivar minimal_severity: Defines the minimal alert severity which will be sent as email - notifications. Known values are: "High", "Medium", and "Low". - :vartype minimal_severity: str or - ~azure.mgmt.security.v2020_01_01_preview.models.MinimalSeverity - """ - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "minimal_severity": {"key": "minimalSeverity", "type": "str"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.State"]] = None, - minimal_severity: Optional[Union[str, "_models.MinimalSeverity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Defines if email notifications will be sent about new security alerts. Known - values are: "On" and "Off". - :paramtype state: str or ~azure.mgmt.security.v2020_01_01_preview.models.State - :keyword minimal_severity: Defines the minimal alert severity which will be sent as email - notifications. Known values are: "High", "Medium", and "Low". - :paramtype minimal_severity: str or - ~azure.mgmt.security.v2020_01_01_preview.models.MinimalSeverity - """ - super().__init__(**kwargs) - self.state = state - self.minimal_severity = minimal_severity - - -class SecurityContactPropertiesNotificationsByRole(_serialization.Model): # pylint: disable=name-too-long - """Defines whether to send email notifications from Microsoft Defender for Cloud to persons with - specific RBAC roles on the subscription. - - :ivar state: Defines whether to send email notifications from AMicrosoft Defender for Cloud to - persons with specific RBAC roles on the subscription. Known values are: "On" and "Off". - :vartype state: str or ~azure.mgmt.security.v2020_01_01_preview.models.State - :ivar roles: Defines which RBAC roles will get email notifications from Microsoft Defender for - Cloud. List of allowed RBAC roles:. - :vartype roles: list[str or ~azure.mgmt.security.v2020_01_01_preview.models.Roles] - """ - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "roles": {"key": "roles", "type": "[str]"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.State"]] = None, - roles: Optional[List[Union[str, "_models.Roles"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Defines whether to send email notifications from AMicrosoft Defender for Cloud - to persons with specific RBAC roles on the subscription. Known values are: "On" and "Off". - :paramtype state: str or ~azure.mgmt.security.v2020_01_01_preview.models.State - :keyword roles: Defines which RBAC roles will get email notifications from Microsoft Defender - for Cloud. List of allowed RBAC roles:. - :paramtype roles: list[str or ~azure.mgmt.security.v2020_01_01_preview.models.Roles] - """ - super().__init__(**kwargs) - self.state = state - self.roles = roles - - -class ServicePrincipalProperties(_serialization.Model): - """Details of the service principal. - - :ivar application_id: Application ID of service principal. - :vartype application_id: str - :ivar secret: A secret string that the application uses to prove its identity, also can be - referred to as application password (write only). - :vartype secret: str - """ - - _attribute_map = { - "application_id": {"key": "applicationId", "type": "str"}, - "secret": {"key": "secret", "type": "str"}, - } - - def __init__(self, *, application_id: Optional[str] = None, secret: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword application_id: Application ID of service principal. - :paramtype application_id: str - :keyword secret: A secret string that the application uses to prove its identity, also can be - referred to as application password (write only). - :paramtype secret: str - """ - super().__init__(**kwargs) - self.application_id = application_id - self.secret = secret diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_security_center_enums.py deleted file mode 100644 index ee2d43028a4e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,103 +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 AuthenticationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """State of the multi-cloud connector.""" - - VALID = "Valid" - """Valid connector""" - INVALID = "Invalid" - """Invalid connector""" - EXPIRED = "Expired" - """the connection has expired""" - INCORRECT_POLICY = "IncorrectPolicy" - """Incorrect policy of the connector""" - - -class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Connect to your cloud account, for AWS use either account credentials or role-based - authentication. For GCP use account organization credentials. - """ - - AWS_CREDS = "awsCreds" - """AWS cloud account connector user credentials authentication""" - AWS_ASSUME_ROLE = "awsAssumeRole" - """AWS account connector assume role authentication""" - GCP_CREDENTIALS = "gcpCredentials" - """GCP account connector service to service authentication""" - - -class AutoProvision(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Whether or not to automatically install Azure Arc (hybrid compute) agents on machines.""" - - ON = "On" - """Install missing Azure Arc agents on machines automatically""" - OFF = "Off" - """Do not install Azure Arc agent on the machines automatically""" - - -class HybridComputeProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """State of the service principal and its secret.""" - - VALID = "Valid" - """Valid service principal details.""" - INVALID = "Invalid" - """Invalid service principal details.""" - EXPIRED = "Expired" - """the service principal details are expired""" - - -class MinimalSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Defines the minimal alert severity which will be sent as email notifications.""" - - HIGH = "High" - """Get notifications on new alerts with High severity""" - MEDIUM = "Medium" - """Get notifications on new alerts with medium or high severity""" - LOW = "Low" - """Don't get notifications on new alerts with low, medium or high severity""" - - -class PermissionProperty(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """A permission detected in the cloud account.""" - - AWS_AWS_SECURITY_HUB_READ_ONLY_ACCESS = "AWS::AWSSecurityHubReadOnlyAccess" - """This permission provides read only access to AWS Security Hub resources.""" - AWS_SECURITY_AUDIT = "AWS::SecurityAudit" - """This permission grants access to read security configuration metadata.""" - AWS_AMAZON_SSM_AUTOMATION_ROLE = "AWS::AmazonSSMAutomationRole" - """The permission provides for EC2 Automation service to execute activities defined within - Automation documents.""" - GCP_SECURITY_CENTER_ADMIN_VIEWER = "GCP::Security Center Admin Viewer" - """This permission provides read only access to GCP Security Command Center.""" - - -class Roles(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """A possible role to configure sending security notification alerts to.""" - - ACCOUNT_ADMIN = "AccountAdmin" - """If enabled, send notification on new alerts to the account admins""" - SERVICE_ADMIN = "ServiceAdmin" - """If enabled, send notification on new alerts to the service admins""" - OWNER = "Owner" - """If enabled, send notification on new alerts to the subscription owners""" - CONTRIBUTOR = "Contributor" - """If enabled, send notification on new alerts to the subscription contributors""" - - -class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Defines if email notifications will be sent about new security alerts.""" - - ON = "On" - """Get notifications on new alerts""" - OFF = "Off" - """Don't get notifications on new alerts""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py deleted file mode 100644 index 48244779e87d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py +++ /dev/null @@ -1,21 +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 ._connectors_operations import ConnectorsOperations -from ._security_contacts_operations import SecurityContactsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ConnectorsOperations", - "SecurityContactsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py deleted file mode 100644 index 556ef2fc0745..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py +++ /dev/null @@ -1,486 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(connector_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", "2020-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(connector_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", "2020-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "connectorName": _SERIALIZER.url("connector_name", connector_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_delete_request(connector_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", "2020-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class ConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01_preview.SecurityCenter`'s - :attr:`connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.ConnectorSetting"]: - """Cloud accounts connectors of a subscription. - - :return: An iterator like instance of either ConnectorSetting or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting] - :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._api_version or "2020-01-01-preview") - ) - cls: ClsType[_models.ConnectorSettingList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ConnectorSettingList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, connector_name: str, **kwargs: Any) -> _models.ConnectorSetting: - """Details of a specific cloud account connector. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :return: ConnectorSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - connector_name=connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ConnectorSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - connector_name: str, - connector_setting: _models.ConnectorSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ConnectorSetting: - """Create a cloud account connector or update an existing one. Connect to your cloud account. For - AWS, use either account credentials or role-based authentication. For GCP, use account - organization credentials. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :param connector_setting: Settings for the cloud account connector. Required. - :type connector_setting: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ConnectorSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - connector_name: str, - connector_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ConnectorSetting: - """Create a cloud account connector or update an existing one. Connect to your cloud account. For - AWS, use either account credentials or role-based authentication. For GCP, use account - organization credentials. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :param connector_setting: Settings for the cloud account connector. Required. - :type connector_setting: 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: ConnectorSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, connector_name: str, connector_setting: Union[_models.ConnectorSetting, IO[bytes]], **kwargs: Any - ) -> _models.ConnectorSetting: - """Create a cloud account connector or update an existing one. Connect to your cloud account. For - AWS, use either account credentials or role-based authentication. For GCP, use account - organization credentials. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :param connector_setting: Settings for the cloud account connector. Is either a - ConnectorSetting type or a IO[bytes] type. Required. - :type connector_setting: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting or - IO[bytes] - :return: ConnectorSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connector_setting, (IOBase, bytes)): - _content = connector_setting - else: - _json = self._serialize.body(connector_setting, "ConnectorSetting") - - _request = build_create_or_update_request( - connector_name=connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ConnectorSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete(self, connector_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete a cloud account connector from a subscription. - - :param connector_name: Name of the cloud account connector. Required. - :type connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - connector_name=connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_security_contacts_operations.py deleted file mode 100644 index 1a201f75af07..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_security_contacts_operations.py +++ /dev/null @@ -1,489 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2020-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(security_contact_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", "2020-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(security_contact_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", "2020-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_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_delete_request(security_contact_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", "2020-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class SecurityContactsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_01_01_preview.SecurityCenter`'s - :attr:`security_contacts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecurityContact"]: - """List all security contact configurations for the subscription. - - :return: An iterator like instance of either SecurityContact or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact] - :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._api_version or "2020-01-01-preview") - ) - cls: ClsType[_models.SecurityContactList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityContactList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, security_contact_name: str, **kwargs: Any) -> _models.SecurityContact: - """Get Default Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - _request = build_get_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - security_contact_name: str, - security_contact: _models.SecurityContact, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Create security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - security_contact_name: str, - security_contact: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityContact: - """Create security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Required. - :type security_contact: 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: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, security_contact_name: str, security_contact: Union[_models.SecurityContact, IO[bytes]], **kwargs: Any - ) -> _models.SecurityContact: - """Create security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :param security_contact: Security contact object. Is either a SecurityContact type or a - IO[bytes] type. Required. - :type security_contact: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact or - IO[bytes] - :return: SecurityContact or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_contact, (IOBase, bytes)): - _content = security_contact - else: - _json = self._serialize.body(security_contact, "SecurityContact") - - _request = build_create_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityContact", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, security_contact_name: str, **kwargs: Any - ) -> None: - """Delete security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. Required. - :type security_contact_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - security_contact_name=security_contact_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_configuration.py deleted file mode 100644 index ab9313cf5ff5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2020-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_metadata.json deleted file mode 100644 index 6f17ca10a254..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_metadata.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "chosen_version": "2020-07-01-preview", - "total_api_version_list": ["2020-07-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "sql_vulnerability_assessment_baseline_rules": "SqlVulnerabilityAssessmentBaselineRulesOperations", - "sql_vulnerability_assessment_scans": "SqlVulnerabilityAssessmentScansOperations", - "sql_vulnerability_assessment_scan_results": "SqlVulnerabilityAssessmentScanResultsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_security_center.py deleted file mode 100644 index 8bf1a6399f6d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_security_center.py +++ /dev/null @@ -1,122 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - SqlVulnerabilityAssessmentBaselineRulesOperations, - SqlVulnerabilityAssessmentScanResultsOperations, - SqlVulnerabilityAssessmentScansOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar sql_vulnerability_assessment_baseline_rules: - SqlVulnerabilityAssessmentBaselineRulesOperations operations - :vartype sql_vulnerability_assessment_baseline_rules: - azure.mgmt.security.v2020_07_01_preview.operations.SqlVulnerabilityAssessmentBaselineRulesOperations - :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations - :vartype sql_vulnerability_assessment_scans: - azure.mgmt.security.v2020_07_01_preview.operations.SqlVulnerabilityAssessmentScansOperations - :ivar sql_vulnerability_assessment_scan_results: - SqlVulnerabilityAssessmentScanResultsOperations operations - :vartype sql_vulnerability_assessment_scan_results: - azure.mgmt.security.v2020_07_01_preview.operations.SqlVulnerabilityAssessmentScanResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" - ) - self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" - ) - self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_configuration.py deleted file mode 100644 index b61cf1282b08..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2020-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_security_center.py deleted file mode 100644 index a2c246ebf205..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_security_center.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - SqlVulnerabilityAssessmentBaselineRulesOperations, - SqlVulnerabilityAssessmentScanResultsOperations, - SqlVulnerabilityAssessmentScansOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar sql_vulnerability_assessment_baseline_rules: - SqlVulnerabilityAssessmentBaselineRulesOperations operations - :vartype sql_vulnerability_assessment_baseline_rules: - azure.mgmt.security.v2020_07_01_preview.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations - :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations - :vartype sql_vulnerability_assessment_scans: - azure.mgmt.security.v2020_07_01_preview.aio.operations.SqlVulnerabilityAssessmentScansOperations - :ivar sql_vulnerability_assessment_scan_results: - SqlVulnerabilityAssessmentScanResultsOperations operations - :vartype sql_vulnerability_assessment_scan_results: - azure.mgmt.security.v2020_07_01_preview.aio.operations.SqlVulnerabilityAssessmentScanResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" - ) - self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" - ) - self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/__init__.py deleted file mode 100644 index 8bc01846fbe0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations -from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations -from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SqlVulnerabilityAssessmentBaselineRulesOperations", - "SqlVulnerabilityAssessmentScansOperations", - "SqlVulnerabilityAssessmentScanResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py deleted file mode 100644 index 49859e71f70e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ /dev/null @@ -1,528 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._sql_vulnerability_assessment_baseline_rules_operations import ( - build_add_request, - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SqlVulnerabilityAssessmentBaselineRulesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_07_01_preview.aio.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_baseline_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[_models.RuleResultsInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. Default value is None. - :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResultsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. 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: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[Union[_models.RuleResultsInput, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. Is either a RuleResultsInput type or a - IO[bytes] type. Default value is None. - :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResultsInput or IO[bytes] - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RuleResultsInput") - else: - _json = None - - _request = build_create_or_update_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RuleResults: - """Gets the results for a given rule in the Baseline. - - Gets the results for a given rule in the Baseline. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) - - _request = build_get_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any - ) -> None: - """Deletes a rule from the Baseline of a given database. - - Deletes a rule from the Baseline of a given database. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RulesResults: - """Gets the results for all rules in the Baseline. - - Gets the results for all rules in the Baseline. - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RulesResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[_models.RulesResultsInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. Default value is None. - :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResultsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. 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: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[Union[_models.RulesResultsInput, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. Is either a RulesResultsInput type or a IO[bytes] type. - Default value is None. - :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResultsInput or IO[bytes] - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RulesResultsInput") - else: - _json = None - - _request = build_add_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RulesResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py deleted file mode 100644 index 1afe7abbb6fd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py +++ /dev/null @@ -1,186 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._sql_vulnerability_assessment_scan_results_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SqlVulnerabilityAssessmentScanResultsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_07_01_preview.aio.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_scan_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, scan_id: str, scan_result_id: str, workspace_id: str, resource_id: str, **kwargs: Any - ) -> _models.ScanResult: - """Gets the scan results of a single rule in a scan record. - - Gets the scan results of a single rule in a scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. - Required. - :type scan_id: str - :param scan_result_id: The rule Id of the results. Required. - :type scan_result_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: ScanResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.ScanResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) - - _request = build_get_request( - scan_id=scan_id, - scan_result_id=scan_result_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScanResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.ScanResults: - """Gets a list of scan results for a single scan record. - - Gets a list of scan results for a single scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. - Required. - :type scan_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: ScanResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.ScanResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) - - _request = build_list_request( - scan_id=scan_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScanResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py deleted file mode 100644 index 3646f306a54d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,177 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._sql_vulnerability_assessment_scans_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_07_01_preview.aio.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: - """Gets the scan details of a single scan record. - - Gets the scan details of a single scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan record for the latest scan. - Required. - :type scan_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: Scan or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.Scan - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.Scan] = kwargs.pop("cls", None) - - _request = build_get_request( - scan_id=scan_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Scan", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scans: - """Gets a list of scan records. - - Gets a list of scan records. - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: Scans or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.Scans - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.Scans] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Scans", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/__init__.py deleted file mode 100644 index f92a3a9e77b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/__init__.py +++ /dev/null @@ -1,67 +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 ._models_py3 import Baseline -from ._models_py3 import BaselineAdjustedResult -from ._models_py3 import BenchmarkReference -from ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import QueryCheck -from ._models_py3 import Remediation -from ._models_py3 import Resource -from ._models_py3 import RuleResults -from ._models_py3 import RuleResultsInput -from ._models_py3 import RuleResultsProperties -from ._models_py3 import RulesResults -from ._models_py3 import RulesResultsInput -from ._models_py3 import Scan -from ._models_py3 import ScanProperties -from ._models_py3 import ScanResult -from ._models_py3 import ScanResultProperties -from ._models_py3 import ScanResults -from ._models_py3 import Scans -from ._models_py3 import VaRule - -from ._security_center_enums import RuleSeverity -from ._security_center_enums import RuleStatus -from ._security_center_enums import RuleType -from ._security_center_enums import ScanState -from ._security_center_enums import ScanTriggerType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Baseline", - "BaselineAdjustedResult", - "BenchmarkReference", - "CloudErrorBody", - "ErrorAdditionalInfo", - "QueryCheck", - "Remediation", - "Resource", - "RuleResults", - "RuleResultsInput", - "RuleResultsProperties", - "RulesResults", - "RulesResultsInput", - "Scan", - "ScanProperties", - "ScanResult", - "ScanResultProperties", - "ScanResults", - "Scans", - "VaRule", - "RuleSeverity", - "RuleStatus", - "RuleType", - "ScanState", - "ScanTriggerType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_models_py3.py deleted file mode 100644 index 1c208f07adb8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_models_py3.py +++ /dev/null @@ -1,840 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Baseline(_serialization.Model): - """Baseline details. - - :ivar expected_results: Expected results. - :vartype expected_results: list[list[str]] - :ivar updated_time: Baseline update time (UTC). - :vartype updated_time: ~datetime.datetime - """ - - _attribute_map = { - "expected_results": {"key": "expectedResults", "type": "[[str]]"}, - "updated_time": {"key": "updatedTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - expected_results: Optional[List[List[str]]] = None, - updated_time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword expected_results: Expected results. - :paramtype expected_results: list[list[str]] - :keyword updated_time: Baseline update time (UTC). - :paramtype updated_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.expected_results = expected_results - self.updated_time = updated_time - - -class BaselineAdjustedResult(_serialization.Model): - """The rule result adjusted with baseline. - - :ivar baseline: Baseline details. - :vartype baseline: ~azure.mgmt.security.v2020_07_01_preview.models.Baseline - :ivar status: The rule result status. Known values are: "NonFinding", "Finding", and - "InternalError". - :vartype status: str or ~azure.mgmt.security.v2020_07_01_preview.models.RuleStatus - :ivar results_not_in_baseline: Results the are not in baseline. - :vartype results_not_in_baseline: list[list[str]] - :ivar results_only_in_baseline: Results the are in baseline. - :vartype results_only_in_baseline: list[list[str]] - """ - - _attribute_map = { - "baseline": {"key": "baseline", "type": "Baseline"}, - "status": {"key": "status", "type": "str"}, - "results_not_in_baseline": {"key": "resultsNotInBaseline", "type": "[[str]]"}, - "results_only_in_baseline": {"key": "resultsOnlyInBaseline", "type": "[[str]]"}, - } - - def __init__( - self, - *, - baseline: Optional["_models.Baseline"] = None, - status: Optional[Union[str, "_models.RuleStatus"]] = None, - results_not_in_baseline: Optional[List[List[str]]] = None, - results_only_in_baseline: Optional[List[List[str]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword baseline: Baseline details. - :paramtype baseline: ~azure.mgmt.security.v2020_07_01_preview.models.Baseline - :keyword status: The rule result status. Known values are: "NonFinding", "Finding", and - "InternalError". - :paramtype status: str or ~azure.mgmt.security.v2020_07_01_preview.models.RuleStatus - :keyword results_not_in_baseline: Results the are not in baseline. - :paramtype results_not_in_baseline: list[list[str]] - :keyword results_only_in_baseline: Results the are in baseline. - :paramtype results_only_in_baseline: list[list[str]] - """ - super().__init__(**kwargs) - self.baseline = baseline - self.status = status - self.results_not_in_baseline = results_not_in_baseline - self.results_only_in_baseline = results_only_in_baseline - - -class BenchmarkReference(_serialization.Model): - """The benchmark references. - - :ivar benchmark: The benchmark name. - :vartype benchmark: str - :ivar reference: The benchmark reference. - :vartype reference: str - """ - - _attribute_map = { - "benchmark": {"key": "benchmark", "type": "str"}, - "reference": {"key": "reference", "type": "str"}, - } - - def __init__(self, *, benchmark: Optional[str] = None, reference: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword benchmark: The benchmark name. - :paramtype benchmark: str - :keyword reference: The benchmark reference. - :paramtype reference: str - """ - super().__init__(**kwargs) - self.benchmark = benchmark - self.reference = reference - - -class CloudErrorBody(_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.security.v2020_07_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2020_07_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class QueryCheck(_serialization.Model): - """The rule query details. - - :ivar query: The rule query. - :vartype query: str - :ivar expected_result: Expected result. - :vartype expected_result: list[list[str]] - :ivar column_names: Column names of expected result. - :vartype column_names: list[str] - """ - - _attribute_map = { - "query": {"key": "query", "type": "str"}, - "expected_result": {"key": "expectedResult", "type": "[[str]]"}, - "column_names": {"key": "columnNames", "type": "[str]"}, - } - - def __init__( - self, - *, - query: Optional[str] = None, - expected_result: Optional[List[List[str]]] = None, - column_names: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword query: The rule query. - :paramtype query: str - :keyword expected_result: Expected result. - :paramtype expected_result: list[list[str]] - :keyword column_names: Column names of expected result. - :paramtype column_names: list[str] - """ - super().__init__(**kwargs) - self.query = query - self.expected_result = expected_result - self.column_names = column_names - - -class Remediation(_serialization.Model): - """Remediation details. - - :ivar description: Remediation description. - :vartype description: str - :ivar scripts: Remediation script. - :vartype scripts: list[str] - :ivar automated: Is remediation automated. - :vartype automated: bool - :ivar portal_link: Optional link to remediate in Azure Portal. - :vartype portal_link: str - """ - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "scripts": {"key": "scripts", "type": "[str]"}, - "automated": {"key": "automated", "type": "bool"}, - "portal_link": {"key": "portalLink", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - scripts: Optional[List[str]] = None, - automated: Optional[bool] = None, - portal_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Remediation description. - :paramtype description: str - :keyword scripts: Remediation script. - :paramtype scripts: list[str] - :keyword automated: Is remediation automated. - :paramtype automated: bool - :keyword portal_link: Optional link to remediate in Azure Portal. - :paramtype portal_link: str - """ - super().__init__(**kwargs) - self.description = description - self.scripts = scripts - self.automated = automated - self.portal_link = portal_link - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class RuleResults(Resource): - """Rule results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: Rule results properties. - :vartype properties: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResultsProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "RuleResultsProperties"}, - } - - def __init__(self, *, properties: Optional["_models.RuleResultsProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Rule results properties. - :paramtype properties: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResultsProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class RuleResultsInput(_serialization.Model): - """Rule results input. - - :ivar latest_scan: Take results from latest scan. - :vartype latest_scan: bool - :ivar results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :vartype results: list[list[str]] - """ - - _attribute_map = { - "latest_scan": {"key": "latestScan", "type": "bool"}, - "results": {"key": "results", "type": "[[str]]"}, - } - - def __init__( - self, *, latest_scan: Optional[bool] = None, results: Optional[List[List[str]]] = None, **kwargs: Any - ) -> None: - """ - :keyword latest_scan: Take results from latest scan. - :paramtype latest_scan: bool - :keyword results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :paramtype results: list[list[str]] - """ - super().__init__(**kwargs) - self.latest_scan = latest_scan - self.results = results - - -class RuleResultsProperties(_serialization.Model): - """Rule results properties. - - :ivar results: Expected results in the baseline. - :vartype results: list[list[str]] - """ - - _attribute_map = { - "results": {"key": "results", "type": "[[str]]"}, - } - - def __init__(self, *, results: Optional[List[List[str]]] = None, **kwargs: Any) -> None: - """ - :keyword results: Expected results in the baseline. - :paramtype results: list[list[str]] - """ - super().__init__(**kwargs) - self.results = results - - -class RulesResults(_serialization.Model): - """A list of rules results. - - :ivar value: List of rule results. - :vartype value: list[~azure.mgmt.security.v2020_07_01_preview.models.RuleResults] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RuleResults]"}, - } - - def __init__(self, *, value: Optional[List["_models.RuleResults"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of rule results. - :paramtype value: list[~azure.mgmt.security.v2020_07_01_preview.models.RuleResults] - """ - super().__init__(**kwargs) - self.value = value - - -class RulesResultsInput(_serialization.Model): - """Rules results input. - - :ivar latest_scan: Take results from latest scan. - :vartype latest_scan: bool - :ivar results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :vartype results: dict[str, list[list[str]]] - """ - - _attribute_map = { - "latest_scan": {"key": "latestScan", "type": "bool"}, - "results": {"key": "results", "type": "{[[str]]}"}, - } - - def __init__( - self, *, latest_scan: Optional[bool] = None, results: Optional[Dict[str, List[List[str]]]] = None, **kwargs: Any - ) -> None: - """ - :keyword latest_scan: Take results from latest scan. - :paramtype latest_scan: bool - :keyword results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :paramtype results: dict[str, list[list[str]]] - """ - super().__init__(**kwargs) - self.latest_scan = latest_scan - self.results = results - - -class Scan(Resource): - """A vulnerability assessment scan record. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: A vulnerability assessment scan record properties. - :vartype properties: ~azure.mgmt.security.v2020_07_01_preview.models.ScanProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "ScanProperties"}, - } - - def __init__(self, *, properties: Optional["_models.ScanProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: A vulnerability assessment scan record properties. - :paramtype properties: ~azure.mgmt.security.v2020_07_01_preview.models.ScanProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class ScanProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """A vulnerability assessment scan record properties. - - :ivar trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". - :vartype trigger_type: str or ~azure.mgmt.security.v2020_07_01_preview.models.ScanTriggerType - :ivar state: The scan status. Known values are: "Failed", "FailedToRun", "InProgress", and - "Passed". - :vartype state: str or ~azure.mgmt.security.v2020_07_01_preview.models.ScanState - :ivar server: The server name. - :vartype server: str - :ivar database: The database name. - :vartype database: str - :ivar sql_version: The SQL version. - :vartype sql_version: str - :ivar start_time: The scan start time (UTC). - :vartype start_time: ~datetime.datetime - :ivar end_time: Scan results are valid until end time (UTC). - :vartype end_time: ~datetime.datetime - :ivar high_severity_failed_rules_count: The number of failed rules with high severity. - :vartype high_severity_failed_rules_count: int - :ivar medium_severity_failed_rules_count: The number of failed rules with medium severity. - :vartype medium_severity_failed_rules_count: int - :ivar low_severity_failed_rules_count: The number of failed rules with low severity. - :vartype low_severity_failed_rules_count: int - :ivar total_passed_rules_count: The number of total passed rules. - :vartype total_passed_rules_count: int - :ivar total_failed_rules_count: The number of total failed rules. - :vartype total_failed_rules_count: int - :ivar total_rules_count: The number of total rules assessed. - :vartype total_rules_count: int - :ivar is_baseline_applied: Baseline created for this database, and has one or more rules. - :vartype is_baseline_applied: bool - """ - - _attribute_map = { - "trigger_type": {"key": "triggerType", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "server": {"key": "server", "type": "str"}, - "database": {"key": "database", "type": "str"}, - "sql_version": {"key": "sqlVersion", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "high_severity_failed_rules_count": {"key": "highSeverityFailedRulesCount", "type": "int"}, - "medium_severity_failed_rules_count": {"key": "mediumSeverityFailedRulesCount", "type": "int"}, - "low_severity_failed_rules_count": {"key": "lowSeverityFailedRulesCount", "type": "int"}, - "total_passed_rules_count": {"key": "totalPassedRulesCount", "type": "int"}, - "total_failed_rules_count": {"key": "totalFailedRulesCount", "type": "int"}, - "total_rules_count": {"key": "totalRulesCount", "type": "int"}, - "is_baseline_applied": {"key": "isBaselineApplied", "type": "bool"}, - } - - def __init__( - self, - *, - trigger_type: Optional[Union[str, "_models.ScanTriggerType"]] = None, - state: Optional[Union[str, "_models.ScanState"]] = None, - server: Optional[str] = None, - database: Optional[str] = None, - sql_version: Optional[str] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - high_severity_failed_rules_count: Optional[int] = None, - medium_severity_failed_rules_count: Optional[int] = None, - low_severity_failed_rules_count: Optional[int] = None, - total_passed_rules_count: Optional[int] = None, - total_failed_rules_count: Optional[int] = None, - total_rules_count: Optional[int] = None, - is_baseline_applied: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". - :paramtype trigger_type: str or ~azure.mgmt.security.v2020_07_01_preview.models.ScanTriggerType - :keyword state: The scan status. Known values are: "Failed", "FailedToRun", "InProgress", and - "Passed". - :paramtype state: str or ~azure.mgmt.security.v2020_07_01_preview.models.ScanState - :keyword server: The server name. - :paramtype server: str - :keyword database: The database name. - :paramtype database: str - :keyword sql_version: The SQL version. - :paramtype sql_version: str - :keyword start_time: The scan start time (UTC). - :paramtype start_time: ~datetime.datetime - :keyword end_time: Scan results are valid until end time (UTC). - :paramtype end_time: ~datetime.datetime - :keyword high_severity_failed_rules_count: The number of failed rules with high severity. - :paramtype high_severity_failed_rules_count: int - :keyword medium_severity_failed_rules_count: The number of failed rules with medium severity. - :paramtype medium_severity_failed_rules_count: int - :keyword low_severity_failed_rules_count: The number of failed rules with low severity. - :paramtype low_severity_failed_rules_count: int - :keyword total_passed_rules_count: The number of total passed rules. - :paramtype total_passed_rules_count: int - :keyword total_failed_rules_count: The number of total failed rules. - :paramtype total_failed_rules_count: int - :keyword total_rules_count: The number of total rules assessed. - :paramtype total_rules_count: int - :keyword is_baseline_applied: Baseline created for this database, and has one or more rules. - :paramtype is_baseline_applied: bool - """ - super().__init__(**kwargs) - self.trigger_type = trigger_type - self.state = state - self.server = server - self.database = database - self.sql_version = sql_version - self.start_time = start_time - self.end_time = end_time - self.high_severity_failed_rules_count = high_severity_failed_rules_count - self.medium_severity_failed_rules_count = medium_severity_failed_rules_count - self.low_severity_failed_rules_count = low_severity_failed_rules_count - self.total_passed_rules_count = total_passed_rules_count - self.total_failed_rules_count = total_failed_rules_count - self.total_rules_count = total_rules_count - self.is_baseline_applied = is_baseline_applied - - -class ScanResult(Resource): - """A vulnerability assessment scan result for a single rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: A vulnerability assessment scan result properties for a single rule. - :vartype properties: ~azure.mgmt.security.v2020_07_01_preview.models.ScanResultProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "ScanResultProperties"}, - } - - def __init__(self, *, properties: Optional["_models.ScanResultProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: A vulnerability assessment scan result properties for a single rule. - :paramtype properties: ~azure.mgmt.security.v2020_07_01_preview.models.ScanResultProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class ScanResultProperties(_serialization.Model): - """A vulnerability assessment scan result properties for a single rule. - - :ivar rule_id: The rule Id. - :vartype rule_id: str - :ivar status: The rule result status. Known values are: "NonFinding", "Finding", and - "InternalError". - :vartype status: str or ~azure.mgmt.security.v2020_07_01_preview.models.RuleStatus - :ivar is_trimmed: Indicated whether the results specified here are trimmed. - :vartype is_trimmed: bool - :ivar query_results: The results of the query that was run. - :vartype query_results: list[list[str]] - :ivar remediation: Remediation details. - :vartype remediation: ~azure.mgmt.security.v2020_07_01_preview.models.Remediation - :ivar baseline_adjusted_result: The rule result adjusted with baseline. - :vartype baseline_adjusted_result: - ~azure.mgmt.security.v2020_07_01_preview.models.BaselineAdjustedResult - :ivar rule_metadata: vulnerability assessment rule metadata details. - :vartype rule_metadata: ~azure.mgmt.security.v2020_07_01_preview.models.VaRule - """ - - _attribute_map = { - "rule_id": {"key": "ruleId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "is_trimmed": {"key": "isTrimmed", "type": "bool"}, - "query_results": {"key": "queryResults", "type": "[[str]]"}, - "remediation": {"key": "remediation", "type": "Remediation"}, - "baseline_adjusted_result": {"key": "baselineAdjustedResult", "type": "BaselineAdjustedResult"}, - "rule_metadata": {"key": "ruleMetadata", "type": "VaRule"}, - } - - def __init__( - self, - *, - rule_id: Optional[str] = None, - status: Optional[Union[str, "_models.RuleStatus"]] = None, - is_trimmed: Optional[bool] = None, - query_results: Optional[List[List[str]]] = None, - remediation: Optional["_models.Remediation"] = None, - baseline_adjusted_result: Optional["_models.BaselineAdjustedResult"] = None, - rule_metadata: Optional["_models.VaRule"] = None, - **kwargs: Any - ) -> None: - """ - :keyword rule_id: The rule Id. - :paramtype rule_id: str - :keyword status: The rule result status. Known values are: "NonFinding", "Finding", and - "InternalError". - :paramtype status: str or ~azure.mgmt.security.v2020_07_01_preview.models.RuleStatus - :keyword is_trimmed: Indicated whether the results specified here are trimmed. - :paramtype is_trimmed: bool - :keyword query_results: The results of the query that was run. - :paramtype query_results: list[list[str]] - :keyword remediation: Remediation details. - :paramtype remediation: ~azure.mgmt.security.v2020_07_01_preview.models.Remediation - :keyword baseline_adjusted_result: The rule result adjusted with baseline. - :paramtype baseline_adjusted_result: - ~azure.mgmt.security.v2020_07_01_preview.models.BaselineAdjustedResult - :keyword rule_metadata: vulnerability assessment rule metadata details. - :paramtype rule_metadata: ~azure.mgmt.security.v2020_07_01_preview.models.VaRule - """ - super().__init__(**kwargs) - self.rule_id = rule_id - self.status = status - self.is_trimmed = is_trimmed - self.query_results = query_results - self.remediation = remediation - self.baseline_adjusted_result = baseline_adjusted_result - self.rule_metadata = rule_metadata - - -class ScanResults(_serialization.Model): - """A list of vulnerability assessment scan results. - - :ivar value: List of vulnerability assessment scan results. - :vartype value: list[~azure.mgmt.security.v2020_07_01_preview.models.ScanResult] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ScanResult]"}, - } - - def __init__(self, *, value: Optional[List["_models.ScanResult"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of vulnerability assessment scan results. - :paramtype value: list[~azure.mgmt.security.v2020_07_01_preview.models.ScanResult] - """ - super().__init__(**kwargs) - self.value = value - - -class Scans(_serialization.Model): - """A list of vulnerability assessment scan records. - - :ivar value: List of vulnerability assessment scan records. - :vartype value: list[~azure.mgmt.security.v2020_07_01_preview.models.Scan] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Scan]"}, - } - - def __init__(self, *, value: Optional[List["_models.Scan"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of vulnerability assessment scan records. - :paramtype value: list[~azure.mgmt.security.v2020_07_01_preview.models.Scan] - """ - super().__init__(**kwargs) - self.value = value - - -class VaRule(_serialization.Model): - """vulnerability assessment rule metadata details. - - :ivar rule_id: The rule Id. - :vartype rule_id: str - :ivar severity: The rule severity. Known values are: "High", "Medium", "Low", "Informational", - and "Obsolete". - :vartype severity: str or ~azure.mgmt.security.v2020_07_01_preview.models.RuleSeverity - :ivar category: The rule category. - :vartype category: str - :ivar rule_type: The rule type. Known values are: "Binary", "BaselineExpected", "PositiveList", - and "NegativeList". - :vartype rule_type: str or ~azure.mgmt.security.v2020_07_01_preview.models.RuleType - :ivar title: The rule title. - :vartype title: str - :ivar description: The rule description. - :vartype description: str - :ivar rationale: The rule rationale. - :vartype rationale: str - :ivar query_check: The rule query details. - :vartype query_check: ~azure.mgmt.security.v2020_07_01_preview.models.QueryCheck - :ivar benchmark_references: The benchmark references. - :vartype benchmark_references: - list[~azure.mgmt.security.v2020_07_01_preview.models.BenchmarkReference] - """ - - _attribute_map = { - "rule_id": {"key": "ruleId", "type": "str"}, - "severity": {"key": "severity", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "rationale": {"key": "rationale", "type": "str"}, - "query_check": {"key": "queryCheck", "type": "QueryCheck"}, - "benchmark_references": {"key": "benchmarkReferences", "type": "[BenchmarkReference]"}, - } - - def __init__( - self, - *, - rule_id: Optional[str] = None, - severity: Optional[Union[str, "_models.RuleSeverity"]] = None, - category: Optional[str] = None, - rule_type: Optional[Union[str, "_models.RuleType"]] = None, - title: Optional[str] = None, - description: Optional[str] = None, - rationale: Optional[str] = None, - query_check: Optional["_models.QueryCheck"] = None, - benchmark_references: Optional[List["_models.BenchmarkReference"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword rule_id: The rule Id. - :paramtype rule_id: str - :keyword severity: The rule severity. Known values are: "High", "Medium", "Low", - "Informational", and "Obsolete". - :paramtype severity: str or ~azure.mgmt.security.v2020_07_01_preview.models.RuleSeverity - :keyword category: The rule category. - :paramtype category: str - :keyword rule_type: The rule type. Known values are: "Binary", "BaselineExpected", - "PositiveList", and "NegativeList". - :paramtype rule_type: str or ~azure.mgmt.security.v2020_07_01_preview.models.RuleType - :keyword title: The rule title. - :paramtype title: str - :keyword description: The rule description. - :paramtype description: str - :keyword rationale: The rule rationale. - :paramtype rationale: str - :keyword query_check: The rule query details. - :paramtype query_check: ~azure.mgmt.security.v2020_07_01_preview.models.QueryCheck - :keyword benchmark_references: The benchmark references. - :paramtype benchmark_references: - list[~azure.mgmt.security.v2020_07_01_preview.models.BenchmarkReference] - """ - super().__init__(**kwargs) - self.rule_id = rule_id - self.severity = severity - self.category = category - self.rule_type = rule_type - self.title = title - self.description = description - self.rationale = rationale - self.query_check = query_check - self.benchmark_references = benchmark_references diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_security_center_enums.py deleted file mode 100644 index a75012e95df4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,71 +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 RuleSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rule severity.""" - - HIGH = "High" - """High""" - MEDIUM = "Medium" - """Medium""" - LOW = "Low" - """Low""" - INFORMATIONAL = "Informational" - """Informational""" - OBSOLETE = "Obsolete" - """Obsolete""" - - -class RuleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rule result status.""" - - NON_FINDING = "NonFinding" - """NonFinding""" - FINDING = "Finding" - """Finding""" - INTERNAL_ERROR = "InternalError" - """InternalError""" - - -class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rule type.""" - - BINARY = "Binary" - """Binary""" - BASELINE_EXPECTED = "BaselineExpected" - """BaselineExpected""" - POSITIVE_LIST = "PositiveList" - """PositiveList""" - NEGATIVE_LIST = "NegativeList" - """NegativeList""" - - -class ScanState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scan status.""" - - FAILED = "Failed" - """Failed""" - FAILED_TO_RUN = "FailedToRun" - """FailedToRun""" - IN_PROGRESS = "InProgress" - """InProgress""" - PASSED = "Passed" - """Passed""" - - -class ScanTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scan trigger type.""" - - ON_DEMAND = "OnDemand" - """OnDemand""" - RECURRING = "Recurring" - """Recurring""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/__init__.py deleted file mode 100644 index 8bc01846fbe0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations -from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations -from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SqlVulnerabilityAssessmentBaselineRulesOperations", - "SqlVulnerabilityAssessmentScansOperations", - "SqlVulnerabilityAssessmentScanResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py deleted file mode 100644 index 529c08d706aa..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ /dev/null @@ -1,672 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request(rule_id: str, resource_id: str, *, workspace_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", "2020-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(rule_id: str, resource_id: str, *, workspace_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", "2020-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(rule_id: str, resource_id: str, *, workspace_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", "2020-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(resource_id: str, *, workspace_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", "2020-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _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_add_request(resource_id: str, *, workspace_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", "2020-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class SqlVulnerabilityAssessmentBaselineRulesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_07_01_preview.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_baseline_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[_models.RuleResultsInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. Default value is None. - :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResultsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. 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: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[Union[_models.RuleResultsInput, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. Is either a RuleResultsInput type or a - IO[bytes] type. Default value is None. - :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResultsInput or IO[bytes] - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RuleResultsInput") - else: - _json = None - - _request = build_create_or_update_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RuleResults: - """Gets the results for a given rule in the Baseline. - - Gets the results for a given rule in the Baseline. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) - - _request = build_get_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any - ) -> None: - """Deletes a rule from the Baseline of a given database. - - Deletes a rule from the Baseline of a given database. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RulesResults: - """Gets the results for all rules in the Baseline. - - Gets the results for all rules in the Baseline. - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RulesResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[_models.RulesResultsInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. Default value is None. - :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResultsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. 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: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[Union[_models.RulesResultsInput, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. Is either a RulesResultsInput type or a IO[bytes] type. - Default value is None. - :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResultsInput or IO[bytes] - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RulesResultsInput") - else: - _json = None - - _request = build_add_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RulesResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py deleted file mode 100644 index e399139c92f8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py +++ /dev/null @@ -1,250 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - scan_id: str, scan_result_id: str, resource_id: str, *, workspace_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", "2020-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults/{scanResultId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "scanResultId": _SERIALIZER.url("scan_result_id", scan_result_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(scan_id: str, resource_id: str, *, workspace_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", "2020-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _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 SqlVulnerabilityAssessmentScanResultsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_07_01_preview.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_scan_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, scan_id: str, scan_result_id: str, workspace_id: str, resource_id: str, **kwargs: Any - ) -> _models.ScanResult: - """Gets the scan results of a single rule in a scan record. - - Gets the scan results of a single rule in a scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. - Required. - :type scan_id: str - :param scan_result_id: The rule Id of the results. Required. - :type scan_result_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: ScanResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.ScanResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) - - _request = build_get_request( - scan_id=scan_id, - scan_result_id=scan_result_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScanResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.ScanResults: - """Gets a list of scan results for a single scan record. - - Gets a list of scan results for a single scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. - Required. - :type scan_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: ScanResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.ScanResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) - - _request = build_list_request( - scan_id=scan_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScanResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py deleted file mode 100644 index 34710802a38a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,235 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(scan_id: str, resource_id: str, *, workspace_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", "2020-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(resource_id: str, *, workspace_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", "2020-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans" - ) - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _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 SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2020_07_01_preview.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: - """Gets the scan details of a single scan record. - - Gets the scan details of a single scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan record for the latest scan. - Required. - :type scan_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: Scan or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.Scan - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.Scan] = kwargs.pop("cls", None) - - _request = build_get_request( - scan_id=scan_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Scan", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scans: - """Gets a list of scan records. - - Gets a list of scan records. - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: Scans or the result of cls(response) - :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.Scans - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") - ) - cls: ClsType[_models.Scans] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Scans", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_configuration.py deleted file mode 100644 index 50e21dd4294f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_metadata.json deleted file mode 100644 index cb3dcc820e6a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2021-01-01", - "total_api_version_list": ["2021-01-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "alerts": "AlertsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_security_center.py deleted file mode 100644 index d46d33468df9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_security_center.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import AlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar alerts: AlertsOperations operations - :vartype alerts: azure.mgmt.security.v2021_01_01.operations.AlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-01-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_configuration.py deleted file mode 100644 index f059bb236f3e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_security_center.py deleted file mode 100644 index 3f7048750a26..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_security_center.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import AlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar alerts: AlertsOperations operations - :vartype alerts: azure.mgmt.security.v2021_01_01.aio.operations.AlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-01-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/__init__.py deleted file mode 100644 index b3a334939bbd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._alerts_operations import AlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_alerts_operations.py deleted file mode 100644 index 7e0d2a752904..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_alerts_operations.py +++ /dev/null @@ -1,1024 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._alerts_operations import ( - build_get_resource_group_level_request, - build_get_subscription_level_request, - build_list_by_resource_group_request, - build_list_request, - build_list_resource_group_level_by_region_request, - build_list_subscription_level_by_region_request, - build_simulate_request, - build_update_resource_group_level_state_to_activate_request, - build_update_resource_group_level_state_to_dismiss_request, - build_update_resource_group_level_state_to_resolve_request, - build_update_subscription_level_state_to_activate_request, - build_update_subscription_level_state_to_dismiss_request, - build_update_subscription_level_state_to_resolve_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_01_01.aio.SecurityCenter`'s - :attr:`alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Alert"]: - """List all the alerts that are associated with the subscription. - - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_01_01.models.Alert] - :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._api_version or "2021-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Alert"]: - """List all the alerts that are associated with the resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_01_01.models.Alert] - :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._api_version or "2021-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> AsyncIterable["_models.Alert"]: - """List all the alerts that are associated with the subscription that are stored in a specific - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_01_01.models.Alert] - :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._api_version or "2021-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_subscription_level_by_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_resource_group_level_by_region( - self, asc_location: str, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Alert"]: - """List all the alerts that are associated with the resource group that are stored in a specific - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_01_01.models.Alert] - :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._api_version or "2021-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_group_level_by_region_request( - asc_location=asc_location, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: Any) -> _models.Alert: - """Get an alert that is associated with a subscription. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_01_01.models.Alert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - - _request = build_get_subscription_level_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Alert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_resource_group_level( - self, asc_location: str, alert_name: str, resource_group_name: str, **kwargs: Any - ) -> _models.Alert: - """Get an alert that is associated a resource group or a resource in a resource group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_01_01.models.Alert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - - _request = build_get_resource_group_level_request( - asc_location=asc_location, - alert_name=alert_name, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Alert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_dismiss_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_resolve_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_subscription_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_activate_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_resource_group_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_resolve_request( - asc_location=asc_location, - alert_name=alert_name, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_dismiss_request( - asc_location=asc_location, - alert_name=alert_name, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_resource_group_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_activate_request( - asc_location=asc_location, - alert_name=alert_name, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - async def _simulate_initial( # pylint: disable=inconsistent-return-statements - self, - asc_location: str, - alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], - **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_simulator_request_body, (IOBase, bytes)): - _content = alert_simulator_request_body - else: - _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") - - _request = build_simulate_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: _models.AlertSimulatorRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Required. - :type alert_simulator_request_body: - ~azure.mgmt.security.v2021_01_01.models.AlertSimulatorRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Required. - :type alert_simulator_request_body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Is either a - AlertSimulatorRequestBody type or a IO[bytes] type. Required. - :type alert_simulator_request_body: - ~azure.mgmt.security.v2021_01_01.models.AlertSimulatorRequestBody or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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._api_version or "2021-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._simulate_initial( # type: ignore - asc_location=asc_location, - alert_simulator_request_body=alert_simulator_request_body, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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": "original-uri"}, **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/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/__init__.py deleted file mode 100644 index f0a4dbee8e8f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/__init__.py +++ /dev/null @@ -1,53 +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 ._models_py3 import Alert -from ._models_py3 import AlertEntity -from ._models_py3 import AlertList -from ._models_py3 import AlertSimulatorBundlesRequestProperties -from ._models_py3 import AlertSimulatorRequestBody -from ._models_py3 import AlertSimulatorRequestProperties -from ._models_py3 import AzureResourceIdentifier -from ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import LogAnalyticsIdentifier -from ._models_py3 import Resource -from ._models_py3 import ResourceIdentifier - -from ._security_center_enums import AlertSeverity -from ._security_center_enums import AlertStatus -from ._security_center_enums import BundleType -from ._security_center_enums import Intent -from ._security_center_enums import KindEnum -from ._security_center_enums import ResourceIdentifierType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Alert", - "AlertEntity", - "AlertList", - "AlertSimulatorBundlesRequestProperties", - "AlertSimulatorRequestBody", - "AlertSimulatorRequestProperties", - "AzureResourceIdentifier", - "CloudErrorBody", - "ErrorAdditionalInfo", - "LogAnalyticsIdentifier", - "Resource", - "ResourceIdentifier", - "AlertSeverity", - "AlertStatus", - "BundleType", - "Intent", - "KindEnum", - "ResourceIdentifierType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_models_py3.py deleted file mode 100644 index f9dc8476bcb5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_models_py3.py +++ /dev/null @@ -1,570 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Alert(Resource): # pylint: disable=too-many-instance-attributes - """Security alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar alert_type: Unique identifier for the detection logic (all alert instances from the same - detection logic will have the same alertType). - :vartype alert_type: str - :ivar system_alert_id: Unique identifier for the alert. - :vartype system_alert_id: str - :ivar product_component_name: The name of Azure Security Center pricing tier which powering - this alert. Learn more: - https://docs.microsoft.com/en-us/azure/security-center/security-center-pricing. - :vartype product_component_name: str - :ivar alert_display_name: The display name of the alert. - :vartype alert_display_name: str - :ivar description: Description of the suspicious activity that was detected. - :vartype description: str - :ivar severity: The risk level of the threat that was detected. Learn more: - https://docs.microsoft.com/en-us/azure/security-center/security-center-alerts-overview#how-are-alerts-classified. - Known values are: "Informational", "Low", "Medium", and "High". - :vartype severity: str or ~azure.mgmt.security.v2021_01_01.models.AlertSeverity - :ivar intent: The kill chain related intent behind the alert. For list of supported values, and - explanations of Azure Security Center's supported kill chain intents. Known values are: - "Unknown", "PreAttack", "InitialAccess", "Persistence", "PrivilegeEscalation", - "DefenseEvasion", "CredentialAccess", "Discovery", "LateralMovement", "Execution", - "Collection", "Exfiltration", "CommandAndControl", "Impact", "Probing", and "Exploitation". - :vartype intent: str or ~azure.mgmt.security.v2021_01_01.models.Intent - :ivar start_time_utc: The UTC time of the first event or activity included in the alert in - ISO8601 format. - :vartype start_time_utc: ~datetime.datetime - :ivar end_time_utc: The UTC time of the last event or activity included in the alert in ISO8601 - format. - :vartype end_time_utc: ~datetime.datetime - :ivar resource_identifiers: The resource identifiers that can be used to direct the alert to - the right product exposure group (tenant, workspace, subscription etc.). There can be multiple - identifiers of different type per alert. - :vartype resource_identifiers: list[~azure.mgmt.security.v2021_01_01.models.ResourceIdentifier] - :ivar remediation_steps: Manual action items to take to remediate the alert. - :vartype remediation_steps: list[str] - :ivar vendor_name: The name of the vendor that raises the alert. - :vartype vendor_name: str - :ivar status: The life cycle status of the alert. Known values are: "Active", "Resolved", and - "Dismissed". - :vartype status: str or ~azure.mgmt.security.v2021_01_01.models.AlertStatus - :ivar extended_links: Links related to the alert. - :vartype extended_links: list[dict[str, str]] - :ivar alert_uri: A direct link to the alert page in Azure Portal. - :vartype alert_uri: str - :ivar time_generated_utc: The UTC time the alert was generated in ISO8601 format. - :vartype time_generated_utc: ~datetime.datetime - :ivar product_name: The name of the product which published this alert (Azure Security Center, - Azure ATP, Microsoft Defender ATP, O365 ATP, MCAS, and so on). - :vartype product_name: str - :ivar processing_end_time_utc: The UTC processing end time of the alert in ISO8601 format. - :vartype processing_end_time_utc: ~datetime.datetime - :ivar entities: A list of entities related to the alert. - :vartype entities: list[~azure.mgmt.security.v2021_01_01.models.AlertEntity] - :ivar is_incident: This field determines whether the alert is an incident (a compound grouping - of several alerts) or a single alert. - :vartype is_incident: bool - :ivar correlation_key: Key for corelating related alerts. Alerts with the same correlation key - considered to be related. - :vartype correlation_key: str - :ivar extended_properties: Custom properties for the alert. - :vartype extended_properties: dict[str, str] - :ivar compromised_entity: The display name of the resource most related to this alert. - :vartype compromised_entity: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "alert_type": {"readonly": True}, - "system_alert_id": {"readonly": True}, - "product_component_name": {"readonly": True}, - "alert_display_name": {"readonly": True}, - "description": {"readonly": True}, - "severity": {"readonly": True}, - "intent": {"readonly": True}, - "start_time_utc": {"readonly": True}, - "end_time_utc": {"readonly": True}, - "resource_identifiers": {"readonly": True}, - "remediation_steps": {"readonly": True}, - "vendor_name": {"readonly": True}, - "status": {"readonly": True}, - "extended_links": {"readonly": True}, - "alert_uri": {"readonly": True}, - "time_generated_utc": {"readonly": True}, - "product_name": {"readonly": True}, - "processing_end_time_utc": {"readonly": True}, - "entities": {"readonly": True}, - "is_incident": {"readonly": True}, - "correlation_key": {"readonly": True}, - "compromised_entity": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "alert_type": {"key": "properties.alertType", "type": "str"}, - "system_alert_id": {"key": "properties.systemAlertId", "type": "str"}, - "product_component_name": {"key": "properties.productComponentName", "type": "str"}, - "alert_display_name": {"key": "properties.alertDisplayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "severity": {"key": "properties.severity", "type": "str"}, - "intent": {"key": "properties.intent", "type": "str"}, - "start_time_utc": {"key": "properties.startTimeUtc", "type": "iso-8601"}, - "end_time_utc": {"key": "properties.endTimeUtc", "type": "iso-8601"}, - "resource_identifiers": {"key": "properties.resourceIdentifiers", "type": "[ResourceIdentifier]"}, - "remediation_steps": {"key": "properties.remediationSteps", "type": "[str]"}, - "vendor_name": {"key": "properties.vendorName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "extended_links": {"key": "properties.extendedLinks", "type": "[{str}]"}, - "alert_uri": {"key": "properties.alertUri", "type": "str"}, - "time_generated_utc": {"key": "properties.timeGeneratedUtc", "type": "iso-8601"}, - "product_name": {"key": "properties.productName", "type": "str"}, - "processing_end_time_utc": {"key": "properties.processingEndTimeUtc", "type": "iso-8601"}, - "entities": {"key": "properties.entities", "type": "[AlertEntity]"}, - "is_incident": {"key": "properties.isIncident", "type": "bool"}, - "correlation_key": {"key": "properties.correlationKey", "type": "str"}, - "extended_properties": {"key": "properties.extendedProperties", "type": "{str}"}, - "compromised_entity": {"key": "properties.compromisedEntity", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, *, extended_properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword extended_properties: Custom properties for the alert. - :paramtype extended_properties: dict[str, str] - """ - super().__init__(**kwargs) - self.alert_type = None - self.system_alert_id = None - self.product_component_name = None - self.alert_display_name = None - self.description = None - self.severity = None - self.intent = None - self.start_time_utc = None - self.end_time_utc = None - self.resource_identifiers = None - self.remediation_steps = None - self.vendor_name = None - self.status = None - self.extended_links = None - self.alert_uri = None - self.time_generated_utc = None - self.product_name = None - self.processing_end_time_utc = None - self.entities = None - self.is_incident = None - self.correlation_key = None - self.extended_properties = extended_properties - self.compromised_entity = None - - -class AlertEntity(_serialization.Model): - """Changing set of properties depending on the entity type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar type: Type of entity. - :vartype type: str - """ - - _validation = { - "type": {"readonly": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs: Any) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.type = None - - -class AlertList(_serialization.Model): - """List of security alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: describes security alert properties. - :vartype value: list[~azure.mgmt.security.v2021_01_01.models.Alert] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Alert]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Alert"]] = None, **kwargs: Any) -> None: - """ - :keyword value: describes security alert properties. - :paramtype value: list[~azure.mgmt.security.v2021_01_01.models.Alert] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class AlertSimulatorRequestProperties(_serialization.Model): - """Describes properties of an alert simulation request. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AlertSimulatorBundlesRequestProperties - - All required parameters must be populated in order to send to server. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar kind: The kind of alert simulation. Required. "Bundles" - :vartype kind: str or ~azure.mgmt.security.v2021_01_01.models.KindEnum - """ - - _validation = { - "kind": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "kind": {"key": "kind", "type": "str"}, - } - - _subtype_map = {"kind": {"Bundles": "AlertSimulatorBundlesRequestProperties"}} - - def __init__(self, *, additional_properties: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.kind: Optional[str] = None - - -class AlertSimulatorBundlesRequestProperties(AlertSimulatorRequestProperties): - """Simulate alerts according to this bundles. - - All required parameters must be populated in order to send to server. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar kind: The kind of alert simulation. Required. "Bundles" - :vartype kind: str or ~azure.mgmt.security.v2021_01_01.models.KindEnum - :ivar bundles: Bundles list. - :vartype bundles: list[str or ~azure.mgmt.security.v2021_01_01.models.BundleType] - """ - - _validation = { - "kind": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "kind": {"key": "kind", "type": "str"}, - "bundles": {"key": "bundles", "type": "[str]"}, - } - - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - bundles: Optional[List[Union[str, "_models.BundleType"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword bundles: Bundles list. - :paramtype bundles: list[str or ~azure.mgmt.security.v2021_01_01.models.BundleType] - """ - super().__init__(additional_properties=additional_properties, **kwargs) - self.kind: str = "Bundles" - self.bundles = bundles - - -class AlertSimulatorRequestBody(_serialization.Model): - """Alert Simulator request body. - - :ivar properties: Alert Simulator request body data. - :vartype properties: ~azure.mgmt.security.v2021_01_01.models.AlertSimulatorRequestProperties - """ - - _attribute_map = { - "properties": {"key": "properties", "type": "AlertSimulatorRequestProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.AlertSimulatorRequestProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Alert Simulator request body data. - :paramtype properties: ~azure.mgmt.security.v2021_01_01.models.AlertSimulatorRequestProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class ResourceIdentifier(_serialization.Model): - """A resource identifier for an alert which can be used to direct the alert to the right product - exposure group (tenant, workspace, subscription etc.). - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureResourceIdentifier, LogAnalyticsIdentifier - - All required parameters must be populated in order to send to server. - - :ivar type: There can be multiple identifiers of different type per alert, this field specify - the identifier type. Required. Known values are: "AzureResource" and "LogAnalytics". - :vartype type: str or ~azure.mgmt.security.v2021_01_01.models.ResourceIdentifierType - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - _subtype_map = {"type": {"AzureResource": "AzureResourceIdentifier", "LogAnalytics": "LogAnalyticsIdentifier"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - - -class AzureResourceIdentifier(ResourceIdentifier): - """Azure resource identifier. - - 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 type: There can be multiple identifiers of different type per alert, this field specify - the identifier type. Required. Known values are: "AzureResource" and "LogAnalytics". - :vartype type: str or ~azure.mgmt.security.v2021_01_01.models.ResourceIdentifierType - :ivar azure_resource_id: ARM resource identifier for the cloud resource being alerted on. - :vartype azure_resource_id: str - """ - - _validation = { - "type": {"required": True}, - "azure_resource_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "azure_resource_id": {"key": "azureResourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "AzureResource" - self.azure_resource_id = None - - -class CloudErrorBody(_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.security.v2021_01_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2021_01_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class LogAnalyticsIdentifier(ResourceIdentifier): - """Represents a Log Analytics workspace scope identifier. - - 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 type: There can be multiple identifiers of different type per alert, this field specify - the identifier type. Required. Known values are: "AzureResource" and "LogAnalytics". - :vartype type: str or ~azure.mgmt.security.v2021_01_01.models.ResourceIdentifierType - :ivar workspace_id: The LogAnalytics workspace id that stores this alert. - :vartype workspace_id: str - :ivar workspace_subscription_id: The azure subscription id for the LogAnalytics workspace - storing this alert. - :vartype workspace_subscription_id: str - :ivar workspace_resource_group: The azure resource group for the LogAnalytics workspace storing - this alert. - :vartype workspace_resource_group: str - :ivar agent_id: (optional) The LogAnalytics agent id reporting the event that this alert is - based on. - :vartype agent_id: str - """ - - _validation = { - "type": {"required": True}, - "workspace_id": {"readonly": True}, - "workspace_subscription_id": { - "readonly": True, - "pattern": r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", - }, - "workspace_resource_group": {"readonly": True}, - "agent_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "workspace_subscription_id": {"key": "workspaceSubscriptionId", "type": "str"}, - "workspace_resource_group": {"key": "workspaceResourceGroup", "type": "str"}, - "agent_id": {"key": "agentId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "LogAnalytics" - self.workspace_id = None - self.workspace_subscription_id = None - self.workspace_resource_group = None - self.agent_id = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_security_center_enums.py deleted file mode 100644 index 5a6c154a7f82..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_security_center_enums.py +++ /dev/null @@ -1,124 +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 AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The risk level of the threat that was detected. Learn more: - https://docs.microsoft.com/en-us/azure/security-center/security-center-alerts-overview#how-are-alerts-classified. - """ - - INFORMATIONAL = "Informational" - """Informational""" - LOW = "Low" - """Low""" - MEDIUM = "Medium" - """Medium""" - HIGH = "High" - """High""" - - -class AlertStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The life cycle status of the alert.""" - - ACTIVE = "Active" - """An alert which doesn't specify a value is assigned the status 'Active'""" - RESOLVED = "Resolved" - """Alert closed after handling""" - DISMISSED = "Dismissed" - """Alert dismissed as false positive""" - - -class BundleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Alert Simulator supported bundles.""" - - APP_SERVICES = "AppServices" - DNS = "DNS" - KEY_VAULTS = "KeyVaults" - KUBERNETES_SERVICE = "KubernetesService" - RESOURCE_MANAGER = "ResourceManager" - SQL_SERVERS = "SqlServers" - STORAGE_ACCOUNTS = "StorageAccounts" - VIRTUAL_MACHINES = "VirtualMachines" - - -class Intent(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kill chain related intent behind the alert. For list of supported values, and explanations - of Azure Security Center's supported kill chain intents. - """ - - UNKNOWN = "Unknown" - """Unknown""" - PRE_ATTACK = "PreAttack" - """PreAttack could be either an attempt to access a certain resource regardless of a malicious - intent, or a failed attempt to gain access to a target system to gather information prior to - exploitation. This step is usually detected as an attempt, originating from outside the - network, to scan the target system and find a way in. Further details on the PreAttack stage - can be read in `MITRE Pre-Att&ck matrix `_.""" - INITIAL_ACCESS = "InitialAccess" - """InitialAccess is the stage where an attacker manages to get foothold on the attacked resource.""" - PERSISTENCE = "Persistence" - """Persistence is any access, action, or configuration change to a system that gives a threat - actor a persistent presence on that system.""" - PRIVILEGE_ESCALATION = "PrivilegeEscalation" - """Privilege escalation is the result of actions that allow an adversary to obtain a higher level - of permissions on a system or network.""" - DEFENSE_EVASION = "DefenseEvasion" - """Defense evasion consists of techniques an adversary may use to evade detection or avoid other - defenses.""" - CREDENTIAL_ACCESS = "CredentialAccess" - """Credential access represents techniques resulting in access to or control over system, domain, - or service credentials that are used within an enterprise environment.""" - DISCOVERY = "Discovery" - """Discovery consists of techniques that allow the adversary to gain knowledge about the system - and internal network.""" - LATERAL_MOVEMENT = "LateralMovement" - """Lateral movement consists of techniques that enable an adversary to access and control remote - systems on a network and could, but does not necessarily, include execution of tools on remote - systems.""" - EXECUTION = "Execution" - """The execution tactic represents techniques that result in execution of adversary-controlled - code on a local or remote system.""" - COLLECTION = "Collection" - """Collection consists of techniques used to identify and gather information, such as sensitive - files, from a target network prior to exfiltration.""" - EXFILTRATION = "Exfiltration" - """Exfiltration refers to techniques and attributes that result or aid in the adversary removing - files and information from a target network.""" - COMMAND_AND_CONTROL = "CommandAndControl" - """The command and control tactic represents how adversaries communicate with systems under their - control within a target network.""" - IMPACT = "Impact" - """Impact events primarily try to directly reduce the availability or integrity of a system, - service, or network; including manipulation of data to impact a business or operational - process.""" - PROBING = "Probing" - """Probing could be either an attempt to access a certain resource regardless of a malicious - intent, or a failed attempt to gain access to a target system to gather information prior to - exploitation.""" - EXPLOITATION = "Exploitation" - """Exploitation is the stage where an attacker manages to get a foothold on the attacked resource. - This stage is relevant for compute hosts and resources such as user accounts, certificates etc.""" - - -class KindEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of alert simulation.""" - - BUNDLES = "Bundles" - """Simulate alerts according to bundles""" - - -class ResourceIdentifierType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """There can be multiple identifiers of different type per alert, this field specify the - identifier type. - """ - - AZURE_RESOURCE = "AzureResource" - LOG_ANALYTICS = "LogAnalytics" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/__init__.py deleted file mode 100644 index b3a334939bbd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._alerts_operations import AlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_alerts_operations.py deleted file mode 100644 index 7dc8b0914b0f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_alerts_operations.py +++ /dev/null @@ -1,1444 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_subscription_level_by_region_request( # pylint: disable=name-too-long - asc_location: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_resource_group_level_by_region_request( # pylint: disable=name-too-long - asc_location: str, resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_subscription_level_request( - asc_location: str, alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_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_get_resource_group_level_request( - asc_location: str, alert_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_update_subscription_level_state_to_dismiss_request( # pylint: disable=name-too-long - asc_location: str, alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_subscription_level_state_to_resolve_request( # pylint: disable=name-too-long - asc_location: str, alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_subscription_level_state_to_activate_request( # pylint: disable=name-too-long - asc_location: str, alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_resource_group_level_state_to_resolve_request( # pylint: disable=name-too-long - asc_location: str, alert_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_resource_group_level_state_to_dismiss_request( # pylint: disable=name-too-long - asc_location: str, alert_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_resource_group_level_state_to_activate_request( # pylint: disable=name-too-long - asc_location: str, alert_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_simulate_request(asc_location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_01_01.SecurityCenter`'s - :attr:`alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Alert"]: - """List all the alerts that are associated with the subscription. - - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_01_01.models.Alert] - :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._api_version or "2021-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Alert"]: - """List all the alerts that are associated with the resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_01_01.models.Alert] - :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._api_version or "2021-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> Iterable["_models.Alert"]: - """List all the alerts that are associated with the subscription that are stored in a specific - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_01_01.models.Alert] - :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._api_version or "2021-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_subscription_level_by_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_resource_group_level_by_region( - self, asc_location: str, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.Alert"]: - """List all the alerts that are associated with the resource group that are stored in a specific - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_01_01.models.Alert] - :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._api_version or "2021-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_group_level_by_region_request( - asc_location=asc_location, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: Any) -> _models.Alert: - """Get an alert that is associated with a subscription. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_01_01.models.Alert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - - _request = build_get_subscription_level_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Alert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_resource_group_level( - self, asc_location: str, alert_name: str, resource_group_name: str, **kwargs: Any - ) -> _models.Alert: - """Get an alert that is associated a resource group or a resource in a resource group. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_01_01.models.Alert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - - _request = build_get_resource_group_level_request( - asc_location=asc_location, - alert_name=alert_name, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Alert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_dismiss_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_resolve_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_subscription_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_activate_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_resource_group_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_resolve_request( - asc_location=asc_location, - alert_name=alert_name, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_dismiss_request( - asc_location=asc_location, - alert_name=alert_name, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_resource_group_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_activate_request( - asc_location=asc_location, - alert_name=alert_name, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _simulate_initial( # pylint: disable=inconsistent-return-statements - self, - asc_location: str, - alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], - **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_simulator_request_body, (IOBase, bytes)): - _content = alert_simulator_request_body - else: - _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") - - _request = build_simulate_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: _models.AlertSimulatorRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Required. - :type alert_simulator_request_body: - ~azure.mgmt.security.v2021_01_01.models.AlertSimulatorRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Required. - :type alert_simulator_request_body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Is either a - AlertSimulatorRequestBody type or a IO[bytes] type. Required. - :type alert_simulator_request_body: - ~azure.mgmt.security.v2021_01_01.models.AlertSimulatorRequestBody or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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._api_version or "2021-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._simulate_initial( # type: ignore - asc_location=asc_location, - alert_simulator_request_body=alert_simulator_request_body, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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": "original-uri"}, **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/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_configuration.py deleted file mode 100644 index 8a5cfe205cbe..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-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", "2021-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_metadata.json deleted file mode 100644 index d8f3e3285aa9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2021-05-01-preview", - "total_api_version_list": ["2021-05-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "software_inventories": "SoftwareInventoriesOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_security_center.py deleted file mode 100644 index 971b1c79f469..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_security_center.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SoftwareInventoriesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar software_inventories: SoftwareInventoriesOperations operations - :vartype software_inventories: - azure.mgmt.security.v2021_05_01_preview.operations.SoftwareInventoriesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.software_inventories = SoftwareInventoriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-05-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_configuration.py deleted file mode 100644 index 45eb7af92971..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-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", "2021-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_security_center.py deleted file mode 100644 index 2fe63aadac3e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_security_center.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SoftwareInventoriesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar software_inventories: SoftwareInventoriesOperations operations - :vartype software_inventories: - azure.mgmt.security.v2021_05_01_preview.aio.operations.SoftwareInventoriesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.software_inventories = SoftwareInventoriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-05-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/__init__.py deleted file mode 100644 index 7bacc485fce7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._software_inventories_operations import SoftwareInventoriesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SoftwareInventoriesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_software_inventories_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_software_inventories_operations.py deleted file mode 100644 index 917e598a3b90..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_software_inventories_operations.py +++ /dev/null @@ -1,312 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._software_inventories_operations import ( - build_get_request, - build_list_by_extended_resource_request, - build_list_by_subscription_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SoftwareInventoriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_05_01_preview.aio.SecurityCenter`'s - :attr:`software_inventories` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_extended_resource( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Software"]: - """Gets the software inventory of the virtual machine. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either Software or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_05_01_preview.models.Software] - :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._api_version or "2021-05-01-preview") - ) - cls: ClsType[_models.SoftwaresList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_extended_resource_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SoftwaresList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Software"]: - """Gets the software inventory of all virtual machines in the subscriptions. - - :return: An iterator like instance of either Software or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_05_01_preview.models.Software] - :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._api_version or "2021-05-01-preview") - ) - cls: ClsType[_models.SoftwaresList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SoftwaresList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - software_name: str, - **kwargs: Any - ) -> _models.Software: - """Gets a single software data of the virtual machine. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param software_name: Name of the installed software. Required. - :type software_name: str - :return: Software or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_05_01_preview.models.Software - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-05-01-preview") - ) - cls: ClsType[_models.Software] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - software_name=software_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Software", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/__init__.py deleted file mode 100644 index 75809ee4c6fa..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/__init__.py +++ /dev/null @@ -1,29 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Resource -from ._models_py3 import Software -from ._models_py3 import SoftwaresList - -from ._security_center_enums import EndOfSupportStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "ErrorAdditionalInfo", - "Resource", - "Software", - "SoftwaresList", - "EndOfSupportStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_models_py3.py deleted file mode 100644 index 40293222c062..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_models_py3.py +++ /dev/null @@ -1,257 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CloudErrorBody(_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.security.v2021_05_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2021_05_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Software(Resource): # pylint: disable=too-many-instance-attributes - """Represents a software data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar device_id: Unique identifier for the virtual machine in the service. - :vartype device_id: str - :ivar os_platform: Platform of the operating system running on the device. - :vartype os_platform: str - :ivar vendor: Name of the software vendor. - :vartype vendor: str - :ivar software_name: Name of the software product. - :vartype software_name: str - :ivar version: Version number of the software product. - :vartype version: str - :ivar end_of_support_status: End of support status. Known values are: "None", - "noLongerSupported", "versionNoLongerSupported", "upcomingNoLongerSupported", and - "upcomingVersionNoLongerSupported". - :vartype end_of_support_status: str or - ~azure.mgmt.security.v2021_05_01_preview.models.EndOfSupportStatus - :ivar end_of_support_date: The end of support date in case the product is upcoming end of - support. - :vartype end_of_support_date: str - :ivar number_of_known_vulnerabilities: Number of weaknesses. - :vartype number_of_known_vulnerabilities: int - :ivar first_seen_at: First time that the software was seen in the device. - :vartype first_seen_at: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "device_id": {"key": "properties.deviceId", "type": "str"}, - "os_platform": {"key": "properties.osPlatform", "type": "str"}, - "vendor": {"key": "properties.vendor", "type": "str"}, - "software_name": {"key": "properties.softwareName", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "end_of_support_status": {"key": "properties.endOfSupportStatus", "type": "str"}, - "end_of_support_date": {"key": "properties.endOfSupportDate", "type": "str"}, - "number_of_known_vulnerabilities": {"key": "properties.numberOfKnownVulnerabilities", "type": "int"}, - "first_seen_at": {"key": "properties.firstSeenAt", "type": "str"}, - } - - def __init__( - self, - *, - device_id: Optional[str] = None, - os_platform: Optional[str] = None, - vendor: Optional[str] = None, - software_name: Optional[str] = None, - version: Optional[str] = None, - end_of_support_status: Optional[Union[str, "_models.EndOfSupportStatus"]] = None, - end_of_support_date: Optional[str] = None, - number_of_known_vulnerabilities: Optional[int] = None, - first_seen_at: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword device_id: Unique identifier for the virtual machine in the service. - :paramtype device_id: str - :keyword os_platform: Platform of the operating system running on the device. - :paramtype os_platform: str - :keyword vendor: Name of the software vendor. - :paramtype vendor: str - :keyword software_name: Name of the software product. - :paramtype software_name: str - :keyword version: Version number of the software product. - :paramtype version: str - :keyword end_of_support_status: End of support status. Known values are: "None", - "noLongerSupported", "versionNoLongerSupported", "upcomingNoLongerSupported", and - "upcomingVersionNoLongerSupported". - :paramtype end_of_support_status: str or - ~azure.mgmt.security.v2021_05_01_preview.models.EndOfSupportStatus - :keyword end_of_support_date: The end of support date in case the product is upcoming end of - support. - :paramtype end_of_support_date: str - :keyword number_of_known_vulnerabilities: Number of weaknesses. - :paramtype number_of_known_vulnerabilities: int - :keyword first_seen_at: First time that the software was seen in the device. - :paramtype first_seen_at: str - """ - super().__init__(**kwargs) - self.device_id = device_id - self.os_platform = os_platform - self.vendor = vendor - self.software_name = software_name - self.version = version - self.end_of_support_status = end_of_support_status - self.end_of_support_date = end_of_support_date - self.number_of_known_vulnerabilities = number_of_known_vulnerabilities - self.first_seen_at = first_seen_at - - -class SoftwaresList(_serialization.Model): - """Represents the software inventory of the virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: list[~azure.mgmt.security.v2021_05_01_preview.models.Software] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Software]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Software"]] = None, **kwargs: Any) -> None: - """ - :keyword value: - :paramtype value: list[~azure.mgmt.security.v2021_05_01_preview.models.Software] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_security_center_enums.py deleted file mode 100644 index d2f018b25e87..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,20 +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 EndOfSupportStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """End of support status.""" - - NONE = "None" - NO_LONGER_SUPPORTED = "noLongerSupported" - VERSION_NO_LONGER_SUPPORTED = "versionNoLongerSupported" - UPCOMING_NO_LONGER_SUPPORTED = "upcomingNoLongerSupported" - UPCOMING_VERSION_NO_LONGER_SUPPORTED = "upcomingVersionNoLongerSupported" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/__init__.py deleted file mode 100644 index 7bacc485fce7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._software_inventories_operations import SoftwareInventoriesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SoftwareInventoriesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_software_inventories_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_software_inventories_operations.py deleted file mode 100644 index 042b29c7b9b2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_software_inventories_operations.py +++ /dev/null @@ -1,422 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_extended_resource_request( - resource_group_name: str, - resource_namespace: str, - resource_type: str, - 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", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), - "resourceName": _SERIALIZER.url("resource_name", 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_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/softwareInventories" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request( - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - software_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories/{softwareName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "resourceNamespace": _SERIALIZER.url("resource_namespace", resource_namespace, "str"), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "softwareName": _SERIALIZER.url("software_name", software_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) - - -class SoftwareInventoriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_05_01_preview.SecurityCenter`'s - :attr:`software_inventories` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_extended_resource( - self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.Software"]: - """Gets the software inventory of the virtual machine. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either Software or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_05_01_preview.models.Software] - :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._api_version or "2021-05-01-preview") - ) - cls: ClsType[_models.SoftwaresList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_extended_resource_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SoftwaresList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Software"]: - """Gets the software inventory of all virtual machines in the subscriptions. - - :return: An iterator like instance of either Software or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_05_01_preview.models.Software] - :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._api_version or "2021-05-01-preview") - ) - cls: ClsType[_models.SoftwaresList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SoftwaresList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - software_name: str, - **kwargs: Any - ) -> _models.Software: - """Gets a single software data of the virtual machine. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_namespace: The namespace of the resource. Required. - :type resource_namespace: str - :param resource_type: The type of the resource. Required. - :type resource_type: str - :param resource_name: Name of the resource. Required. - :type resource_name: str - :param software_name: Name of the installed software. Required. - :type software_name: str - :return: Software or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_05_01_preview.models.Software - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-05-01-preview") - ) - cls: ClsType[_models.Software] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_namespace=resource_namespace, - resource_type=resource_type, - resource_name=resource_name, - software_name=software_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Software", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_configuration.py deleted file mode 100644 index 8511c6274289..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_metadata.json deleted file mode 100644 index 8495601e58bf..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2021-06-01", - "total_api_version_list": ["2021-06-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "assessments_metadata": "AssessmentsMetadataOperations", - "assessments": "AssessmentsOperations", - "settings": "SettingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_security_center.py deleted file mode 100644 index f445b685a441..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_security_center.py +++ /dev/null @@ -1,118 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import AssessmentsMetadataOperations, AssessmentsOperations, SettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar assessments_metadata: AssessmentsMetadataOperations operations - :vartype assessments_metadata: - azure.mgmt.security.v2021_06_01.operations.AssessmentsMetadataOperations - :ivar assessments: AssessmentsOperations operations - :vartype assessments: azure.mgmt.security.v2021_06_01.operations.AssessmentsOperations - :ivar settings: SettingsOperations operations - :vartype settings: azure.mgmt.security.v2021_06_01.operations.SettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.assessments_metadata = AssessmentsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01" - ) - self.assessments = AssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01" - ) - self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-06-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_configuration.py deleted file mode 100644 index 103be5c54eed..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_security_center.py deleted file mode 100644 index d97c4848a330..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_security_center.py +++ /dev/null @@ -1,120 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import AssessmentsMetadataOperations, AssessmentsOperations, SettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar assessments_metadata: AssessmentsMetadataOperations operations - :vartype assessments_metadata: - azure.mgmt.security.v2021_06_01.aio.operations.AssessmentsMetadataOperations - :ivar assessments: AssessmentsOperations operations - :vartype assessments: azure.mgmt.security.v2021_06_01.aio.operations.AssessmentsOperations - :ivar settings: SettingsOperations operations - :vartype settings: azure.mgmt.security.v2021_06_01.aio.operations.SettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.assessments_metadata = AssessmentsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01" - ) - self.assessments = AssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01" - ) - self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-06-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/__init__.py deleted file mode 100644 index 76294910e948..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._assessments_metadata_operations import AssessmentsMetadataOperations -from ._assessments_operations import AssessmentsOperations -from ._settings_operations import SettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AssessmentsMetadataOperations", - "AssessmentsOperations", - "SettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_metadata_operations.py deleted file mode 100644 index 76a58cee59f1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_metadata_operations.py +++ /dev/null @@ -1,505 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._assessments_metadata_operations import ( - build_create_in_subscription_request, - build_delete_in_subscription_request, - build_get_in_subscription_request, - build_get_request, - build_list_by_subscription_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AssessmentsMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_06_01.aio.SecurityCenter`'s - :attr:`assessments_metadata` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetadataResponse"]: - """Get metadata information on all assessment types. - - :return: An iterator like instance of either SecurityAssessmentMetadataResponse or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse] - :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._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentMetadataResponseList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityAssessmentMetadataResponse: - """Get metadata information on an assessment type. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - assessment_metadata_name=assessment_metadata_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetadataResponse"]: - """Get metadata information on all assessment types in a specific subscription. - - :return: An iterator like instance of either SecurityAssessmentMetadataResponse or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse] - :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._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentMetadataResponseList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_in_subscription( - self, assessment_metadata_name: str, **kwargs: Any - ) -> _models.SecurityAssessmentMetadataResponse: - """Get metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) - - _request = build_get_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: _models.SecurityAssessmentMetadataResponse, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentMetadataResponse: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Required. - :type assessment_metadata: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentMetadataResponse: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Required. - :type assessment_metadata: 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: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: Union[_models.SecurityAssessmentMetadataResponse, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityAssessmentMetadataResponse: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Is either a - SecurityAssessmentMetadataResponse type or a IO[bytes] type. Required. - :type assessment_metadata: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse or IO[bytes] - :return: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(assessment_metadata, (IOBase, bytes)): - _content = assessment_metadata - else: - _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadataResponse") - - _request = build_create_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_in_subscription( # pylint: disable=inconsistent-return-statements - self, assessment_metadata_name: str, **kwargs: Any - ) -> None: - """Delete metadata information on an assessment type in a specific subscription, will cause the - deletion of all the assessments of that type in that subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_operations.py deleted file mode 100644 index c05862b7833e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_operations.py +++ /dev/null @@ -1,399 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._assessments_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_06_01.aio.SecurityCenter`'s - :attr:`assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentResponse"]: - """Get security assessments on all your scanned resources inside a scope. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either SecurityAssessmentResponse or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse] - :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._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_id: str, - assessment_name: str, - expand: Optional[Union[str, _models.ExpandEnum]] = None, - **kwargs: Any - ) -> _models.SecurityAssessmentResponse: - """Get a security assessment on your scanned resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param expand: OData expand. Optional. Known values are: "links" and "metadata". Default value - is None. - :type expand: str or ~azure.mgmt.security.v2021_06_01.models.ExpandEnum - :return: SecurityAssessmentResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - assessment_name=assessment_name, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: _models.SecurityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentResponse: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. - :type assessment: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityAssessmentResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentResponse: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. - :type assessment: 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: SecurityAssessmentResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: Union[_models.SecurityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityAssessmentResponse: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Is either a - SecurityAssessment type or a IO[bytes] type. Required. - :type assessment: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessment or IO[bytes] - :return: SecurityAssessmentResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(assessment, (IOBase, bytes)): - _content = assessment - else: - _json = self._serialize.body(assessment, "SecurityAssessment") - - _request = build_create_or_update_request( - resource_id=resource_id, - assessment_name=assessment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityAssessmentResponse", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityAssessmentResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_id: str, assessment_name: str, **kwargs: Any - ) -> None: - """Delete a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_id=resource_id, - assessment_name=assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_settings_operations.py deleted file mode 100644 index 41b3420fc012..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_settings_operations.py +++ /dev/null @@ -1,308 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._settings_operations import build_get_request, build_list_request, build_update_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_06_01.aio.SecurityCenter`'s - :attr:`settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: - """Settings about different configurations in Microsoft Defender for Cloud. - - :return: An iterator like instance of either Setting or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_06_01.models.Setting] - :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._api_version or "2021-06-01")) - cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SettingsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, setting_name: Union[str, _models.Enum12], **kwargs: Any) -> _models.Setting: - """Settings of different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and - "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_06_01.models.Enum12 - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - setting_name: Union[str, _models.Enum12], - setting: _models.Setting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and - "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_06_01.models.Enum12 - :param setting: Setting object. Required. - :type setting: ~azure.mgmt.security.v2021_06_01.models.Setting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - setting_name: Union[str, _models.Enum12], - setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and - "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_06_01.models.Enum12 - :param setting: Setting object. Required. - :type setting: 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: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, setting_name: Union[str, _models.Enum12], setting: Union[_models.Setting, IO[bytes]], **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and - "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_06_01.models.Enum12 - :param setting: Setting object. Is either a Setting type or a IO[bytes] type. Required. - :type setting: ~azure.mgmt.security.v2021_06_01.models.Setting or IO[bytes] - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(setting, (IOBase, bytes)): - _content = setting - else: - _json = self._serialize.body(setting, "Setting") - - _request = build_update_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/__init__.py deleted file mode 100644 index f4a080777e23..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/__init__.py +++ /dev/null @@ -1,99 +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 ._models_py3 import AlertSyncSettings -from ._models_py3 import AssessmentLinks -from ._models_py3 import AssessmentStatus -from ._models_py3 import AssessmentStatusResponse -from ._models_py3 import AzureResourceDetails -from ._models_py3 import CloudErrorBody -from ._models_py3 import DataExportSettings -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import OnPremiseResourceDetails -from ._models_py3 import OnPremiseSqlResourceDetails -from ._models_py3 import Resource -from ._models_py3 import ResourceDetails -from ._models_py3 import SecurityAssessment -from ._models_py3 import SecurityAssessmentList -from ._models_py3 import SecurityAssessmentMetadata -from ._models_py3 import SecurityAssessmentMetadataPartnerData -from ._models_py3 import SecurityAssessmentMetadataProperties -from ._models_py3 import SecurityAssessmentMetadataPropertiesResponse -from ._models_py3 import SecurityAssessmentMetadataPropertiesResponsePublishDates -from ._models_py3 import SecurityAssessmentMetadataResponse -from ._models_py3 import SecurityAssessmentMetadataResponseList -from ._models_py3 import SecurityAssessmentPartnerData -from ._models_py3 import SecurityAssessmentProperties -from ._models_py3 import SecurityAssessmentPropertiesBase -from ._models_py3 import SecurityAssessmentPropertiesResponse -from ._models_py3 import SecurityAssessmentResponse -from ._models_py3 import Setting -from ._models_py3 import SettingsList - -from ._security_center_enums import AssessmentStatusCode -from ._security_center_enums import AssessmentType -from ._security_center_enums import Categories -from ._security_center_enums import Enum12 -from ._security_center_enums import ExpandEnum -from ._security_center_enums import ImplementationEffort -from ._security_center_enums import SettingKind -from ._security_center_enums import Severity -from ._security_center_enums import Source -from ._security_center_enums import Tactics -from ._security_center_enums import Techniques -from ._security_center_enums import Threats -from ._security_center_enums import UserImpact -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertSyncSettings", - "AssessmentLinks", - "AssessmentStatus", - "AssessmentStatusResponse", - "AzureResourceDetails", - "CloudErrorBody", - "DataExportSettings", - "ErrorAdditionalInfo", - "OnPremiseResourceDetails", - "OnPremiseSqlResourceDetails", - "Resource", - "ResourceDetails", - "SecurityAssessment", - "SecurityAssessmentList", - "SecurityAssessmentMetadata", - "SecurityAssessmentMetadataPartnerData", - "SecurityAssessmentMetadataProperties", - "SecurityAssessmentMetadataPropertiesResponse", - "SecurityAssessmentMetadataPropertiesResponsePublishDates", - "SecurityAssessmentMetadataResponse", - "SecurityAssessmentMetadataResponseList", - "SecurityAssessmentPartnerData", - "SecurityAssessmentProperties", - "SecurityAssessmentPropertiesBase", - "SecurityAssessmentPropertiesResponse", - "SecurityAssessmentResponse", - "Setting", - "SettingsList", - "AssessmentStatusCode", - "AssessmentType", - "Categories", - "Enum12", - "ExpandEnum", - "ImplementationEffort", - "SettingKind", - "Severity", - "Source", - "Tactics", - "Techniques", - "Threats", - "UserImpact", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_models_py3.py deleted file mode 100644 index a26668800afe..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_models_py3.py +++ /dev/null @@ -1,1737 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Setting(Resource): - """The kind of the security setting. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AlertSyncSettings, DataExportSettings - - 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: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", - "AlertSuppressionSetting", and "AlertSyncSettings". - :vartype kind: str or ~azure.mgmt.security.v2021_06_01.models.SettingKind - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - } - - _subtype_map = {"kind": {"AlertSyncSettings": "AlertSyncSettings", "DataExportSettings": "DataExportSettings"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - - -class AlertSyncSettings(Setting): - """Represents an alert sync setting. - - 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: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", - "AlertSuppressionSetting", and "AlertSyncSettings". - :vartype kind: str or ~azure.mgmt.security.v2021_06_01.models.SettingKind - :ivar enabled: Is the alert sync setting enabled. - :vartype enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is the alert sync setting enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.kind: str = "AlertSyncSettings" - self.enabled = enabled - - -class AssessmentLinks(_serialization.Model): - """Links relevant to the assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar azure_portal_uri: Link to assessment in Azure Portal. - :vartype azure_portal_uri: str - """ - - _validation = { - "azure_portal_uri": {"readonly": True}, - } - - _attribute_map = { - "azure_portal_uri": {"key": "azurePortalUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.azure_portal_uri = None - - -class AssessmentStatus(_serialization.Model): - """The result of the assessment. - - All required parameters must be populated in order to send to server. - - :ivar code: Programmatic code for the status of the assessment. Required. Known values are: - "Healthy", "Unhealthy", and "NotApplicable". - :vartype code: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentStatusCode - :ivar cause: Programmatic code for the cause of the assessment status. - :vartype cause: str - :ivar description: Human readable description of the assessment status. - :vartype description: str - """ - - _validation = { - "code": {"required": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "cause": {"key": "cause", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - code: Union[str, "_models.AssessmentStatusCode"], - cause: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: Programmatic code for the status of the assessment. Required. Known values are: - "Healthy", "Unhealthy", and "NotApplicable". - :paramtype code: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentStatusCode - :keyword cause: Programmatic code for the cause of the assessment status. - :paramtype cause: str - :keyword description: Human readable description of the assessment status. - :paramtype description: str - """ - super().__init__(**kwargs) - self.code = code - self.cause = cause - self.description = description - - -class AssessmentStatusResponse(AssessmentStatus): - """The result of the assessment. - - 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 code: Programmatic code for the status of the assessment. Required. Known values are: - "Healthy", "Unhealthy", and "NotApplicable". - :vartype code: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentStatusCode - :ivar cause: Programmatic code for the cause of the assessment status. - :vartype cause: str - :ivar description: Human readable description of the assessment status. - :vartype description: str - :ivar first_evaluation_date: The time that the assessment was created and first evaluated. - Returned as UTC time in ISO 8601 format. - :vartype first_evaluation_date: ~datetime.datetime - :ivar status_change_date: The time that the status of the assessment last changed. Returned as - UTC time in ISO 8601 format. - :vartype status_change_date: ~datetime.datetime - """ - - _validation = { - "code": {"required": True}, - "first_evaluation_date": {"readonly": True}, - "status_change_date": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "cause": {"key": "cause", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "first_evaluation_date": {"key": "firstEvaluationDate", "type": "iso-8601"}, - "status_change_date": {"key": "statusChangeDate", "type": "iso-8601"}, - } - - def __init__( - self, - *, - code: Union[str, "_models.AssessmentStatusCode"], - cause: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: Programmatic code for the status of the assessment. Required. Known values are: - "Healthy", "Unhealthy", and "NotApplicable". - :paramtype code: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentStatusCode - :keyword cause: Programmatic code for the cause of the assessment status. - :paramtype cause: str - :keyword description: Human readable description of the assessment status. - :paramtype description: str - """ - super().__init__(code=code, cause=cause, description=description, **kwargs) - self.first_evaluation_date = None - self.status_change_date = None - - -class ResourceDetails(_serialization.Model): - """Details of the resource that was assessed. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureResourceDetails, OnPremiseResourceDetails - - All required parameters must be populated in order to send to server. - - :ivar source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2021_06_01.models.Source - """ - - _validation = { - "source": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - } - - _subtype_map = {"source": {"Azure": "AzureResourceDetails", "OnPremise": "OnPremiseResourceDetails"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.source: Optional[str] = None - - -class AzureResourceDetails(ResourceDetails): - """Details of the Azure resource that was assessed. - - 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 source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2021_06_01.models.Source - :ivar id: Azure resource Id of the assessed resource. - :vartype id: str - """ - - _validation = { - "source": {"required": True}, - "id": {"readonly": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.source: str = "Azure" - self.id = None - - -class CloudErrorBody(_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.security.v2021_06_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2021_06_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class DataExportSettings(Setting): - """Represents a data export setting. - - 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: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", - "AlertSuppressionSetting", and "AlertSyncSettings". - :vartype kind: str or ~azure.mgmt.security.v2021_06_01.models.SettingKind - :ivar enabled: Is the data export setting enabled. - :vartype enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is the data export setting enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.kind: str = "DataExportSettings" - self.enabled = enabled - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class OnPremiseResourceDetails(ResourceDetails): - """Details of the On Premise resource that was assessed. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - OnPremiseSqlResourceDetails - - All required parameters must be populated in order to send to server. - - :ivar source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2021_06_01.models.Source - :ivar workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :vartype workspace_id: str - :ivar vmuuid: The unique Id of the machine. Required. - :vartype vmuuid: str - :ivar source_computer_id: The oms agent Id installed on the machine. Required. - :vartype source_computer_id: str - :ivar machine_name: The name of the machine. Required. - :vartype machine_name: str - """ - - _validation = { - "source": {"required": True}, - "workspace_id": {"required": True}, - "vmuuid": {"required": True}, - "source_computer_id": {"required": True}, - "machine_name": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "vmuuid": {"key": "vmuuid", "type": "str"}, - "source_computer_id": {"key": "sourceComputerId", "type": "str"}, - "machine_name": {"key": "machineName", "type": "str"}, - } - - _subtype_map = {"source": {"OnPremiseSql": "OnPremiseSqlResourceDetails"}} - - def __init__( - self, *, workspace_id: str, vmuuid: str, source_computer_id: str, machine_name: str, **kwargs: Any - ) -> None: - """ - :keyword workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :paramtype workspace_id: str - :keyword vmuuid: The unique Id of the machine. Required. - :paramtype vmuuid: str - :keyword source_computer_id: The oms agent Id installed on the machine. Required. - :paramtype source_computer_id: str - :keyword machine_name: The name of the machine. Required. - :paramtype machine_name: str - """ - super().__init__(**kwargs) - self.source: str = "OnPremise" - self.workspace_id = workspace_id - self.vmuuid = vmuuid - self.source_computer_id = source_computer_id - self.machine_name = machine_name - - -class OnPremiseSqlResourceDetails(OnPremiseResourceDetails): - """Details of the On Premise Sql resource that was assessed. - - All required parameters must be populated in order to send to server. - - :ivar source: The platform where the assessed resource resides. Required. Known values are: - "Azure", "OnPremise", and "OnPremiseSql". - :vartype source: str or ~azure.mgmt.security.v2021_06_01.models.Source - :ivar workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :vartype workspace_id: str - :ivar vmuuid: The unique Id of the machine. Required. - :vartype vmuuid: str - :ivar source_computer_id: The oms agent Id installed on the machine. Required. - :vartype source_computer_id: str - :ivar machine_name: The name of the machine. Required. - :vartype machine_name: str - :ivar server_name: The Sql server name installed on the machine. Required. - :vartype server_name: str - :ivar database_name: The Sql database name installed on the machine. Required. - :vartype database_name: str - """ - - _validation = { - "source": {"required": True}, - "workspace_id": {"required": True}, - "vmuuid": {"required": True}, - "source_computer_id": {"required": True}, - "machine_name": {"required": True}, - "server_name": {"required": True}, - "database_name": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "vmuuid": {"key": "vmuuid", "type": "str"}, - "source_computer_id": {"key": "sourceComputerId", "type": "str"}, - "machine_name": {"key": "machineName", "type": "str"}, - "server_name": {"key": "serverName", "type": "str"}, - "database_name": {"key": "databaseName", "type": "str"}, - } - - def __init__( - self, - *, - workspace_id: str, - vmuuid: str, - source_computer_id: str, - machine_name: str, - server_name: str, - database_name: str, - **kwargs: Any - ) -> None: - """ - :keyword workspace_id: Azure resource Id of the workspace the machine is attached to. Required. - :paramtype workspace_id: str - :keyword vmuuid: The unique Id of the machine. Required. - :paramtype vmuuid: str - :keyword source_computer_id: The oms agent Id installed on the machine. Required. - :paramtype source_computer_id: str - :keyword machine_name: The name of the machine. Required. - :paramtype machine_name: str - :keyword server_name: The Sql server name installed on the machine. Required. - :paramtype server_name: str - :keyword database_name: The Sql database name installed on the machine. Required. - :paramtype database_name: str - """ - super().__init__( - workspace_id=workspace_id, - vmuuid=vmuuid, - source_computer_id=source_computer_id, - machine_name=machine_name, - **kwargs - ) - self.source: str = "OnPremiseSql" - self.server_name = server_name - self.database_name = database_name - - -class SecurityAssessment(Resource): - """Security assessment on a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar resource_details: Details of the resource that was assessed. - :vartype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :ivar additional_data: Additional data regarding the assessment. - :vartype additional_data: dict[str, str] - :ivar links: Links relevant to the assessment. - :vartype links: ~azure.mgmt.security.v2021_06_01.models.AssessmentLinks - :ivar metadata: Describes properties of an assessment metadata. - :vartype metadata: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :ivar partners_data: Data regarding 3rd party partner integration. - :vartype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - :ivar status: The result of the assessment. - :vartype status: ~azure.mgmt.security.v2021_06_01.models.AssessmentStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"readonly": True}, - "links": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "additional_data": {"key": "properties.additionalData", "type": "{str}"}, - "links": {"key": "properties.links", "type": "AssessmentLinks"}, - "metadata": {"key": "properties.metadata", "type": "SecurityAssessmentMetadataProperties"}, - "partners_data": {"key": "properties.partnersData", "type": "SecurityAssessmentPartnerData"}, - "status": {"key": "properties.status", "type": "AssessmentStatus"}, - } - - def __init__( - self, - *, - resource_details: Optional["_models.ResourceDetails"] = None, - additional_data: Optional[Dict[str, str]] = None, - metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, - partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, - status: Optional["_models.AssessmentStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_details: Details of the resource that was assessed. - :paramtype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :keyword additional_data: Additional data regarding the assessment. - :paramtype additional_data: dict[str, str] - :keyword metadata: Describes properties of an assessment metadata. - :paramtype metadata: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :keyword partners_data: Data regarding 3rd party partner integration. - :paramtype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - :keyword status: The result of the assessment. - :paramtype status: ~azure.mgmt.security.v2021_06_01.models.AssessmentStatus - """ - super().__init__(**kwargs) - self.resource_details = resource_details - self.display_name = None - self.additional_data = additional_data - self.links = None - self.metadata = metadata - self.partners_data = partners_data - self.status = status - - -class SecurityAssessmentList(_serialization.Model): - """Page of a security assessments list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of security assessments in this page. - :vartype value: list[~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityAssessmentResponse]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityAssessmentMetadata(Resource): # pylint: disable=too-many-instance-attributes - """Security assessment metadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :ivar policy_definition_id: Azure resource ID of the policy definition that turns this - assessment calculation on. - :vartype policy_definition_id: str - :ivar description: Human readable description of the assessment. - :vartype description: str - :ivar remediation_description: Human readable description of what you should do to mitigate - this security issue. - :vartype remediation_description: str - :ivar categories: - :vartype categories: list[str or ~azure.mgmt.security.v2021_06_01.models.Categories] - :ivar severity: The severity level of the assessment. Known values are: "Low", "Medium", and - "High". - :vartype severity: str or ~azure.mgmt.security.v2021_06_01.models.Severity - :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and - "High". - :vartype user_impact: str or ~azure.mgmt.security.v2021_06_01.models.UserImpact - :ivar implementation_effort: The implementation effort required to remediate this assessment. - Known values are: "Low", "Moderate", and "High". - :vartype implementation_effort: str or - ~azure.mgmt.security.v2021_06_01.models.ImplementationEffort - :ivar threats: - :vartype threats: list[str or ~azure.mgmt.security.v2021_06_01.models.Threats] - :ivar preview: True if this assessment is in preview release status. - :vartype preview: bool - :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", - "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :vartype assessment_type: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentType - :ivar partner_data: Describes the partner that created the assessment. - :vartype partner_data: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPartnerData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "policy_definition_id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, - "categories": {"key": "properties.categories", "type": "[str]"}, - "severity": {"key": "properties.severity", "type": "str"}, - "user_impact": {"key": "properties.userImpact", "type": "str"}, - "implementation_effort": {"key": "properties.implementationEffort", "type": "str"}, - "threats": {"key": "properties.threats", "type": "[str]"}, - "preview": {"key": "properties.preview", "type": "bool"}, - "assessment_type": {"key": "properties.assessmentType", "type": "str"}, - "partner_data": {"key": "properties.partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - remediation_description: Optional[str] = None, - categories: Optional[List[Union[str, "_models.Categories"]]] = None, - severity: Optional[Union[str, "_models.Severity"]] = None, - user_impact: Optional[Union[str, "_models.UserImpact"]] = None, - implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, - threats: Optional[List[Union[str, "_models.Threats"]]] = None, - preview: Optional[bool] = None, - assessment_type: Optional[Union[str, "_models.AssessmentType"]] = None, - partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: User friendly display name of the assessment. - :paramtype display_name: str - :keyword description: Human readable description of the assessment. - :paramtype description: str - :keyword remediation_description: Human readable description of what you should do to mitigate - this security issue. - :paramtype remediation_description: str - :keyword categories: - :paramtype categories: list[str or ~azure.mgmt.security.v2021_06_01.models.Categories] - :keyword severity: The severity level of the assessment. Known values are: "Low", "Medium", and - "High". - :paramtype severity: str or ~azure.mgmt.security.v2021_06_01.models.Severity - :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", - and "High". - :paramtype user_impact: str or ~azure.mgmt.security.v2021_06_01.models.UserImpact - :keyword implementation_effort: The implementation effort required to remediate this - assessment. Known values are: "Low", "Moderate", and "High". - :paramtype implementation_effort: str or - ~azure.mgmt.security.v2021_06_01.models.ImplementationEffort - :keyword threats: - :paramtype threats: list[str or ~azure.mgmt.security.v2021_06_01.models.Threats] - :keyword preview: True if this assessment is in preview release status. - :paramtype preview: bool - :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", - "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :paramtype assessment_type: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentType - :keyword partner_data: Describes the partner that created the assessment. - :paramtype partner_data: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPartnerData - """ - super().__init__(**kwargs) - self.display_name = display_name - self.policy_definition_id = None - self.description = description - self.remediation_description = remediation_description - self.categories = categories - self.severity = severity - self.user_impact = user_impact - self.implementation_effort = implementation_effort - self.threats = threats - self.preview = preview - self.assessment_type = assessment_type - self.partner_data = partner_data - - -class SecurityAssessmentMetadataPartnerData(_serialization.Model): - """Describes the partner that created the assessment. - - All required parameters must be populated in order to send to server. - - :ivar partner_name: Name of the company of the partner. Required. - :vartype partner_name: str - :ivar product_name: Name of the product of the partner that created the assessment. - :vartype product_name: str - :ivar secret: Secret to authenticate the partner and verify it created the assessment - write - only. Required. - :vartype secret: str - """ - - _validation = { - "partner_name": {"required": True}, - "secret": {"required": True}, - } - - _attribute_map = { - "partner_name": {"key": "partnerName", "type": "str"}, - "product_name": {"key": "productName", "type": "str"}, - "secret": {"key": "secret", "type": "str"}, - } - - def __init__(self, *, partner_name: str, secret: str, product_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword partner_name: Name of the company of the partner. Required. - :paramtype partner_name: str - :keyword product_name: Name of the product of the partner that created the assessment. - :paramtype product_name: str - :keyword secret: Secret to authenticate the partner and verify it created the assessment - - write only. Required. - :paramtype secret: str - """ - super().__init__(**kwargs) - self.partner_name = partner_name - self.product_name = product_name - self.secret = secret - - -class SecurityAssessmentMetadataProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Describes properties of an assessment metadata. - - 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 display_name: User friendly display name of the assessment. Required. - :vartype display_name: str - :ivar policy_definition_id: Azure resource ID of the policy definition that turns this - assessment calculation on. - :vartype policy_definition_id: str - :ivar description: Human readable description of the assessment. - :vartype description: str - :ivar remediation_description: Human readable description of what you should do to mitigate - this security issue. - :vartype remediation_description: str - :ivar categories: - :vartype categories: list[str or ~azure.mgmt.security.v2021_06_01.models.Categories] - :ivar severity: The severity level of the assessment. Required. Known values are: "Low", - "Medium", and "High". - :vartype severity: str or ~azure.mgmt.security.v2021_06_01.models.Severity - :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and - "High". - :vartype user_impact: str or ~azure.mgmt.security.v2021_06_01.models.UserImpact - :ivar implementation_effort: The implementation effort required to remediate this assessment. - Known values are: "Low", "Moderate", and "High". - :vartype implementation_effort: str or - ~azure.mgmt.security.v2021_06_01.models.ImplementationEffort - :ivar threats: - :vartype threats: list[str or ~azure.mgmt.security.v2021_06_01.models.Threats] - :ivar preview: True if this assessment is in preview release status. - :vartype preview: bool - :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Required. Known values are: - "BuiltIn", "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :vartype assessment_type: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentType - :ivar partner_data: Describes the partner that created the assessment. - :vartype partner_data: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPartnerData - """ - - _validation = { - "display_name": {"required": True}, - "policy_definition_id": {"readonly": True}, - "severity": {"required": True}, - "assessment_type": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "remediation_description": {"key": "remediationDescription", "type": "str"}, - "categories": {"key": "categories", "type": "[str]"}, - "severity": {"key": "severity", "type": "str"}, - "user_impact": {"key": "userImpact", "type": "str"}, - "implementation_effort": {"key": "implementationEffort", "type": "str"}, - "threats": {"key": "threats", "type": "[str]"}, - "preview": {"key": "preview", "type": "bool"}, - "assessment_type": {"key": "assessmentType", "type": "str"}, - "partner_data": {"key": "partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, - } - - def __init__( - self, - *, - display_name: str, - severity: Union[str, "_models.Severity"], - assessment_type: Union[str, "_models.AssessmentType"], - description: Optional[str] = None, - remediation_description: Optional[str] = None, - categories: Optional[List[Union[str, "_models.Categories"]]] = None, - user_impact: Optional[Union[str, "_models.UserImpact"]] = None, - implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, - threats: Optional[List[Union[str, "_models.Threats"]]] = None, - preview: Optional[bool] = None, - partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: User friendly display name of the assessment. Required. - :paramtype display_name: str - :keyword description: Human readable description of the assessment. - :paramtype description: str - :keyword remediation_description: Human readable description of what you should do to mitigate - this security issue. - :paramtype remediation_description: str - :keyword categories: - :paramtype categories: list[str or ~azure.mgmt.security.v2021_06_01.models.Categories] - :keyword severity: The severity level of the assessment. Required. Known values are: "Low", - "Medium", and "High". - :paramtype severity: str or ~azure.mgmt.security.v2021_06_01.models.Severity - :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", - and "High". - :paramtype user_impact: str or ~azure.mgmt.security.v2021_06_01.models.UserImpact - :keyword implementation_effort: The implementation effort required to remediate this - assessment. Known values are: "Low", "Moderate", and "High". - :paramtype implementation_effort: str or - ~azure.mgmt.security.v2021_06_01.models.ImplementationEffort - :keyword threats: - :paramtype threats: list[str or ~azure.mgmt.security.v2021_06_01.models.Threats] - :keyword preview: True if this assessment is in preview release status. - :paramtype preview: bool - :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Required. Known values are: - "BuiltIn", "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :paramtype assessment_type: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentType - :keyword partner_data: Describes the partner that created the assessment. - :paramtype partner_data: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPartnerData - """ - super().__init__(**kwargs) - self.display_name = display_name - self.policy_definition_id = None - self.description = description - self.remediation_description = remediation_description - self.categories = categories - self.severity = severity - self.user_impact = user_impact - self.implementation_effort = implementation_effort - self.threats = threats - self.preview = preview - self.assessment_type = assessment_type - self.partner_data = partner_data - - -class SecurityAssessmentMetadataPropertiesResponse( - SecurityAssessmentMetadataProperties -): # pylint: disable=too-many-instance-attributes,name-too-long - """Describes properties of an assessment metadata response. - - 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 display_name: User friendly display name of the assessment. Required. - :vartype display_name: str - :ivar policy_definition_id: Azure resource ID of the policy definition that turns this - assessment calculation on. - :vartype policy_definition_id: str - :ivar description: Human readable description of the assessment. - :vartype description: str - :ivar remediation_description: Human readable description of what you should do to mitigate - this security issue. - :vartype remediation_description: str - :ivar categories: - :vartype categories: list[str or ~azure.mgmt.security.v2021_06_01.models.Categories] - :ivar severity: The severity level of the assessment. Required. Known values are: "Low", - "Medium", and "High". - :vartype severity: str or ~azure.mgmt.security.v2021_06_01.models.Severity - :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and - "High". - :vartype user_impact: str or ~azure.mgmt.security.v2021_06_01.models.UserImpact - :ivar implementation_effort: The implementation effort required to remediate this assessment. - Known values are: "Low", "Moderate", and "High". - :vartype implementation_effort: str or - ~azure.mgmt.security.v2021_06_01.models.ImplementationEffort - :ivar threats: - :vartype threats: list[str or ~azure.mgmt.security.v2021_06_01.models.Threats] - :ivar preview: True if this assessment is in preview release status. - :vartype preview: bool - :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Required. Known values are: - "BuiltIn", "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :vartype assessment_type: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentType - :ivar partner_data: Describes the partner that created the assessment. - :vartype partner_data: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPartnerData - :ivar publish_dates: - :vartype publish_dates: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPropertiesResponsePublishDates - :ivar planned_deprecation_date: - :vartype planned_deprecation_date: str - :ivar tactics: - :vartype tactics: list[str or ~azure.mgmt.security.v2021_06_01.models.Tactics] - :ivar techniques: - :vartype techniques: list[str or ~azure.mgmt.security.v2021_06_01.models.Techniques] - """ - - _validation = { - "display_name": {"required": True}, - "policy_definition_id": {"readonly": True}, - "severity": {"required": True}, - "assessment_type": {"required": True}, - "planned_deprecation_date": {"pattern": r"^[0-9]{2}/[0-9]{4}$"}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "remediation_description": {"key": "remediationDescription", "type": "str"}, - "categories": {"key": "categories", "type": "[str]"}, - "severity": {"key": "severity", "type": "str"}, - "user_impact": {"key": "userImpact", "type": "str"}, - "implementation_effort": {"key": "implementationEffort", "type": "str"}, - "threats": {"key": "threats", "type": "[str]"}, - "preview": {"key": "preview", "type": "bool"}, - "assessment_type": {"key": "assessmentType", "type": "str"}, - "partner_data": {"key": "partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, - "publish_dates": {"key": "publishDates", "type": "SecurityAssessmentMetadataPropertiesResponsePublishDates"}, - "planned_deprecation_date": {"key": "plannedDeprecationDate", "type": "str"}, - "tactics": {"key": "tactics", "type": "[str]"}, - "techniques": {"key": "techniques", "type": "[str]"}, - } - - def __init__( - self, - *, - display_name: str, - severity: Union[str, "_models.Severity"], - assessment_type: Union[str, "_models.AssessmentType"], - description: Optional[str] = None, - remediation_description: Optional[str] = None, - categories: Optional[List[Union[str, "_models.Categories"]]] = None, - user_impact: Optional[Union[str, "_models.UserImpact"]] = None, - implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, - threats: Optional[List[Union[str, "_models.Threats"]]] = None, - preview: Optional[bool] = None, - partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, - publish_dates: Optional["_models.SecurityAssessmentMetadataPropertiesResponsePublishDates"] = None, - planned_deprecation_date: Optional[str] = None, - tactics: Optional[List[Union[str, "_models.Tactics"]]] = None, - techniques: Optional[List[Union[str, "_models.Techniques"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: User friendly display name of the assessment. Required. - :paramtype display_name: str - :keyword description: Human readable description of the assessment. - :paramtype description: str - :keyword remediation_description: Human readable description of what you should do to mitigate - this security issue. - :paramtype remediation_description: str - :keyword categories: - :paramtype categories: list[str or ~azure.mgmt.security.v2021_06_01.models.Categories] - :keyword severity: The severity level of the assessment. Required. Known values are: "Low", - "Medium", and "High". - :paramtype severity: str or ~azure.mgmt.security.v2021_06_01.models.Severity - :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", - and "High". - :paramtype user_impact: str or ~azure.mgmt.security.v2021_06_01.models.UserImpact - :keyword implementation_effort: The implementation effort required to remediate this - assessment. Known values are: "Low", "Moderate", and "High". - :paramtype implementation_effort: str or - ~azure.mgmt.security.v2021_06_01.models.ImplementationEffort - :keyword threats: - :paramtype threats: list[str or ~azure.mgmt.security.v2021_06_01.models.Threats] - :keyword preview: True if this assessment is in preview release status. - :paramtype preview: bool - :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Required. Known values are: - "BuiltIn", "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :paramtype assessment_type: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentType - :keyword partner_data: Describes the partner that created the assessment. - :paramtype partner_data: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPartnerData - :keyword publish_dates: - :paramtype publish_dates: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPropertiesResponsePublishDates - :keyword planned_deprecation_date: - :paramtype planned_deprecation_date: str - :keyword tactics: - :paramtype tactics: list[str or ~azure.mgmt.security.v2021_06_01.models.Tactics] - :keyword techniques: - :paramtype techniques: list[str or ~azure.mgmt.security.v2021_06_01.models.Techniques] - """ - super().__init__( - display_name=display_name, - description=description, - remediation_description=remediation_description, - categories=categories, - severity=severity, - user_impact=user_impact, - implementation_effort=implementation_effort, - threats=threats, - preview=preview, - assessment_type=assessment_type, - partner_data=partner_data, - **kwargs - ) - self.publish_dates = publish_dates - self.planned_deprecation_date = planned_deprecation_date - self.tactics = tactics - self.techniques = techniques - - -class SecurityAssessmentMetadataPropertiesResponsePublishDates(_serialization.Model): # pylint: disable=name-too-long - """SecurityAssessmentMetadataPropertiesResponsePublishDates. - - All required parameters must be populated in order to send to server. - - :ivar ga: - :vartype ga: str - :ivar public: Required. - :vartype public: str - """ - - _validation = { - "ga": {"pattern": r"^([0-9]{2}/){2}[0-9]{4}$"}, - "public": {"required": True, "pattern": r"^([0-9]{2}/){2}[0-9]{4}$"}, - } - - _attribute_map = { - "ga": {"key": "GA", "type": "str"}, - "public": {"key": "public", "type": "str"}, - } - - def __init__(self, *, public: str, ga: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword ga: - :paramtype ga: str - :keyword public: Required. - :paramtype public: str - """ - super().__init__(**kwargs) - self.ga = ga - self.public = public - - -class SecurityAssessmentMetadataResponse(Resource): # pylint: disable=too-many-instance-attributes - """Security assessment metadata response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :ivar policy_definition_id: Azure resource ID of the policy definition that turns this - assessment calculation on. - :vartype policy_definition_id: str - :ivar description: Human readable description of the assessment. - :vartype description: str - :ivar remediation_description: Human readable description of what you should do to mitigate - this security issue. - :vartype remediation_description: str - :ivar categories: - :vartype categories: list[str or ~azure.mgmt.security.v2021_06_01.models.Categories] - :ivar severity: The severity level of the assessment. Known values are: "Low", "Medium", and - "High". - :vartype severity: str or ~azure.mgmt.security.v2021_06_01.models.Severity - :ivar user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", and - "High". - :vartype user_impact: str or ~azure.mgmt.security.v2021_06_01.models.UserImpact - :ivar implementation_effort: The implementation effort required to remediate this assessment. - Known values are: "Low", "Moderate", and "High". - :vartype implementation_effort: str or - ~azure.mgmt.security.v2021_06_01.models.ImplementationEffort - :ivar threats: - :vartype threats: list[str or ~azure.mgmt.security.v2021_06_01.models.Threats] - :ivar preview: True if this assessment is in preview release status. - :vartype preview: bool - :ivar assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", - "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :vartype assessment_type: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentType - :ivar partner_data: Describes the partner that created the assessment. - :vartype partner_data: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPartnerData - :ivar publish_dates: - :vartype publish_dates: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPropertiesResponsePublishDates - :ivar planned_deprecation_date: - :vartype planned_deprecation_date: str - :ivar tactics: - :vartype tactics: list[str or ~azure.mgmt.security.v2021_06_01.models.Tactics] - :ivar techniques: - :vartype techniques: list[str or ~azure.mgmt.security.v2021_06_01.models.Techniques] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "policy_definition_id": {"readonly": True}, - "planned_deprecation_date": {"pattern": r"^[0-9]{2}/[0-9]{4}$"}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, - "categories": {"key": "properties.categories", "type": "[str]"}, - "severity": {"key": "properties.severity", "type": "str"}, - "user_impact": {"key": "properties.userImpact", "type": "str"}, - "implementation_effort": {"key": "properties.implementationEffort", "type": "str"}, - "threats": {"key": "properties.threats", "type": "[str]"}, - "preview": {"key": "properties.preview", "type": "bool"}, - "assessment_type": {"key": "properties.assessmentType", "type": "str"}, - "partner_data": {"key": "properties.partnerData", "type": "SecurityAssessmentMetadataPartnerData"}, - "publish_dates": { - "key": "properties.publishDates", - "type": "SecurityAssessmentMetadataPropertiesResponsePublishDates", - }, - "planned_deprecation_date": {"key": "properties.plannedDeprecationDate", "type": "str"}, - "tactics": {"key": "properties.tactics", "type": "[str]"}, - "techniques": {"key": "properties.techniques", "type": "[str]"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - remediation_description: Optional[str] = None, - categories: Optional[List[Union[str, "_models.Categories"]]] = None, - severity: Optional[Union[str, "_models.Severity"]] = None, - user_impact: Optional[Union[str, "_models.UserImpact"]] = None, - implementation_effort: Optional[Union[str, "_models.ImplementationEffort"]] = None, - threats: Optional[List[Union[str, "_models.Threats"]]] = None, - preview: Optional[bool] = None, - assessment_type: Optional[Union[str, "_models.AssessmentType"]] = None, - partner_data: Optional["_models.SecurityAssessmentMetadataPartnerData"] = None, - publish_dates: Optional["_models.SecurityAssessmentMetadataPropertiesResponsePublishDates"] = None, - planned_deprecation_date: Optional[str] = None, - tactics: Optional[List[Union[str, "_models.Tactics"]]] = None, - techniques: Optional[List[Union[str, "_models.Techniques"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: User friendly display name of the assessment. - :paramtype display_name: str - :keyword description: Human readable description of the assessment. - :paramtype description: str - :keyword remediation_description: Human readable description of what you should do to mitigate - this security issue. - :paramtype remediation_description: str - :keyword categories: - :paramtype categories: list[str or ~azure.mgmt.security.v2021_06_01.models.Categories] - :keyword severity: The severity level of the assessment. Known values are: "Low", "Medium", and - "High". - :paramtype severity: str or ~azure.mgmt.security.v2021_06_01.models.Severity - :keyword user_impact: The user impact of the assessment. Known values are: "Low", "Moderate", - and "High". - :paramtype user_impact: str or ~azure.mgmt.security.v2021_06_01.models.UserImpact - :keyword implementation_effort: The implementation effort required to remediate this - assessment. Known values are: "Low", "Moderate", and "High". - :paramtype implementation_effort: str or - ~azure.mgmt.security.v2021_06_01.models.ImplementationEffort - :keyword threats: - :paramtype threats: list[str or ~azure.mgmt.security.v2021_06_01.models.Threats] - :keyword preview: True if this assessment is in preview release status. - :paramtype preview: bool - :keyword assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Known values are: "BuiltIn", - "CustomPolicy", "CustomerManaged", and "VerifiedPartner". - :paramtype assessment_type: str or ~azure.mgmt.security.v2021_06_01.models.AssessmentType - :keyword partner_data: Describes the partner that created the assessment. - :paramtype partner_data: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPartnerData - :keyword publish_dates: - :paramtype publish_dates: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataPropertiesResponsePublishDates - :keyword planned_deprecation_date: - :paramtype planned_deprecation_date: str - :keyword tactics: - :paramtype tactics: list[str or ~azure.mgmt.security.v2021_06_01.models.Tactics] - :keyword techniques: - :paramtype techniques: list[str or ~azure.mgmt.security.v2021_06_01.models.Techniques] - """ - super().__init__(**kwargs) - self.display_name = display_name - self.policy_definition_id = None - self.description = description - self.remediation_description = remediation_description - self.categories = categories - self.severity = severity - self.user_impact = user_impact - self.implementation_effort = implementation_effort - self.threats = threats - self.preview = preview - self.assessment_type = assessment_type - self.partner_data = partner_data - self.publish_dates = publish_dates - self.planned_deprecation_date = planned_deprecation_date - self.tactics = tactics - self.techniques = techniques - - -class SecurityAssessmentMetadataResponseList(_serialization.Model): - """List of security assessment metadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: - :vartype value: - list[~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityAssessmentMetadataResponse]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityAssessmentPartnerData(_serialization.Model): - """Data regarding 3rd party partner integration. - - All required parameters must be populated in order to send to server. - - :ivar partner_name: Name of the company of the partner. Required. - :vartype partner_name: str - :ivar secret: secret to authenticate the partner - write only. Required. - :vartype secret: str - """ - - _validation = { - "partner_name": {"required": True}, - "secret": {"required": True}, - } - - _attribute_map = { - "partner_name": {"key": "partnerName", "type": "str"}, - "secret": {"key": "secret", "type": "str"}, - } - - def __init__(self, *, partner_name: str, secret: str, **kwargs: Any) -> None: - """ - :keyword partner_name: Name of the company of the partner. Required. - :paramtype partner_name: str - :keyword secret: secret to authenticate the partner - write only. Required. - :paramtype secret: str - """ - super().__init__(**kwargs) - self.partner_name = partner_name - self.secret = secret - - -class SecurityAssessmentPropertiesBase(_serialization.Model): - """Describes properties of an assessment. - - 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 resource_details: Details of the resource that was assessed. Required. - :vartype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :ivar additional_data: Additional data regarding the assessment. - :vartype additional_data: dict[str, str] - :ivar links: Links relevant to the assessment. - :vartype links: ~azure.mgmt.security.v2021_06_01.models.AssessmentLinks - :ivar metadata: Describes properties of an assessment metadata. - :vartype metadata: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :ivar partners_data: Data regarding 3rd party partner integration. - :vartype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - """ - - _validation = { - "resource_details": {"required": True}, - "display_name": {"readonly": True}, - "links": {"readonly": True}, - } - - _attribute_map = { - "resource_details": {"key": "resourceDetails", "type": "ResourceDetails"}, - "display_name": {"key": "displayName", "type": "str"}, - "additional_data": {"key": "additionalData", "type": "{str}"}, - "links": {"key": "links", "type": "AssessmentLinks"}, - "metadata": {"key": "metadata", "type": "SecurityAssessmentMetadataProperties"}, - "partners_data": {"key": "partnersData", "type": "SecurityAssessmentPartnerData"}, - } - - def __init__( - self, - *, - resource_details: "_models.ResourceDetails", - additional_data: Optional[Dict[str, str]] = None, - metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, - partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_details: Details of the resource that was assessed. Required. - :paramtype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :keyword additional_data: Additional data regarding the assessment. - :paramtype additional_data: dict[str, str] - :keyword metadata: Describes properties of an assessment metadata. - :paramtype metadata: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :keyword partners_data: Data regarding 3rd party partner integration. - :paramtype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - """ - super().__init__(**kwargs) - self.resource_details = resource_details - self.display_name = None - self.additional_data = additional_data - self.links = None - self.metadata = metadata - self.partners_data = partners_data - - -class SecurityAssessmentProperties(SecurityAssessmentPropertiesBase): - """Describes properties of an assessment. - - 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 resource_details: Details of the resource that was assessed. Required. - :vartype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :ivar additional_data: Additional data regarding the assessment. - :vartype additional_data: dict[str, str] - :ivar links: Links relevant to the assessment. - :vartype links: ~azure.mgmt.security.v2021_06_01.models.AssessmentLinks - :ivar metadata: Describes properties of an assessment metadata. - :vartype metadata: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :ivar partners_data: Data regarding 3rd party partner integration. - :vartype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - :ivar status: The result of the assessment. Required. - :vartype status: ~azure.mgmt.security.v2021_06_01.models.AssessmentStatus - """ - - _validation = { - "resource_details": {"required": True}, - "display_name": {"readonly": True}, - "links": {"readonly": True}, - "status": {"required": True}, - } - - _attribute_map = { - "resource_details": {"key": "resourceDetails", "type": "ResourceDetails"}, - "display_name": {"key": "displayName", "type": "str"}, - "additional_data": {"key": "additionalData", "type": "{str}"}, - "links": {"key": "links", "type": "AssessmentLinks"}, - "metadata": {"key": "metadata", "type": "SecurityAssessmentMetadataProperties"}, - "partners_data": {"key": "partnersData", "type": "SecurityAssessmentPartnerData"}, - "status": {"key": "status", "type": "AssessmentStatus"}, - } - - def __init__( - self, - *, - resource_details: "_models.ResourceDetails", - status: "_models.AssessmentStatus", - additional_data: Optional[Dict[str, str]] = None, - metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, - partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_details: Details of the resource that was assessed. Required. - :paramtype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :keyword additional_data: Additional data regarding the assessment. - :paramtype additional_data: dict[str, str] - :keyword metadata: Describes properties of an assessment metadata. - :paramtype metadata: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :keyword partners_data: Data regarding 3rd party partner integration. - :paramtype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - :keyword status: The result of the assessment. Required. - :paramtype status: ~azure.mgmt.security.v2021_06_01.models.AssessmentStatus - """ - super().__init__( - resource_details=resource_details, - additional_data=additional_data, - metadata=metadata, - partners_data=partners_data, - **kwargs - ) - self.status = status - - -class SecurityAssessmentPropertiesResponse(SecurityAssessmentPropertiesBase): - """Describes properties of an assessment. - - 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 resource_details: Details of the resource that was assessed. Required. - :vartype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :ivar additional_data: Additional data regarding the assessment. - :vartype additional_data: dict[str, str] - :ivar links: Links relevant to the assessment. - :vartype links: ~azure.mgmt.security.v2021_06_01.models.AssessmentLinks - :ivar metadata: Describes properties of an assessment metadata. - :vartype metadata: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :ivar partners_data: Data regarding 3rd party partner integration. - :vartype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - :ivar status: The result of the assessment. Required. - :vartype status: ~azure.mgmt.security.v2021_06_01.models.AssessmentStatusResponse - """ - - _validation = { - "resource_details": {"required": True}, - "display_name": {"readonly": True}, - "links": {"readonly": True}, - "status": {"required": True}, - } - - _attribute_map = { - "resource_details": {"key": "resourceDetails", "type": "ResourceDetails"}, - "display_name": {"key": "displayName", "type": "str"}, - "additional_data": {"key": "additionalData", "type": "{str}"}, - "links": {"key": "links", "type": "AssessmentLinks"}, - "metadata": {"key": "metadata", "type": "SecurityAssessmentMetadataProperties"}, - "partners_data": {"key": "partnersData", "type": "SecurityAssessmentPartnerData"}, - "status": {"key": "status", "type": "AssessmentStatusResponse"}, - } - - def __init__( - self, - *, - resource_details: "_models.ResourceDetails", - status: "_models.AssessmentStatusResponse", - additional_data: Optional[Dict[str, str]] = None, - metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, - partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_details: Details of the resource that was assessed. Required. - :paramtype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :keyword additional_data: Additional data regarding the assessment. - :paramtype additional_data: dict[str, str] - :keyword metadata: Describes properties of an assessment metadata. - :paramtype metadata: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :keyword partners_data: Data regarding 3rd party partner integration. - :paramtype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - :keyword status: The result of the assessment. Required. - :paramtype status: ~azure.mgmt.security.v2021_06_01.models.AssessmentStatusResponse - """ - super().__init__( - resource_details=resource_details, - additional_data=additional_data, - metadata=metadata, - partners_data=partners_data, - **kwargs - ) - self.status = status - - -class SecurityAssessmentResponse(Resource): - """Security assessment on a resource - response format. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar resource_details: Details of the resource that was assessed. - :vartype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :ivar additional_data: Additional data regarding the assessment. - :vartype additional_data: dict[str, str] - :ivar links: Links relevant to the assessment. - :vartype links: ~azure.mgmt.security.v2021_06_01.models.AssessmentLinks - :ivar metadata: Describes properties of an assessment metadata. - :vartype metadata: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :ivar partners_data: Data regarding 3rd party partner integration. - :vartype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - :ivar status: The result of the assessment. - :vartype status: ~azure.mgmt.security.v2021_06_01.models.AssessmentStatusResponse - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"readonly": True}, - "links": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "additional_data": {"key": "properties.additionalData", "type": "{str}"}, - "links": {"key": "properties.links", "type": "AssessmentLinks"}, - "metadata": {"key": "properties.metadata", "type": "SecurityAssessmentMetadataProperties"}, - "partners_data": {"key": "properties.partnersData", "type": "SecurityAssessmentPartnerData"}, - "status": {"key": "properties.status", "type": "AssessmentStatusResponse"}, - } - - def __init__( - self, - *, - resource_details: Optional["_models.ResourceDetails"] = None, - additional_data: Optional[Dict[str, str]] = None, - metadata: Optional["_models.SecurityAssessmentMetadataProperties"] = None, - partners_data: Optional["_models.SecurityAssessmentPartnerData"] = None, - status: Optional["_models.AssessmentStatusResponse"] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_details: Details of the resource that was assessed. - :paramtype resource_details: ~azure.mgmt.security.v2021_06_01.models.ResourceDetails - :keyword additional_data: Additional data regarding the assessment. - :paramtype additional_data: dict[str, str] - :keyword metadata: Describes properties of an assessment metadata. - :paramtype metadata: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataProperties - :keyword partners_data: Data regarding 3rd party partner integration. - :paramtype partners_data: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentPartnerData - :keyword status: The result of the assessment. - :paramtype status: ~azure.mgmt.security.v2021_06_01.models.AssessmentStatusResponse - """ - super().__init__(**kwargs) - self.resource_details = resource_details - self.display_name = None - self.additional_data = additional_data - self.links = None - self.metadata = metadata - self.partners_data = partners_data - self.status = status - - -class SettingsList(_serialization.Model): - """Subscription settings list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The settings list. - :vartype value: list[~azure.mgmt.security.v2021_06_01.models.Setting] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Setting]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Setting"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The settings list. - :paramtype value: list[~azure.mgmt.security.v2021_06_01.models.Setting] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_security_center_enums.py deleted file mode 100644 index f08a01bca828..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_security_center_enums.py +++ /dev/null @@ -1,249 +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 AssessmentStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Programmatic code for the status of the assessment.""" - - HEALTHY = "Healthy" - """The resource is healthy""" - UNHEALTHY = "Unhealthy" - """The resource has a security issue that needs to be addressed""" - NOT_APPLICABLE = "NotApplicable" - """Assessment for this resource did not happen""" - - -class AssessmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """BuiltIn if the assessment based on built-in Azure Policy definition, Custom if the assessment - based on custom Azure Policy definition. - """ - - BUILT_IN = "BuiltIn" - """Microsoft Defender for Cloud managed assessments""" - CUSTOM_POLICY = "CustomPolicy" - """User defined policies that are automatically ingested from Azure Policy to Microsoft Defender - for Cloud""" - CUSTOMER_MANAGED = "CustomerManaged" - """User assessments pushed directly by the user or other third party to Microsoft Defender for - Cloud""" - VERIFIED_PARTNER = "VerifiedPartner" - """An assessment that was created by a verified 3rd party if the user connected it to ASC""" - - -class Categories(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The categories of resource that is at risk when the assessment is unhealthy.""" - - COMPUTE = "Compute" - NETWORKING = "Networking" - DATA = "Data" - IDENTITY_AND_ACCESS = "IdentityAndAccess" - IO_T = "IoT" - - -class Enum12(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum12.""" - - MCAS = "MCAS" - WDATP = "WDATP" - SENTINEL = "Sentinel" - - -class ExpandEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExpandEnum.""" - - LINKS = "links" - """All links associated with an assessment""" - METADATA = "metadata" - """Assessment metadata""" - - -class ImplementationEffort(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The implementation effort required to remediate this assessment.""" - - LOW = "Low" - MODERATE = "Moderate" - HIGH = "High" - - -class SettingKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the kind of the settings string.""" - - DATA_EXPORT_SETTINGS = "DataExportSettings" - ALERT_SUPPRESSION_SETTING = "AlertSuppressionSetting" - ALERT_SYNC_SETTINGS = "AlertSyncSettings" - - -class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The severity level of the assessment.""" - - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - - -class Source(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The platform where the assessed resource resides.""" - - AZURE = "Azure" - """Resource is in Azure""" - ON_PREMISE = "OnPremise" - """Resource in an on premise machine connected to Azure cloud""" - ON_PREMISE_SQL = "OnPremiseSql" - """SQL Resource in an on premise machine connected to Azure cloud""" - - -class Tactics(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Tactic of the assessment.""" - - RECONNAISSANCE = "Reconnaissance" - RESOURCE_DEVELOPMENT = "Resource Development" - INITIAL_ACCESS = "Initial Access" - EXECUTION = "Execution" - PERSISTENCE = "Persistence" - PRIVILEGE_ESCALATION = "Privilege Escalation" - DEFENSE_EVASION = "Defense Evasion" - CREDENTIAL_ACCESS = "Credential Access" - DISCOVERY = "Discovery" - LATERAL_MOVEMENT = "Lateral Movement" - COLLECTION = "Collection" - COMMAND_AND_CONTROL = "Command and Control" - EXFILTRATION = "Exfiltration" - IMPACT = "Impact" - - -class Techniques(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Techniques of the assessment.""" - - ABUSE_ELEVATION_CONTROL_MECHANISM = "Abuse Elevation Control Mechanism" - ACCESS_TOKEN_MANIPULATION = "Access Token Manipulation" - ACCOUNT_DISCOVERY = "Account Discovery" - ACCOUNT_MANIPULATION = "Account Manipulation" - ACTIVE_SCANNING = "Active Scanning" - APPLICATION_LAYER_PROTOCOL = "Application Layer Protocol" - AUDIO_CAPTURE = "Audio Capture" - BOOT_OR_LOGON_AUTOSTART_EXECUTION = "Boot or Logon Autostart Execution" - BOOT_OR_LOGON_INITIALIZATION_SCRIPTS = "Boot or Logon Initialization Scripts" - BRUTE_FORCE = "Brute Force" - CLOUD_INFRASTRUCTURE_DISCOVERY = "Cloud Infrastructure Discovery" - CLOUD_SERVICE_DASHBOARD = "Cloud Service Dashboard" - CLOUD_SERVICE_DISCOVERY = "Cloud Service Discovery" - COMMAND_AND_SCRIPTING_INTERPRETER = "Command and Scripting Interpreter" - COMPROMISE_CLIENT_SOFTWARE_BINARY = "Compromise Client Software Binary" - COMPROMISE_INFRASTRUCTURE = "Compromise Infrastructure" - CONTAINER_AND_RESOURCE_DISCOVERY = "Container and Resource Discovery" - CREATE_ACCOUNT = "Create Account" - CREATE_OR_MODIFY_SYSTEM_PROCESS = "Create or Modify System Process" - CREDENTIALS_FROM_PASSWORD_STORES = "Credentials from Password Stores" - DATA_DESTRUCTION = "Data Destruction" - DATA_ENCRYPTED_FOR_IMPACT = "Data Encrypted for Impact" - DATA_FROM_CLOUD_STORAGE_OBJECT = "Data from Cloud Storage Object" - DATA_FROM_CONFIGURATION_REPOSITORY = "Data from Configuration Repository" - DATA_FROM_INFORMATION_REPOSITORIES = "Data from Information Repositories" - DATA_FROM_LOCAL_SYSTEM = "Data from Local System" - DATA_MANIPULATION = "Data Manipulation" - DATA_STAGED = "Data Staged" - DEFACEMENT = "Defacement" - DEOBFUSCATE_DECODE_FILES_OR_INFORMATION = "Deobfuscate/Decode Files or Information" - DISK_WIPE = "Disk Wipe" - DOMAIN_TRUST_DISCOVERY = "Domain Trust Discovery" - DRIVE_BY_COMPROMISE = "Drive-by Compromise" - DYNAMIC_RESOLUTION = "Dynamic Resolution" - ENDPOINT_DENIAL_OF_SERVICE = "Endpoint Denial of Service" - EVENT_TRIGGERED_EXECUTION = "Event Triggered Execution" - EXFILTRATION_OVER_ALTERNATIVE_PROTOCOL = "Exfiltration Over Alternative Protocol" - EXPLOIT_PUBLIC_FACING_APPLICATION = "Exploit Public-Facing Application" - EXPLOITATION_FOR_CLIENT_EXECUTION = "Exploitation for Client Execution" - EXPLOITATION_FOR_CREDENTIAL_ACCESS = "Exploitation for Credential Access" - EXPLOITATION_FOR_DEFENSE_EVASION = "Exploitation for Defense Evasion" - EXPLOITATION_FOR_PRIVILEGE_ESCALATION = "Exploitation for Privilege Escalation" - EXPLOITATION_OF_REMOTE_SERVICES = "Exploitation of Remote Services" - EXTERNAL_REMOTE_SERVICES = "External Remote Services" - FALLBACK_CHANNELS = "Fallback Channels" - FILE_AND_DIRECTORY_DISCOVERY = "File and Directory Discovery" - GATHER_VICTIM_NETWORK_INFORMATION = "Gather Victim Network Information" - HIDE_ARTIFACTS = "Hide Artifacts" - HIJACK_EXECUTION_FLOW = "Hijack Execution Flow" - IMPAIR_DEFENSES = "Impair Defenses" - IMPLANT_CONTAINER_IMAGE = "Implant Container Image" - INDICATOR_REMOVAL_ON_HOST = "Indicator Removal on Host" - INDIRECT_COMMAND_EXECUTION = "Indirect Command Execution" - INGRESS_TOOL_TRANSFER = "Ingress Tool Transfer" - INPUT_CAPTURE = "Input Capture" - INTER_PROCESS_COMMUNICATION = "Inter-Process Communication" - LATERAL_TOOL_TRANSFER = "Lateral Tool Transfer" - MAN_IN_THE_MIDDLE = "Man-in-the-Middle" - MASQUERADING = "Masquerading" - MODIFY_AUTHENTICATION_PROCESS = "Modify Authentication Process" - MODIFY_REGISTRY = "Modify Registry" - NETWORK_DENIAL_OF_SERVICE = "Network Denial of Service" - NETWORK_SERVICE_SCANNING = "Network Service Scanning" - NETWORK_SNIFFING = "Network Sniffing" - NON_APPLICATION_LAYER_PROTOCOL = "Non-Application Layer Protocol" - NON_STANDARD_PORT = "Non-Standard Port" - OBTAIN_CAPABILITIES = "Obtain Capabilities" - OBFUSCATED_FILES_OR_INFORMATION = "Obfuscated Files or Information" - OFFICE_APPLICATION_STARTUP = "Office Application Startup" - OS_CREDENTIAL_DUMPING = "OS Credential Dumping" - PERMISSION_GROUPS_DISCOVERY = "Permission Groups Discovery" - PHISHING = "Phishing" - PRE_OS_BOOT = "Pre-OS Boot" - PROCESS_DISCOVERY = "Process Discovery" - PROCESS_INJECTION = "Process Injection" - PROTOCOL_TUNNELING = "Protocol Tunneling" - PROXY = "Proxy" - QUERY_REGISTRY = "Query Registry" - REMOTE_ACCESS_SOFTWARE = "Remote Access Software" - REMOTE_SERVICE_SESSION_HIJACKING = "Remote Service Session Hijacking" - REMOTE_SERVICES = "Remote Services" - REMOTE_SYSTEM_DISCOVERY = "Remote System Discovery" - RESOURCE_HIJACKING = "Resource Hijacking" - SCHEDULED_TASK_JOB = "Scheduled Task/Job" - SCREEN_CAPTURE = "Screen Capture" - SEARCH_VICTIM_OWNED_WEBSITES = "Search Victim-Owned Websites" - SERVER_SOFTWARE_COMPONENT = "Server Software Component" - SERVICE_STOP = "Service Stop" - SIGNED_BINARY_PROXY_EXECUTION = "Signed Binary Proxy Execution" - SOFTWARE_DEPLOYMENT_TOOLS = "Software Deployment Tools" - SQL_STORED_PROCEDURES = "SQL Stored Procedures" - STEAL_OR_FORGE_KERBEROS_TICKETS = "Steal or Forge Kerberos Tickets" - SUBVERT_TRUST_CONTROLS = "Subvert Trust Controls" - SUPPLY_CHAIN_COMPROMISE = "Supply Chain Compromise" - SYSTEM_INFORMATION_DISCOVERY = "System Information Discovery" - TAINT_SHARED_CONTENT = "Taint Shared Content" - TRAFFIC_SIGNALING = "Traffic Signaling" - TRANSFER_DATA_TO_CLOUD_ACCOUNT = "Transfer Data to Cloud Account" - TRUSTED_RELATIONSHIP = "Trusted Relationship" - UNSECURED_CREDENTIALS = "Unsecured Credentials" - USER_EXECUTION = "User Execution" - VALID_ACCOUNTS = "Valid Accounts" - WINDOWS_MANAGEMENT_INSTRUMENTATION = "Windows Management Instrumentation" - FILE_AND_DIRECTORY_PERMISSIONS_MODIFICATION = "File and Directory Permissions Modification" - - -class Threats(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Threats impact of the assessment.""" - - ACCOUNT_BREACH = "accountBreach" - DATA_EXFILTRATION = "dataExfiltration" - DATA_SPILLAGE = "dataSpillage" - MALICIOUS_INSIDER = "maliciousInsider" - ELEVATION_OF_PRIVILEGE = "elevationOfPrivilege" - THREAT_RESISTANCE = "threatResistance" - MISSING_COVERAGE = "missingCoverage" - DENIAL_OF_SERVICE = "denialOfService" - - -class UserImpact(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The user impact of the assessment.""" - - LOW = "Low" - MODERATE = "Moderate" - HIGH = "High" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/__init__.py deleted file mode 100644 index 76294910e948..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._assessments_metadata_operations import AssessmentsMetadataOperations -from ._assessments_operations import AssessmentsOperations -from ._settings_operations import SettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AssessmentsMetadataOperations", - "AssessmentsOperations", - "SettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_metadata_operations.py deleted file mode 100644 index a4fd60e46363..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_metadata_operations.py +++ /dev/null @@ -1,668 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Security/assessmentMetadata") - - # 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_request(assessment_metadata_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}") - path_format_arguments = { - "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_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_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_in_subscription_request( - assessment_metadata_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_create_in_subscription_request( - assessment_metadata_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - } - - _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_in_subscription_request( - assessment_metadata_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AssessmentsMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_06_01.SecurityCenter`'s - :attr:`assessments_metadata` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadataResponse"]: - """Get metadata information on all assessment types. - - :return: An iterator like instance of either SecurityAssessmentMetadataResponse or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse] - :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._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentMetadataResponseList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityAssessmentMetadataResponse: - """Get metadata information on an assessment type. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - assessment_metadata_name=assessment_metadata_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadataResponse"]: - """Get metadata information on all assessment types in a specific subscription. - - :return: An iterator like instance of either SecurityAssessmentMetadataResponse or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse] - :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._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentMetadataResponseList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_in_subscription( - self, assessment_metadata_name: str, **kwargs: Any - ) -> _models.SecurityAssessmentMetadataResponse: - """Get metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) - - _request = build_get_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: _models.SecurityAssessmentMetadataResponse, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentMetadataResponse: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Required. - :type assessment_metadata: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentMetadataResponse: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Required. - :type assessment_metadata: 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: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: Union[_models.SecurityAssessmentMetadataResponse, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityAssessmentMetadataResponse: - """Create metadata information on an assessment type in a specific subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. Is either a - SecurityAssessmentMetadataResponse type or a IO[bytes] type. Required. - :type assessment_metadata: - ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse or IO[bytes] - :return: SecurityAssessmentMetadataResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(assessment_metadata, (IOBase, bytes)): - _content = assessment_metadata - else: - _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadataResponse") - - _request = build_create_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentMetadataResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_in_subscription( # pylint: disable=inconsistent-return-statements - self, assessment_metadata_name: str, **kwargs: Any - ) -> None: - """Delete metadata information on an assessment type in a specific subscription, will cause the - deletion of all the assessments of that type in that subscription. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - Required. - :type assessment_metadata_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_in_subscription_request( - assessment_metadata_name=assessment_metadata_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_operations.py deleted file mode 100644 index 2b6a70b4088f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_operations.py +++ /dev/null @@ -1,502 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/assessments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_id: str, assessment_name: str, *, expand: Optional[Union[str, _models.ExpandEnum]] = 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", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(resource_id: str, assessment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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", "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_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_delete_request(resource_id: str, assessment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_06_01.SecurityCenter`'s - :attr:`assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> Iterable["_models.SecurityAssessmentResponse"]: - """Get security assessments on all your scanned resources inside a scope. - - :param scope: Scope of the query, can be subscription - (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group - (/providers/Microsoft.Management/managementGroups/mgName). Required. - :type scope: str - :return: An iterator like instance of either SecurityAssessmentResponse or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse] - :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._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityAssessmentList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_id: str, - assessment_name: str, - expand: Optional[Union[str, _models.ExpandEnum]] = None, - **kwargs: Any - ) -> _models.SecurityAssessmentResponse: - """Get a security assessment on your scanned resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param expand: OData expand. Optional. Known values are: "links" and "metadata". Default value - is None. - :type expand: str or ~azure.mgmt.security.v2021_06_01.models.ExpandEnum - :return: SecurityAssessmentResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - assessment_name=assessment_name, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityAssessmentResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: _models.SecurityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentResponse: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. - :type assessment: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityAssessmentResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityAssessmentResponse: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Required. - :type assessment: 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: SecurityAssessmentResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: Union[_models.SecurityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityAssessmentResponse: - """Create a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. Is either a - SecurityAssessment type or a IO[bytes] type. Required. - :type assessment: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessment or IO[bytes] - :return: SecurityAssessmentResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(assessment, (IOBase, bytes)): - _content = assessment - else: - _json = self._serialize.body(assessment, "SecurityAssessment") - - _request = build_create_or_update_request( - resource_id=resource_id, - assessment_name=assessment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityAssessmentResponse", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityAssessmentResponse", pipeline_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_id: str, assessment_name: str, **kwargs: Any - ) -> None: - """Delete a security assessment on your resource. An assessment metadata that describes this - assessment must be predefined with the same name before inserting the assessment result. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. Required. - :type assessment_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_id=resource_id, - assessment_name=assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_settings_operations.py deleted file mode 100644 index d2ee78a8476b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_settings_operations.py +++ /dev/null @@ -1,396 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(setting_name: Union[str, _models.Enum12], subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "settingName": _SERIALIZER.url("setting_name", setting_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_update_request(setting_name: Union[str, _models.Enum12], subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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}/providers/Microsoft.Security/settings/{settingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "settingName": _SERIALIZER.url("setting_name", setting_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) - - -class SettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_06_01.SecurityCenter`'s - :attr:`settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: - """Settings about different configurations in Microsoft Defender for Cloud. - - :return: An iterator like instance of either Setting or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_06_01.models.Setting] - :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._api_version or "2021-06-01")) - cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SettingsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, setting_name: Union[str, _models.Enum12], **kwargs: Any) -> _models.Setting: - """Settings of different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and - "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_06_01.models.Enum12 - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - setting_name: Union[str, _models.Enum12], - setting: _models.Setting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and - "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_06_01.models.Enum12 - :param setting: Setting object. Required. - :type setting: ~azure.mgmt.security.v2021_06_01.models.Setting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - setting_name: Union[str, _models.Enum12], - setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and - "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_06_01.models.Enum12 - :param setting: Setting object. Required. - :type setting: 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: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, setting_name: Union[str, _models.Enum12], setting: Union[_models.Setting, IO[bytes]], **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and - "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_06_01.models.Enum12 - :param setting: Setting object. Is either a Setting type or a IO[bytes] type. Required. - :type setting: ~azure.mgmt.security.v2021_06_01.models.Setting or IO[bytes] - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(setting, (IOBase, bytes)): - _content = setting - else: - _json = self._serialize.body(setting, "Setting") - - _request = build_update_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_configuration.py deleted file mode 100644 index 2a41ad89570d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-07-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_metadata.json deleted file mode 100644 index 9fae64cfa56e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2021-07-01", - "total_api_version_list": ["2021-07-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "settings": "SettingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_security_center.py deleted file mode 100644 index 84fcfd293b5f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_security_center.py +++ /dev/null @@ -1,107 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar settings: SettingsOperations operations - :vartype settings: azure.mgmt.security.v2021_07_01.operations.SettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_configuration.py deleted file mode 100644 index f375c91110da..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-07-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_security_center.py deleted file mode 100644 index b64146988157..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_security_center.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar settings: SettingsOperations operations - :vartype settings: azure.mgmt.security.v2021_07_01.aio.operations.SettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/__init__.py deleted file mode 100644 index 1046445c98b6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._settings_operations import SettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_settings_operations.py deleted file mode 100644 index 191310fe2d70..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_settings_operations.py +++ /dev/null @@ -1,308 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._settings_operations import build_get_request, build_list_request, build_update_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_07_01.aio.SecurityCenter`'s - :attr:`settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: - """Settings about different configurations in Microsoft Defender for Cloud. - - :return: An iterator like instance of either Setting or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_07_01.models.Setting] - :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._api_version or "2021-07-01")) - cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SettingsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _models.Setting: - """Settings of different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_07_01.models.SettingName - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - setting_name: Union[str, _models.SettingName], - setting: _models.Setting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_07_01.models.SettingName - :param setting: Setting object. Required. - :type setting: ~azure.mgmt.security.v2021_07_01.models.Setting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - setting_name: Union[str, _models.SettingName], - setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_07_01.models.SettingName - :param setting: Setting object. Required. - :type setting: 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: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, setting_name: Union[str, _models.SettingName], setting: Union[_models.Setting, IO[bytes]], **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_07_01.models.SettingName - :param setting: Setting object. Is either a Setting type or a IO[bytes] type. Required. - :type setting: ~azure.mgmt.security.v2021_07_01.models.Setting or IO[bytes] - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(setting, (IOBase, bytes)): - _content = setting - else: - _json = self._serialize.body(setting, "Setting") - - _request = build_update_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/__init__.py deleted file mode 100644 index ce862c57b5f2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/__init__.py +++ /dev/null @@ -1,35 +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 ._models_py3 import AlertSyncSettings -from ._models_py3 import CloudErrorBody -from ._models_py3 import DataExportSettings -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Resource -from ._models_py3 import Setting -from ._models_py3 import SettingsList - -from ._security_center_enums import SettingKind -from ._security_center_enums import SettingName -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertSyncSettings", - "CloudErrorBody", - "DataExportSettings", - "ErrorAdditionalInfo", - "Resource", - "Setting", - "SettingsList", - "SettingKind", - "SettingName", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_models_py3.py deleted file mode 100644 index f8fd85d8586d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_models_py3.py +++ /dev/null @@ -1,283 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Setting(Resource): - """The kind of the security setting. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AlertSyncSettings, DataExportSettings - - 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: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", - "AlertSuppressionSetting", and "AlertSyncSettings". - :vartype kind: str or ~azure.mgmt.security.v2021_07_01.models.SettingKind - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - } - - _subtype_map = {"kind": {"AlertSyncSettings": "AlertSyncSettings", "DataExportSettings": "DataExportSettings"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - - -class AlertSyncSettings(Setting): - """Represents an alert sync setting. - - 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: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", - "AlertSuppressionSetting", and "AlertSyncSettings". - :vartype kind: str or ~azure.mgmt.security.v2021_07_01.models.SettingKind - :ivar enabled: Is the alert sync setting enabled. - :vartype enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is the alert sync setting enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.kind: str = "AlertSyncSettings" - self.enabled = enabled - - -class CloudErrorBody(_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.security.v2021_07_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2021_07_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class DataExportSettings(Setting): - """Represents a data export setting. - - 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: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", - "AlertSuppressionSetting", and "AlertSyncSettings". - :vartype kind: str or ~azure.mgmt.security.v2021_07_01.models.SettingKind - :ivar enabled: Is the data export setting enabled. - :vartype enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is the data export setting enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.kind: str = "DataExportSettings" - self.enabled = enabled - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class SettingsList(_serialization.Model): - """Subscription settings list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The settings list. - :vartype value: list[~azure.mgmt.security.v2021_07_01.models.Setting] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Setting]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Setting"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The settings list. - :paramtype value: list[~azure.mgmt.security.v2021_07_01.models.Setting] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_security_center_enums.py deleted file mode 100644 index a8c079d4a92a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_security_center_enums.py +++ /dev/null @@ -1,27 +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 SettingKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the kind of the settings string.""" - - DATA_EXPORT_SETTINGS = "DataExportSettings" - ALERT_SUPPRESSION_SETTING = "AlertSuppressionSetting" - ALERT_SYNC_SETTINGS = "AlertSyncSettings" - - -class SettingName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SettingName.""" - - MCAS = "MCAS" - WDATP = "WDATP" - WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW = "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW" - SENTINEL = "Sentinel" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/__init__.py deleted file mode 100644 index 1046445c98b6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._settings_operations import SettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_settings_operations.py deleted file mode 100644 index ff8d799d2b7e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_settings_operations.py +++ /dev/null @@ -1,400 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request( - setting_name: Union[str, _models.SettingName], subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "settingName": _SERIALIZER.url("setting_name", setting_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_update_request( - setting_name: Union[str, _models.SettingName], subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "settingName": _SERIALIZER.url("setting_name", setting_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) - - -class SettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_07_01.SecurityCenter`'s - :attr:`settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: - """Settings about different configurations in Microsoft Defender for Cloud. - - :return: An iterator like instance of either Setting or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_07_01.models.Setting] - :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._api_version or "2021-07-01")) - cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SettingsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _models.Setting: - """Settings of different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_07_01.models.SettingName - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - setting_name: Union[str, _models.SettingName], - setting: _models.Setting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_07_01.models.SettingName - :param setting: Setting object. Required. - :type setting: ~azure.mgmt.security.v2021_07_01.models.Setting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - setting_name: Union[str, _models.SettingName], - setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_07_01.models.SettingName - :param setting: Setting object. Required. - :type setting: 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: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, setting_name: Union[str, _models.SettingName], setting: Union[_models.Setting, IO[bytes]], **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2021_07_01.models.SettingName - :param setting: Setting object. Is either a Setting type or a IO[bytes] type. Required. - :type setting: ~azure.mgmt.security.v2021_07_01.models.Setting or IO[bytes] - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(setting, (IOBase, bytes)): - _content = setting - else: - _json = self._serialize.body(setting, "Setting") - - _request = build_update_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_configuration.py deleted file mode 100644 index 17d795debae0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-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", "2021-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_metadata.json deleted file mode 100644 index 32943b42b47c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2021-07-01-preview", - "total_api_version_list": ["2021-07-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "custom_assessment_automations": "CustomAssessmentAutomationsOperations", - "custom_entity_store_assignments": "CustomEntityStoreAssignmentsOperations", - "security_connectors": "SecurityConnectorsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_security_center.py deleted file mode 100644 index 313d87834dd0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_security_center.py +++ /dev/null @@ -1,126 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - CustomAssessmentAutomationsOperations, - CustomEntityStoreAssignmentsOperations, - SecurityConnectorsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar custom_assessment_automations: CustomAssessmentAutomationsOperations operations - :vartype custom_assessment_automations: - azure.mgmt.security.v2021_07_01_preview.operations.CustomAssessmentAutomationsOperations - :ivar custom_entity_store_assignments: CustomEntityStoreAssignmentsOperations operations - :vartype custom_entity_store_assignments: - azure.mgmt.security.v2021_07_01_preview.operations.CustomEntityStoreAssignmentsOperations - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2021_07_01_preview.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.custom_assessment_automations = CustomAssessmentAutomationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.custom_entity_store_assignments = CustomEntityStoreAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_configuration.py deleted file mode 100644 index 8ba58b89cf62..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-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", "2021-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_security_center.py deleted file mode 100644 index cf27d5c0fe80..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_security_center.py +++ /dev/null @@ -1,128 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - CustomAssessmentAutomationsOperations, - CustomEntityStoreAssignmentsOperations, - SecurityConnectorsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar custom_assessment_automations: CustomAssessmentAutomationsOperations operations - :vartype custom_assessment_automations: - azure.mgmt.security.v2021_07_01_preview.aio.operations.CustomAssessmentAutomationsOperations - :ivar custom_entity_store_assignments: CustomEntityStoreAssignmentsOperations operations - :vartype custom_entity_store_assignments: - azure.mgmt.security.v2021_07_01_preview.aio.operations.CustomEntityStoreAssignmentsOperations - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2021_07_01_preview.aio.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.custom_assessment_automations = CustomAssessmentAutomationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.custom_entity_store_assignments = CustomEntityStoreAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/__init__.py deleted file mode 100644 index 395581c73e89..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._custom_assessment_automations_operations import CustomAssessmentAutomationsOperations -from ._custom_entity_store_assignments_operations import CustomEntityStoreAssignmentsOperations -from ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomAssessmentAutomationsOperations", - "CustomEntityStoreAssignmentsOperations", - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py deleted file mode 100644 index 65a42b6b65ce..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py +++ /dev/null @@ -1,506 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._custom_assessment_automations_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CustomAssessmentAutomationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_07_01_preview.aio.SecurityCenter`'s - :attr:`custom_assessment_automations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, resource_group_name: str, custom_assessment_automation_name: str, **kwargs: Any - ) -> _models.CustomAssessmentAutomation: - """Gets a custom assessment automation. - - Gets a single custom assessment automation by name for the provided subscription and resource - group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :return: CustomAssessmentAutomation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - custom_assessment_automation_name=custom_assessment_automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomAssessmentAutomation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - resource_group_name: str, - custom_assessment_automation_name: str, - custom_assessment_automation_body: _models.CustomAssessmentAutomationRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CustomAssessmentAutomation: - """Creates a custom assessment automation. - - Creates or updates a custom assessment automation for the provided subscription. Please note - that providing an existing custom assessment automation will replace the existing record. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :param custom_assessment_automation_body: Custom Assessment Automation body. Required. - :type custom_assessment_automation_body: - ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomationRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CustomAssessmentAutomation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - custom_assessment_automation_name: str, - custom_assessment_automation_body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CustomAssessmentAutomation: - """Creates a custom assessment automation. - - Creates or updates a custom assessment automation for the provided subscription. Please note - that providing an existing custom assessment automation will replace the existing record. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :param custom_assessment_automation_body: Custom Assessment Automation body. Required. - :type custom_assessment_automation_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: CustomAssessmentAutomation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - custom_assessment_automation_name: str, - custom_assessment_automation_body: Union[_models.CustomAssessmentAutomationRequest, IO[bytes]], - **kwargs: Any - ) -> _models.CustomAssessmentAutomation: - """Creates a custom assessment automation. - - Creates or updates a custom assessment automation for the provided subscription. Please note - that providing an existing custom assessment automation will replace the existing record. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :param custom_assessment_automation_body: Custom Assessment Automation body. Is either a - CustomAssessmentAutomationRequest type or a IO[bytes] type. Required. - :type custom_assessment_automation_body: - ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomationRequest or IO[bytes] - :return: CustomAssessmentAutomation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_assessment_automation_body, (IOBase, bytes)): - _content = custom_assessment_automation_body - else: - _json = self._serialize.body(custom_assessment_automation_body, "CustomAssessmentAutomationRequest") - - _request = build_create_request( - resource_group_name=resource_group_name, - custom_assessment_automation_name=custom_assessment_automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("CustomAssessmentAutomation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomAssessmentAutomation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, custom_assessment_automation_name: str, **kwargs: Any - ) -> None: - """Deletes a custom assessment automation. - - Deletes a custom assessment automation by name for a provided subscription. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - custom_assessment_automation_name=custom_assessment_automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CustomAssessmentAutomation"]: - """List custom assessment automations in a subscription and a resource group. - - List custom assessment automations by provided subscription and resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either CustomAssessmentAutomation or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomAssessmentAutomationsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomAssessmentAutomationsListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomAssessmentAutomation"]: - """List custom assessment automations in a subscription. - - List custom assessment automations by provided subscription. - - :return: An iterator like instance of either CustomAssessmentAutomation or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomAssessmentAutomationsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomAssessmentAutomationsListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py deleted file mode 100644 index ed2422d86fef..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py +++ /dev/null @@ -1,512 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._custom_entity_store_assignments_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CustomEntityStoreAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_07_01_preview.aio.SecurityCenter`'s - :attr:`custom_entity_store_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, resource_group_name: str, custom_entity_store_assignment_name: str, **kwargs: Any - ) -> _models.CustomEntityStoreAssignment: - """Gets a custom entity store assignment. - - Gets a single custom entity store assignment by name for the provided subscription and resource - group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :return: CustomEntityStoreAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - custom_entity_store_assignment_name=custom_entity_store_assignment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomEntityStoreAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - resource_group_name: str, - custom_entity_store_assignment_name: str, - custom_entity_store_assignment_request_body: _models.CustomEntityStoreAssignmentRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CustomEntityStoreAssignment: - """Creates a custom entity store assignment. - - Creates a custom entity store assignment for the provided subscription, if not already exists. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :param custom_entity_store_assignment_request_body: Custom entity store assignment body. - Required. - :type custom_entity_store_assignment_request_body: - ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignmentRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CustomEntityStoreAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - custom_entity_store_assignment_name: str, - custom_entity_store_assignment_request_body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CustomEntityStoreAssignment: - """Creates a custom entity store assignment. - - Creates a custom entity store assignment for the provided subscription, if not already exists. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :param custom_entity_store_assignment_request_body: Custom entity store assignment body. - Required. - :type custom_entity_store_assignment_request_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: CustomEntityStoreAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - custom_entity_store_assignment_name: str, - custom_entity_store_assignment_request_body: Union[_models.CustomEntityStoreAssignmentRequest, IO[bytes]], - **kwargs: Any - ) -> _models.CustomEntityStoreAssignment: - """Creates a custom entity store assignment. - - Creates a custom entity store assignment for the provided subscription, if not already exists. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :param custom_entity_store_assignment_request_body: Custom entity store assignment body. Is - either a CustomEntityStoreAssignmentRequest type or a IO[bytes] type. Required. - :type custom_entity_store_assignment_request_body: - ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignmentRequest or IO[bytes] - :return: CustomEntityStoreAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_entity_store_assignment_request_body, (IOBase, bytes)): - _content = custom_entity_store_assignment_request_body - else: - _json = self._serialize.body( - custom_entity_store_assignment_request_body, "CustomEntityStoreAssignmentRequest" - ) - - _request = build_create_request( - resource_group_name=resource_group_name, - custom_entity_store_assignment_name=custom_entity_store_assignment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("CustomEntityStoreAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomEntityStoreAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, custom_entity_store_assignment_name: str, **kwargs: Any - ) -> None: - """Deleted a custom entity store assignment. - - Delete a custom entity store assignment by name for a provided subscription. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - custom_entity_store_assignment_name=custom_entity_store_assignment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CustomEntityStoreAssignment"]: - """List custom entity store assignments in a subscription and a resource group. - - List custom entity store assignments by a provided subscription and resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either CustomEntityStoreAssignment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomEntityStoreAssignmentsListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomEntityStoreAssignment"]: - """List custom entity store assignments in a subscription. - - List custom entity store assignments by provided subscription. - - :return: An iterator like instance of either CustomEntityStoreAssignment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomEntityStoreAssignmentsListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py deleted file mode 100644 index 2c3c6fcb6562..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py +++ /dev/null @@ -1,625 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_connectors_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_07_01_preview.aio.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/__init__.py deleted file mode 100644 index 4e9aeed6ee6e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/__init__.py +++ /dev/null @@ -1,93 +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 ._models_py3 import AzureTrackedResourceLocation -from ._models_py3 import CloudErrorBody -from ._models_py3 import CloudOffering -from ._models_py3 import CspmMonitorAwsOffering -from ._models_py3 import CspmMonitorAwsOfferingNativeCloudConnection -from ._models_py3 import CustomAssessmentAutomation -from ._models_py3 import CustomAssessmentAutomationRequest -from ._models_py3 import CustomAssessmentAutomationsListResult -from ._models_py3 import CustomEntityStoreAssignment -from ._models_py3 import CustomEntityStoreAssignmentRequest -from ._models_py3 import CustomEntityStoreAssignmentsListResult -from ._models_py3 import DefenderForContainersAwsOffering -from ._models_py3 import DefenderForContainersAwsOfferingCloudWatchToKinesis -from ._models_py3 import DefenderForContainersAwsOfferingKinesisToS3 -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesScubaReader -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesService -from ._models_py3 import DefenderForServersAwsOffering -from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata -from ._models_py3 import DefenderForServersAwsOfferingDefenderForServers -from ._models_py3 import ETag -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import InformationProtectionAwsOffering -from ._models_py3 import InformationProtectionAwsOfferingInformationProtection -from ._models_py3 import Kind -from ._models_py3 import Resource -from ._models_py3 import SecurityConnector -from ._models_py3 import SecurityConnectorPropertiesOrganizationalData -from ._models_py3 import SecurityConnectorsList -from ._models_py3 import SystemData -from ._models_py3 import Tags -from ._models_py3 import TrackedResource - -from ._security_center_enums import CloudName -from ._security_center_enums import CreatedByType -from ._security_center_enums import OfferingType -from ._security_center_enums import OrganizationMembershipType -from ._security_center_enums import SeverityEnum -from ._security_center_enums import SupportedCloudEnum -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureTrackedResourceLocation", - "CloudErrorBody", - "CloudOffering", - "CspmMonitorAwsOffering", - "CspmMonitorAwsOfferingNativeCloudConnection", - "CustomAssessmentAutomation", - "CustomAssessmentAutomationRequest", - "CustomAssessmentAutomationsListResult", - "CustomEntityStoreAssignment", - "CustomEntityStoreAssignmentRequest", - "CustomEntityStoreAssignmentsListResult", - "DefenderForContainersAwsOffering", - "DefenderForContainersAwsOfferingCloudWatchToKinesis", - "DefenderForContainersAwsOfferingKinesisToS3", - "DefenderForContainersAwsOfferingKubernetesScubaReader", - "DefenderForContainersAwsOfferingKubernetesService", - "DefenderForServersAwsOffering", - "DefenderForServersAwsOfferingArcAutoProvisioning", - "DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata", - "DefenderForServersAwsOfferingDefenderForServers", - "ETag", - "ErrorAdditionalInfo", - "InformationProtectionAwsOffering", - "InformationProtectionAwsOfferingInformationProtection", - "Kind", - "Resource", - "SecurityConnector", - "SecurityConnectorPropertiesOrganizationalData", - "SecurityConnectorsList", - "SystemData", - "Tags", - "TrackedResource", - "CloudName", - "CreatedByType", - "OfferingType", - "OrganizationMembershipType", - "SeverityEnum", - "SupportedCloudEnum", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_models_py3.py deleted file mode 100644 index 9928221fb257..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_models_py3.py +++ /dev/null @@ -1,1367 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AzureTrackedResourceLocation(_serialization.Model): - """Describes an Azure resource with location. - - :ivar location: Location where the resource is stored. - :vartype location: str - """ - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - - -class CloudErrorBody(_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.security.v2021_07_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2021_07_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class CloudOffering(_serialization.Model): - """The security offering details. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - CspmMonitorAwsOffering, DefenderForContainersAwsOffering, DefenderForServersAwsOffering, - InformationProtectionAwsOffering - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", and - "InformationProtectionAws". - :vartype offering_type: str or ~azure.mgmt.security.v2021_07_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - _subtype_map = { - "offering_type": { - "CspmMonitorAws": "CspmMonitorAwsOffering", - "DefenderForContainersAws": "DefenderForContainersAwsOffering", - "DefenderForServersAws": "DefenderForServersAwsOffering", - "InformationProtectionAws": "InformationProtectionAwsOffering", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: Optional[str] = None - self.description = None - - -class CspmMonitorAwsOffering(CloudOffering): - """The CSPM monitoring for AWS offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", and - "InformationProtectionAws". - :vartype offering_type: str or ~azure.mgmt.security.v2021_07_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2021_07_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "CspmMonitorAwsOfferingNativeCloudConnection", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.CspmMonitorAwsOfferingNativeCloudConnection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2021_07_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorAws" - self.native_cloud_connection = native_cloud_connection - - -class CspmMonitorAwsOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class CustomAssessmentAutomation(Resource): # pylint: disable=too-many-instance-attributes - """Custom Assessment Automation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2021_07_01_preview.models.SystemData - :ivar compressed_query: GZip encoded KQL query representing the assessment automation results - required. - :vartype compressed_query: str - :ivar supported_cloud: Relevant cloud for the custom assessment automation. Known values are: - "AWS" and "GCP". - :vartype supported_cloud: str or - ~azure.mgmt.security.v2021_07_01_preview.models.SupportedCloudEnum - :ivar severity: The severity to relate to the assessments generated by this assessment - automation. Known values are: "High", "Medium", and "Low". - :vartype severity: str or ~azure.mgmt.security.v2021_07_01_preview.models.SeverityEnum - :ivar display_name: The display name of the assessments generated by this assessment - automation. - :vartype display_name: str - :ivar description: The description to relate to the assessments generated by this assessment - automation. - :vartype description: str - :ivar remediation_description: The remediation description to relate to the assessments - generated by this assessment automation. - :vartype remediation_description: str - :ivar assessment_key: The assessment metadata key used when an assessment is generated for this - assessment automation. - :vartype assessment_key: str - """ - - _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"}, - "compressed_query": {"key": "properties.compressedQuery", "type": "str"}, - "supported_cloud": {"key": "properties.supportedCloud", "type": "str"}, - "severity": {"key": "properties.severity", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, - "assessment_key": {"key": "properties.assessmentKey", "type": "str"}, - } - - def __init__( - self, - *, - compressed_query: Optional[str] = None, - supported_cloud: Union[str, "_models.SupportedCloudEnum"] = "AWS", - severity: Union[str, "_models.SeverityEnum"] = "Low", - display_name: Optional[str] = None, - description: Optional[str] = None, - remediation_description: Optional[str] = None, - assessment_key: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword compressed_query: GZip encoded KQL query representing the assessment automation - results required. - :paramtype compressed_query: str - :keyword supported_cloud: Relevant cloud for the custom assessment automation. Known values - are: "AWS" and "GCP". - :paramtype supported_cloud: str or - ~azure.mgmt.security.v2021_07_01_preview.models.SupportedCloudEnum - :keyword severity: The severity to relate to the assessments generated by this assessment - automation. Known values are: "High", "Medium", and "Low". - :paramtype severity: str or ~azure.mgmt.security.v2021_07_01_preview.models.SeverityEnum - :keyword display_name: The display name of the assessments generated by this assessment - automation. - :paramtype display_name: str - :keyword description: The description to relate to the assessments generated by this assessment - automation. - :paramtype description: str - :keyword remediation_description: The remediation description to relate to the assessments - generated by this assessment automation. - :paramtype remediation_description: str - :keyword assessment_key: The assessment metadata key used when an assessment is generated for - this assessment automation. - :paramtype assessment_key: str - """ - super().__init__(**kwargs) - self.system_data = None - self.compressed_query = compressed_query - self.supported_cloud = supported_cloud - self.severity = severity - self.display_name = display_name - self.description = description - self.remediation_description = remediation_description - self.assessment_key = assessment_key - - -class CustomAssessmentAutomationRequest(Resource): - """Custom Assessment Automation request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar compressed_query: Base 64 encoded KQL query representing the assessment automation - results required. - :vartype compressed_query: str - :ivar supported_cloud: Relevant cloud for the custom assessment automation. Known values are: - "AWS" and "GCP". - :vartype supported_cloud: str or - ~azure.mgmt.security.v2021_07_01_preview.models.SupportedCloudEnum - :ivar severity: The severity to relate to the assessments generated by this assessment - automation. Known values are: "High", "Medium", and "Low". - :vartype severity: str or ~azure.mgmt.security.v2021_07_01_preview.models.SeverityEnum - :ivar display_name: The display name of the assessments generated by this assessment - automation. - :vartype display_name: str - :ivar description: The description to relate to the assessments generated by this assessment - automation. - :vartype description: str - :ivar remediation_description: The remediation description to relate to the assessments - generated by this assessment automation. - :vartype remediation_description: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "compressed_query": {"key": "properties.compressedQuery", "type": "str"}, - "supported_cloud": {"key": "properties.supportedCloud", "type": "str"}, - "severity": {"key": "properties.severity", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "remediation_description": {"key": "properties.remediationDescription", "type": "str"}, - } - - def __init__( - self, - *, - compressed_query: Optional[str] = None, - supported_cloud: Union[str, "_models.SupportedCloudEnum"] = "AWS", - severity: Union[str, "_models.SeverityEnum"] = "Low", - display_name: Optional[str] = None, - description: Optional[str] = None, - remediation_description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword compressed_query: Base 64 encoded KQL query representing the assessment automation - results required. - :paramtype compressed_query: str - :keyword supported_cloud: Relevant cloud for the custom assessment automation. Known values - are: "AWS" and "GCP". - :paramtype supported_cloud: str or - ~azure.mgmt.security.v2021_07_01_preview.models.SupportedCloudEnum - :keyword severity: The severity to relate to the assessments generated by this assessment - automation. Known values are: "High", "Medium", and "Low". - :paramtype severity: str or ~azure.mgmt.security.v2021_07_01_preview.models.SeverityEnum - :keyword display_name: The display name of the assessments generated by this assessment - automation. - :paramtype display_name: str - :keyword description: The description to relate to the assessments generated by this assessment - automation. - :paramtype description: str - :keyword remediation_description: The remediation description to relate to the assessments - generated by this assessment automation. - :paramtype remediation_description: str - """ - super().__init__(**kwargs) - self.compressed_query = compressed_query - self.supported_cloud = supported_cloud - self.severity = severity - self.display_name = display_name - self.description = description - self.remediation_description = remediation_description - - -class CustomAssessmentAutomationsListResult(_serialization.Model): - """A list of Custom Assessment Automations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of Custom Assessment Automations. - :vartype value: - list[~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation] - :ivar next_link: The link used to get the next page of operations. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CustomAssessmentAutomation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link used to get the next page of operations. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class CustomEntityStoreAssignment(Resource): - """Custom entity store assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2021_07_01_preview.models.SystemData - :ivar principal: The principal assigned with entity store. Format of principal is: [AAD - type]=[PrincipalObjectId];[TenantId]. - :vartype principal: str - :ivar entity_store_database_link: The link to entity store database. - :vartype entity_store_database_link: str - """ - - _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"}, - "principal": {"key": "properties.principal", "type": "str"}, - "entity_store_database_link": {"key": "properties.entityStoreDatabaseLink", "type": "str"}, - } - - def __init__( - self, *, principal: Optional[str] = None, entity_store_database_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword principal: The principal assigned with entity store. Format of principal is: [AAD - type]=[PrincipalObjectId];[TenantId]. - :paramtype principal: str - :keyword entity_store_database_link: The link to entity store database. - :paramtype entity_store_database_link: str - """ - super().__init__(**kwargs) - self.system_data = None - self.principal = principal - self.entity_store_database_link = entity_store_database_link - - -class CustomEntityStoreAssignmentRequest(_serialization.Model): - """describes the custom entity store assignment request. - - :ivar principal: The principal assigned with entity store. If not provided, will use caller - principal. Format of principal is: [AAD type]=[PrincipalObjectId];[TenantId]. - :vartype principal: str - """ - - _attribute_map = { - "principal": {"key": "properties.principal", "type": "str"}, - } - - def __init__(self, *, principal: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal: The principal assigned with entity store. If not provided, will use caller - principal. Format of principal is: [AAD type]=[PrincipalObjectId];[TenantId]. - :paramtype principal: str - """ - super().__init__(**kwargs) - self.principal = principal - - -class CustomEntityStoreAssignmentsListResult(_serialization.Model): - """A list of custom entity store assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of custom entity store assignments. - :vartype value: - list[~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment] - :ivar next_link: The link used to get the next page of operations. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CustomEntityStoreAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link used to get the next page of operations. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class DefenderForContainersAwsOffering(CloudOffering): - """The Defender for Containers AWS offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", and - "InformationProtectionAws". - :vartype offering_type: str or ~azure.mgmt.security.v2021_07_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar kubernetes_service: The kubernetes service connection configuration. - :vartype kubernetes_service: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :ivar kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :vartype kubernetes_scuba_reader: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :ivar cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :vartype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :ivar kinesis_to_s3: The kinesis to s3 connection configuration. - :vartype kinesis_to_s3: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "kubernetes_service": {"key": "kubernetesService", "type": "DefenderForContainersAwsOfferingKubernetesService"}, - "kubernetes_scuba_reader": { - "key": "kubernetesScubaReader", - "type": "DefenderForContainersAwsOfferingKubernetesScubaReader", - }, - "cloud_watch_to_kinesis": { - "key": "cloudWatchToKinesis", - "type": "DefenderForContainersAwsOfferingCloudWatchToKinesis", - }, - "kinesis_to_s3": {"key": "kinesisToS3", "type": "DefenderForContainersAwsOfferingKinesisToS3"}, - } - - def __init__( - self, - *, - kubernetes_service: Optional["_models.DefenderForContainersAwsOfferingKubernetesService"] = None, - kubernetes_scuba_reader: Optional["_models.DefenderForContainersAwsOfferingKubernetesScubaReader"] = None, - cloud_watch_to_kinesis: Optional["_models.DefenderForContainersAwsOfferingCloudWatchToKinesis"] = None, - kinesis_to_s3: Optional["_models.DefenderForContainersAwsOfferingKinesisToS3"] = None, - **kwargs: Any - ) -> None: - """ - :keyword kubernetes_service: The kubernetes service connection configuration. - :paramtype kubernetes_service: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :keyword kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :paramtype kubernetes_scuba_reader: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :keyword cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :paramtype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :keyword kinesis_to_s3: The kinesis to s3 connection configuration. - :paramtype kinesis_to_s3: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForContainersAws" - self.kubernetes_service = kubernetes_service - self.kubernetes_scuba_reader = kubernetes_scuba_reader - self.cloud_watch_to_kinesis = cloud_watch_to_kinesis - self.kinesis_to_s3 = kinesis_to_s3 - - -class DefenderForContainersAwsOfferingCloudWatchToKinesis(_serialization.Model): # pylint: disable=name-too-long - """The cloudwatch to kinesis connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKinesisToS3(_serialization.Model): # pylint: disable=name-too-long - """The kinesis to s3 connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesScubaReader(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes to scuba connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesService(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes service connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForServersAwsOffering(CloudOffering): - """The Defender for Servers AWS offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", and - "InformationProtectionAws". - :vartype offering_type: str or ~azure.mgmt.security.v2021_07_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar defender_for_servers: The Defender for servers connection configuration. - :vartype defender_for_servers: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "defender_for_servers": { - "key": "defenderForServers", - "type": "DefenderForServersAwsOfferingDefenderForServers", - }, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForServersAwsOfferingArcAutoProvisioning", - }, - } - - def __init__( - self, - *, - defender_for_servers: Optional["_models.DefenderForServersAwsOfferingDefenderForServers"] = None, - arc_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioning"] = None, - **kwargs: Any - ) -> None: - """ - :keyword defender_for_servers: The Defender for servers connection configuration. - :paramtype defender_for_servers: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForServersAws" - self.defender_for_servers = defender_for_servers - self.arc_auto_provisioning = arc_auto_provisioning - - -class DefenderForServersAwsOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar service_principal_secret_metadata: Metadata of Service Principal secret for - autoprovisioning. - :vartype service_principal_secret_metadata: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata # pylint: disable=line-too-long - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "service_principal_secret_metadata": { - "key": "servicePrincipalSecretMetadata", - "type": "DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - service_principal_secret_metadata: Optional[ - "_models.DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword service_principal_secret_metadata: Metadata of Service Principal secret for - autoprovisioning. - :paramtype service_principal_secret_metadata: - ~azure.mgmt.security.v2021_07_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.enabled = enabled - self.service_principal_secret_metadata = service_principal_secret_metadata - - -class DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata( - _serialization.Model -): # pylint: disable=name-too-long - """Metadata of Service Principal secret for autoprovisioning. - - :ivar expiry_date: expiration date of service principal secret. - :vartype expiry_date: str - :ivar parameter_store_region: region of parameter store where secret is kept. - :vartype parameter_store_region: str - :ivar parameter_name_in_store: name of secret resource in parameter store. - :vartype parameter_name_in_store: str - """ - - _attribute_map = { - "expiry_date": {"key": "expiryDate", "type": "str"}, - "parameter_store_region": {"key": "parameterStoreRegion", "type": "str"}, - "parameter_name_in_store": {"key": "parameterNameInStore", "type": "str"}, - } - - def __init__( - self, - *, - expiry_date: Optional[str] = None, - parameter_store_region: Optional[str] = None, - parameter_name_in_store: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword expiry_date: expiration date of service principal secret. - :paramtype expiry_date: str - :keyword parameter_store_region: region of parameter store where secret is kept. - :paramtype parameter_store_region: str - :keyword parameter_name_in_store: name of secret resource in parameter store. - :paramtype parameter_name_in_store: str - """ - super().__init__(**kwargs) - self.expiry_date = expiry_date - self.parameter_store_region = parameter_store_region - self.parameter_name_in_store = parameter_name_in_store - - -class DefenderForServersAwsOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long - """The Defender for servers connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ETag(_serialization.Model): - """Entity tag is used for comparing two or more entities from the same requested resource. - - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - """ - - _attribute_map = { - "etag": {"key": "etag", "type": "str"}, - } - - def __init__(self, *, etag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - """ - super().__init__(**kwargs) - self.etag = etag - - -class InformationProtectionAwsOffering(CloudOffering): - """The information protection for AWS offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", and - "InformationProtectionAws". - :vartype offering_type: str or ~azure.mgmt.security.v2021_07_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar information_protection: The native cloud connection configuration. - :vartype information_protection: - ~azure.mgmt.security.v2021_07_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "information_protection": { - "key": "informationProtection", - "type": "InformationProtectionAwsOfferingInformationProtection", - }, - } - - def __init__( - self, - *, - information_protection: Optional["_models.InformationProtectionAwsOfferingInformationProtection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword information_protection: The native cloud connection configuration. - :paramtype information_protection: - ~azure.mgmt.security.v2021_07_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - super().__init__(**kwargs) - self.offering_type: str = "InformationProtectionAws" - self.information_protection = information_protection - - -class InformationProtectionAwsOfferingInformationProtection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class Kind(_serialization.Model): - """Describes an Azure resource with kind. - - :ivar kind: Kind of the resource. - :vartype kind: str - """ - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__(self, *, kind: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword kind: Kind of the resource. - :paramtype kind: str - """ - super().__init__(**kwargs) - self.kind = kind - - -class Tags(_serialization.Model): - """A list of key value pairs that describe the resource. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class TrackedResource(Resource, AzureTrackedResourceLocation, Kind, ETag, Tags): - """Describes an Azure tracked resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) - self.tags = tags - self.etag = etag - self.kind = kind - self.location = location - self.id = None - self.name = None - self.type = None - - -class SecurityConnector(TrackedResource): # pylint: disable=too-many-instance-attributes - """The security connector resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2021_07_01_preview.models.SystemData - :ivar hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector). - :vartype hierarchy_identifier: str - :ivar cloud_name: The multi cloud resource's cloud name. Known values are: "Azure", "AWS", and - "GCP". - :vartype cloud_name: str or ~azure.mgmt.security.v2021_07_01_preview.models.CloudName - :ivar offerings: A collection of offerings for the security connector. - :vartype offerings: list[~azure.mgmt.security.v2021_07_01_preview.models.CloudOffering] - :ivar organizational_data: The multi cloud account's organizational data. - :vartype organizational_data: - ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnectorPropertiesOrganizationalData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "hierarchy_identifier": {"key": "properties.hierarchyIdentifier", "type": "str"}, - "cloud_name": {"key": "properties.cloudName", "type": "str"}, - "offerings": {"key": "properties.offerings", "type": "[CloudOffering]"}, - "organizational_data": { - "key": "properties.organizationalData", - "type": "SecurityConnectorPropertiesOrganizationalData", - }, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - hierarchy_identifier: Optional[str] = None, - cloud_name: Optional[Union[str, "_models.CloudName"]] = None, - offerings: Optional[List["_models.CloudOffering"]] = None, - organizational_data: Optional["_models.SecurityConnectorPropertiesOrganizationalData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - :keyword hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector). - :paramtype hierarchy_identifier: str - :keyword cloud_name: The multi cloud resource's cloud name. Known values are: "Azure", "AWS", - and "GCP". - :paramtype cloud_name: str or ~azure.mgmt.security.v2021_07_01_preview.models.CloudName - :keyword offerings: A collection of offerings for the security connector. - :paramtype offerings: list[~azure.mgmt.security.v2021_07_01_preview.models.CloudOffering] - :keyword organizational_data: The multi cloud account's organizational data. - :paramtype organizational_data: - ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnectorPropertiesOrganizationalData - """ - super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) - self.system_data = None - self.hierarchy_identifier = hierarchy_identifier - self.cloud_name = cloud_name - self.offerings = offerings - self.organizational_data = organizational_data - - -class SecurityConnectorPropertiesOrganizationalData(_serialization.Model): # pylint: disable=name-too-long - """The multi cloud account's organizational data. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2021_07_01_preview.models.OrganizationMembershipType - :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, - this will be the ID of the account's parent. - :vartype parent_hierarchy_id: str - :ivar stackset_name: If the multi cloud account is of membership type organization, this will - be the name of the onboarding stackset. - :vartype stackset_name: str - :ivar excluded_account_ids: If the multi cloud account is of membership type organization, list - of accounts excluded from offering. - :vartype excluded_account_ids: list[str] - """ - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, - "stackset_name": {"key": "stacksetName", "type": "str"}, - "excluded_account_ids": {"key": "excludedAccountIds", "type": "[str]"}, - } - - def __init__( - self, - *, - organization_membership_type: Optional[Union[str, "_models.OrganizationMembershipType"]] = None, - parent_hierarchy_id: Optional[str] = None, - stackset_name: Optional[str] = None, - excluded_account_ids: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword organization_membership_type: The multi cloud account's membership type in the - organization. Known values are: "Member" and "Organization". - :paramtype organization_membership_type: str or - ~azure.mgmt.security.v2021_07_01_preview.models.OrganizationMembershipType - :keyword parent_hierarchy_id: If the multi cloud account is not of membership type - organization, this will be the ID of the account's parent. - :paramtype parent_hierarchy_id: str - :keyword stackset_name: If the multi cloud account is of membership type organization, this - will be the name of the onboarding stackset. - :paramtype stackset_name: str - :keyword excluded_account_ids: If the multi cloud account is of membership type organization, - list of accounts excluded from offering. - :paramtype excluded_account_ids: list[str] - """ - super().__init__(**kwargs) - self.organization_membership_type = organization_membership_type - self.parent_hierarchy_id = parent_hierarchy_id - self.stackset_name = stackset_name - self.excluded_account_ids = excluded_account_ids - - -class SecurityConnectorsList(_serialization.Model): - """List of security connectors response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of security connectors under the given scope. Required. - :vartype value: list[~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityConnector]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.SecurityConnector"], **kwargs: Any) -> None: - """ - :keyword value: The list of security connectors under the given scope. Required. - :paramtype value: list[~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = 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.security.v2021_07_01_preview.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.security.v2021_07_01_preview.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.security.v2021_07_01_preview.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.security.v2021_07_01_preview.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 diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_security_center_enums.py deleted file mode 100644 index 719ba9a6bf61..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,58 +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 CloudName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud resource's cloud name.""" - - AZURE = "Azure" - AWS = "AWS" - GCP = "GCP" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class OfferingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the security offering.""" - - CSPM_MONITOR_AWS = "CspmMonitorAws" - DEFENDER_FOR_CONTAINERS_AWS = "DefenderForContainersAws" - DEFENDER_FOR_SERVERS_AWS = "DefenderForServersAws" - INFORMATION_PROTECTION_AWS = "InformationProtectionAws" - - -class OrganizationMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud account's membership type in the organization.""" - - MEMBER = "Member" - ORGANIZATION = "Organization" - - -class SeverityEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The severity to relate to the assessments generated by this assessment automation.""" - - HIGH = "High" - MEDIUM = "Medium" - LOW = "Low" - - -class SupportedCloudEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Relevant cloud for the custom assessment automation.""" - - AWS = "AWS" - GCP = "GCP" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/__init__.py deleted file mode 100644 index 395581c73e89..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._custom_assessment_automations_operations import CustomAssessmentAutomationsOperations -from ._custom_entity_store_assignments_operations import CustomEntityStoreAssignmentsOperations -from ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomAssessmentAutomationsOperations", - "CustomEntityStoreAssignmentsOperations", - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py deleted file mode 100644 index 995c032e7e21..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, custom_assessment_automation_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations/{customAssessmentAutomationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "customAssessmentAutomationName": _SERIALIZER.url( - "custom_assessment_automation_name", custom_assessment_automation_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, custom_assessment_automation_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations/{customAssessmentAutomationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "customAssessmentAutomationName": _SERIALIZER.url( - "custom_assessment_automation_name", custom_assessment_automation_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_delete_request( - resource_group_name: str, custom_assessment_automation_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations/{customAssessmentAutomationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "customAssessmentAutomationName": _SERIALIZER.url( - "custom_assessment_automation_name", custom_assessment_automation_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/customAssessmentAutomations" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) - - -class CustomAssessmentAutomationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_07_01_preview.SecurityCenter`'s - :attr:`custom_assessment_automations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, resource_group_name: str, custom_assessment_automation_name: str, **kwargs: Any - ) -> _models.CustomAssessmentAutomation: - """Gets a custom assessment automation. - - Gets a single custom assessment automation by name for the provided subscription and resource - group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :return: CustomAssessmentAutomation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - custom_assessment_automation_name=custom_assessment_automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomAssessmentAutomation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - resource_group_name: str, - custom_assessment_automation_name: str, - custom_assessment_automation_body: _models.CustomAssessmentAutomationRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CustomAssessmentAutomation: - """Creates a custom assessment automation. - - Creates or updates a custom assessment automation for the provided subscription. Please note - that providing an existing custom assessment automation will replace the existing record. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :param custom_assessment_automation_body: Custom Assessment Automation body. Required. - :type custom_assessment_automation_body: - ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomationRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CustomAssessmentAutomation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - custom_assessment_automation_name: str, - custom_assessment_automation_body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CustomAssessmentAutomation: - """Creates a custom assessment automation. - - Creates or updates a custom assessment automation for the provided subscription. Please note - that providing an existing custom assessment automation will replace the existing record. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :param custom_assessment_automation_body: Custom Assessment Automation body. Required. - :type custom_assessment_automation_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: CustomAssessmentAutomation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - custom_assessment_automation_name: str, - custom_assessment_automation_body: Union[_models.CustomAssessmentAutomationRequest, IO[bytes]], - **kwargs: Any - ) -> _models.CustomAssessmentAutomation: - """Creates a custom assessment automation. - - Creates or updates a custom assessment automation for the provided subscription. Please note - that providing an existing custom assessment automation will replace the existing record. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :param custom_assessment_automation_body: Custom Assessment Automation body. Is either a - CustomAssessmentAutomationRequest type or a IO[bytes] type. Required. - :type custom_assessment_automation_body: - ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomationRequest or IO[bytes] - :return: CustomAssessmentAutomation or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_assessment_automation_body, (IOBase, bytes)): - _content = custom_assessment_automation_body - else: - _json = self._serialize.body(custom_assessment_automation_body, "CustomAssessmentAutomationRequest") - - _request = build_create_request( - resource_group_name=resource_group_name, - custom_assessment_automation_name=custom_assessment_automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("CustomAssessmentAutomation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomAssessmentAutomation", pipeline_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, custom_assessment_automation_name: str, **kwargs: Any - ) -> None: - """Deletes a custom assessment automation. - - Deletes a custom assessment automation by name for a provided subscription. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_assessment_automation_name: Name of the Custom Assessment Automation. Required. - :type custom_assessment_automation_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - custom_assessment_automation_name=custom_assessment_automation_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.CustomAssessmentAutomation"]: - """List custom assessment automations in a subscription and a resource group. - - List custom assessment automations by provided subscription and resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either CustomAssessmentAutomation or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomAssessmentAutomationsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomAssessmentAutomationsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomAssessmentAutomation"]: - """List custom assessment automations in a subscription. - - List custom assessment automations by provided subscription. - - :return: An iterator like instance of either CustomAssessmentAutomation or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.CustomAssessmentAutomation] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomAssessmentAutomationsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomAssessmentAutomationsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py deleted file mode 100644 index 90da419c0abf..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py +++ /dev/null @@ -1,682 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, custom_entity_store_assignment_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments/{customEntityStoreAssignmentName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "customEntityStoreAssignmentName": _SERIALIZER.url( - "custom_entity_store_assignment_name", custom_entity_store_assignment_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, custom_entity_store_assignment_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments/{customEntityStoreAssignmentName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "customEntityStoreAssignmentName": _SERIALIZER.url( - "custom_entity_store_assignment_name", custom_entity_store_assignment_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_delete_request( - resource_group_name: str, custom_entity_store_assignment_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments/{customEntityStoreAssignmentName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "customEntityStoreAssignmentName": _SERIALIZER.url( - "custom_entity_store_assignment_name", custom_entity_store_assignment_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customEntityStoreAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/customEntityStoreAssignments" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) - - -class CustomEntityStoreAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_07_01_preview.SecurityCenter`'s - :attr:`custom_entity_store_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, resource_group_name: str, custom_entity_store_assignment_name: str, **kwargs: Any - ) -> _models.CustomEntityStoreAssignment: - """Gets a custom entity store assignment. - - Gets a single custom entity store assignment by name for the provided subscription and resource - group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :return: CustomEntityStoreAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - custom_entity_store_assignment_name=custom_entity_store_assignment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomEntityStoreAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - resource_group_name: str, - custom_entity_store_assignment_name: str, - custom_entity_store_assignment_request_body: _models.CustomEntityStoreAssignmentRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CustomEntityStoreAssignment: - """Creates a custom entity store assignment. - - Creates a custom entity store assignment for the provided subscription, if not already exists. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :param custom_entity_store_assignment_request_body: Custom entity store assignment body. - Required. - :type custom_entity_store_assignment_request_body: - ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignmentRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CustomEntityStoreAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - custom_entity_store_assignment_name: str, - custom_entity_store_assignment_request_body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CustomEntityStoreAssignment: - """Creates a custom entity store assignment. - - Creates a custom entity store assignment for the provided subscription, if not already exists. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :param custom_entity_store_assignment_request_body: Custom entity store assignment body. - Required. - :type custom_entity_store_assignment_request_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: CustomEntityStoreAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - custom_entity_store_assignment_name: str, - custom_entity_store_assignment_request_body: Union[_models.CustomEntityStoreAssignmentRequest, IO[bytes]], - **kwargs: Any - ) -> _models.CustomEntityStoreAssignment: - """Creates a custom entity store assignment. - - Creates a custom entity store assignment for the provided subscription, if not already exists. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :param custom_entity_store_assignment_request_body: Custom entity store assignment body. Is - either a CustomEntityStoreAssignmentRequest type or a IO[bytes] type. Required. - :type custom_entity_store_assignment_request_body: - ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignmentRequest or IO[bytes] - :return: CustomEntityStoreAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_entity_store_assignment_request_body, (IOBase, bytes)): - _content = custom_entity_store_assignment_request_body - else: - _json = self._serialize.body( - custom_entity_store_assignment_request_body, "CustomEntityStoreAssignmentRequest" - ) - - _request = build_create_request( - resource_group_name=resource_group_name, - custom_entity_store_assignment_name=custom_entity_store_assignment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("CustomEntityStoreAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomEntityStoreAssignment", pipeline_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, custom_entity_store_assignment_name: str, **kwargs: Any - ) -> None: - """Deleted a custom entity store assignment. - - Delete a custom entity store assignment by name for a provided subscription. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param custom_entity_store_assignment_name: Name of the custom entity store assignment. - Generated name is GUID. Required. - :type custom_entity_store_assignment_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - custom_entity_store_assignment_name=custom_entity_store_assignment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.CustomEntityStoreAssignment"]: - """List custom entity store assignments in a subscription and a resource group. - - List custom entity store assignments by a provided subscription and resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either CustomEntityStoreAssignment or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomEntityStoreAssignmentsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomEntityStoreAssignment"]: - """List custom entity store assignments in a subscription. - - List custom entity store assignments by provided subscription. - - :return: An iterator like instance of either CustomEntityStoreAssignment or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.CustomEntityStoreAssignment] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomEntityStoreAssignmentsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py deleted file mode 100644 index 8fac3ac7ec6b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py +++ /dev/null @@ -1,820 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_07_01_preview.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector] - :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._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_07_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_configuration.py deleted file mode 100644 index 1fbf37a4c801..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-10-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", "2021-10-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_metadata.json deleted file mode 100644 index 7c3feadf2ff7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2021-10-01-preview", - "total_api_version_list": ["2021-10-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "mde_onboardings": "MdeOnboardingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_security_center.py deleted file mode 100644 index e118d1ed94d8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_security_center.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import MdeOnboardingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar mde_onboardings: MdeOnboardingsOperations operations - :vartype mde_onboardings: - azure.mgmt.security.v2021_10_01_preview.operations.MdeOnboardingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-10-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.mde_onboardings = MdeOnboardingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_configuration.py deleted file mode 100644 index 41bd711dfe93..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-10-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", "2021-10-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_security_center.py deleted file mode 100644 index fe44a1bc0bcd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_security_center.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import MdeOnboardingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar mde_onboardings: MdeOnboardingsOperations operations - :vartype mde_onboardings: - azure.mgmt.security.v2021_10_01_preview.aio.operations.MdeOnboardingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-10-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.mde_onboardings = MdeOnboardingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/__init__.py deleted file mode 100644 index cf82df5f135a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._mde_onboardings_operations import MdeOnboardingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MdeOnboardingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py deleted file mode 100644 index 925ea8904d06..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._mde_onboardings_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MdeOnboardingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_10_01_preview.aio.SecurityCenter`'s - :attr:`mde_onboardings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.MdeOnboardingDataList: - """The configuration or data needed to onboard the machine to MDE. - - :return: MdeOnboardingDataList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_10_01_preview.models.MdeOnboardingDataList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-10-01-preview") - ) - cls: ClsType[_models.MdeOnboardingDataList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MdeOnboardingDataList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, **kwargs: Any) -> _models.MdeOnboardingData: - """The default configuration or data needed to onboard the machine to MDE. - - :return: MdeOnboardingData or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_10_01_preview.models.MdeOnboardingData - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-10-01-preview") - ) - cls: ClsType[_models.MdeOnboardingData] = kwargs.pop("cls", None) - - _request = build_get_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MdeOnboardingData", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/models/__init__.py deleted file mode 100644 index cb8c7cea8637..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/models/__init__.py +++ /dev/null @@ -1,26 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import MdeOnboardingData -from ._models_py3 import MdeOnboardingDataList -from ._models_py3 import Resource -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "ErrorAdditionalInfo", - "MdeOnboardingData", - "MdeOnboardingDataList", - "Resource", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/models/_models_py3.py deleted file mode 100644 index b54da6ab16d9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/models/_models_py3.py +++ /dev/null @@ -1,196 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CloudErrorBody(_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.security.v2021_10_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2021_10_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class MdeOnboardingData(Resource): - """The resource of the configuration or data needed to onboard the machine to MDE. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar onboarding_package_windows: The onboarding package used to onboard Windows machines to - MDE, coded in base64. This can also be used for onboarding using the dedicated VM Extension. - :vartype onboarding_package_windows: bytes - :ivar onboarding_package_linux: The onboarding package used to onboard Linux machines to MDE, - coded in base64. This can also be used for onboarding using the dedicated VM Extension. - :vartype onboarding_package_linux: bytes - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "onboarding_package_windows": {"key": "properties.onboardingPackageWindows", "type": "bytearray"}, - "onboarding_package_linux": {"key": "properties.onboardingPackageLinux", "type": "bytearray"}, - } - - def __init__( - self, - *, - onboarding_package_windows: Optional[bytes] = None, - onboarding_package_linux: Optional[bytes] = None, - **kwargs: Any - ) -> None: - """ - :keyword onboarding_package_windows: The onboarding package used to onboard Windows machines to - MDE, coded in base64. This can also be used for onboarding using the dedicated VM Extension. - :paramtype onboarding_package_windows: bytes - :keyword onboarding_package_linux: The onboarding package used to onboard Linux machines to - MDE, coded in base64. This can also be used for onboarding using the dedicated VM Extension. - :paramtype onboarding_package_linux: bytes - """ - super().__init__(**kwargs) - self.onboarding_package_windows = onboarding_package_windows - self.onboarding_package_linux = onboarding_package_linux - - -class MdeOnboardingDataList(_serialization.Model): - """List of all MDE onboarding data resources. - - :ivar value: List of the resources of the configuration or data needed to onboard the machine - to MDE. - :vartype value: list[~azure.mgmt.security.v2021_10_01_preview.models.MdeOnboardingData] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[MdeOnboardingData]"}, - } - - def __init__(self, *, value: Optional[List["_models.MdeOnboardingData"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of the resources of the configuration or data needed to onboard the - machine to MDE. - :paramtype value: list[~azure.mgmt.security.v2021_10_01_preview.models.MdeOnboardingData] - """ - super().__init__(**kwargs) - self.value = value diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/__init__.py deleted file mode 100644 index cf82df5f135a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._mde_onboardings_operations import MdeOnboardingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MdeOnboardingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py deleted file mode 100644 index 637018bde336..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py +++ /dev/null @@ -1,216 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/mdeOnboardings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/mdeOnboardings/default" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) - - -class MdeOnboardingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2021_10_01_preview.SecurityCenter`'s - :attr:`mde_onboardings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> _models.MdeOnboardingDataList: - """The configuration or data needed to onboard the machine to MDE. - - :return: MdeOnboardingDataList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_10_01_preview.models.MdeOnboardingDataList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-10-01-preview") - ) - cls: ClsType[_models.MdeOnboardingDataList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MdeOnboardingDataList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, **kwargs: Any) -> _models.MdeOnboardingData: - """The default configuration or data needed to onboard the machine to MDE. - - :return: MdeOnboardingData or the result of cls(response) - :rtype: ~azure.mgmt.security.v2021_10_01_preview.models.MdeOnboardingData - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-10-01-preview") - ) - cls: ClsType[_models.MdeOnboardingData] = kwargs.pop("cls", None) - - _request = build_get_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MdeOnboardingData", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_configuration.py deleted file mode 100644 index ab1fef834312..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_metadata.json deleted file mode 100644 index 2d7855bd872f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2022-01-01", - "total_api_version_list": ["2022-01-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "alerts": "AlertsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_security_center.py deleted file mode 100644 index d2e0152b6d78..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_security_center.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import AlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar alerts: AlertsOperations operations - :vartype alerts: azure.mgmt.security.v2022_01_01.operations.AlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-01-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_configuration.py deleted file mode 100644 index 477529ed1c68..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_security_center.py deleted file mode 100644 index edb93f68b5f8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_security_center.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import AlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar alerts: AlertsOperations operations - :vartype alerts: azure.mgmt.security.v2022_01_01.aio.operations.AlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-01-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/__init__.py deleted file mode 100644 index b3a334939bbd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._alerts_operations import AlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py deleted file mode 100644 index 2be62b2e3250..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py +++ /dev/null @@ -1,1138 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._alerts_operations import ( - build_get_resource_group_level_request, - build_get_subscription_level_request, - build_list_by_resource_group_request, - build_list_request, - build_list_resource_group_level_by_region_request, - build_list_subscription_level_by_region_request, - build_simulate_request, - build_update_resource_group_level_state_to_activate_request, - build_update_resource_group_level_state_to_dismiss_request, - build_update_resource_group_level_state_to_in_progress_request, - build_update_resource_group_level_state_to_resolve_request, - build_update_subscription_level_state_to_activate_request, - build_update_subscription_level_state_to_dismiss_request, - build_update_subscription_level_state_to_in_progress_request, - build_update_subscription_level_state_to_resolve_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_01_01.aio.SecurityCenter`'s - :attr:`alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Alert"]: - """List all the alerts that are associated with the subscription. - - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_01_01.models.Alert] - :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._api_version or "2022-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Alert"]: - """List all the alerts that are associated with the resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_01_01.models.Alert] - :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._api_version or "2022-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> AsyncIterable["_models.Alert"]: - """List all the alerts that are associated with the subscription that are stored in a specific - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_01_01.models.Alert] - :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._api_version or "2022-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_subscription_level_by_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_resource_group_level_by_region( - self, asc_location: str, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Alert"]: - """List all the alerts that are associated with the resource group that are stored in a specific - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_01_01.models.Alert] - :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._api_version or "2022-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_group_level_by_region_request( - asc_location=asc_location, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: Any) -> _models.Alert: - """Get an alert that is associated with a subscription. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01.models.Alert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - - _request = build_get_subscription_level_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Alert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_resource_group_level( - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> _models.Alert: - """Get an alert that is associated a resource group or a resource in a resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01.models.Alert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - - _request = build_get_resource_group_level_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Alert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_dismiss_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_resolve_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_subscription_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_activate_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_subscription_level_state_to_in_progress( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_in_progress_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_resource_group_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_resolve_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_dismiss_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_resource_group_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_activate_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def update_resource_group_level_state_to_in_progress( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_in_progress_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - async def _simulate_initial( # pylint: disable=inconsistent-return-statements - self, - asc_location: str, - alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], - **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_simulator_request_body, (IOBase, bytes)): - _content = alert_simulator_request_body - else: - _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") - - _request = build_simulate_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: _models.AlertSimulatorRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Required. - :type alert_simulator_request_body: - ~azure.mgmt.security.v2022_01_01.models.AlertSimulatorRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Required. - :type alert_simulator_request_body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Is either a - AlertSimulatorRequestBody type or a IO[bytes] type. Required. - :type alert_simulator_request_body: - ~azure.mgmt.security.v2022_01_01.models.AlertSimulatorRequestBody or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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._api_version or "2022-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._simulate_initial( # type: ignore - asc_location=asc_location, - alert_simulator_request_body=alert_simulator_request_body, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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": "original-uri"}, **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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/__init__.py deleted file mode 100644 index 21ba3cd6f9a7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/__init__.py +++ /dev/null @@ -1,55 +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 ._models_py3 import Alert -from ._models_py3 import AlertEntity -from ._models_py3 import AlertList -from ._models_py3 import AlertPropertiesSupportingEvidence -from ._models_py3 import AlertSimulatorBundlesRequestProperties -from ._models_py3 import AlertSimulatorRequestBody -from ._models_py3 import AlertSimulatorRequestProperties -from ._models_py3 import AzureResourceIdentifier -from ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import LogAnalyticsIdentifier -from ._models_py3 import Resource -from ._models_py3 import ResourceIdentifier - -from ._security_center_enums import AlertSeverity -from ._security_center_enums import AlertStatus -from ._security_center_enums import BundleType -from ._security_center_enums import Intent -from ._security_center_enums import KindEnum -from ._security_center_enums import ResourceIdentifierType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Alert", - "AlertEntity", - "AlertList", - "AlertPropertiesSupportingEvidence", - "AlertSimulatorBundlesRequestProperties", - "AlertSimulatorRequestBody", - "AlertSimulatorRequestProperties", - "AzureResourceIdentifier", - "CloudErrorBody", - "ErrorAdditionalInfo", - "LogAnalyticsIdentifier", - "Resource", - "ResourceIdentifier", - "AlertSeverity", - "AlertStatus", - "BundleType", - "Intent", - "KindEnum", - "ResourceIdentifierType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_models_py3.py deleted file mode 100644 index f85e1a5e166f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_models_py3.py +++ /dev/null @@ -1,631 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Alert(Resource): # pylint: disable=too-many-instance-attributes - """Security alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar version: Schema version. - :vartype version: str - :ivar alert_type: Unique identifier for the detection logic (all alert instances from the same - detection logic will have the same alertType). - :vartype alert_type: str - :ivar system_alert_id: Unique identifier for the alert. - :vartype system_alert_id: str - :ivar product_component_name: The name of Azure Security Center pricing tier which powering - this alert. Learn more: - https://docs.microsoft.com/en-us/azure/security-center/security-center-pricing. - :vartype product_component_name: str - :ivar alert_display_name: The display name of the alert. - :vartype alert_display_name: str - :ivar description: Description of the suspicious activity that was detected. - :vartype description: str - :ivar severity: The risk level of the threat that was detected. Learn more: - https://docs.microsoft.com/en-us/azure/security-center/security-center-alerts-overview#how-are-alerts-classified. - Known values are: "Informational", "Low", "Medium", and "High". - :vartype severity: str or ~azure.mgmt.security.v2022_01_01.models.AlertSeverity - :ivar intent: The kill chain related intent behind the alert. For list of supported values, and - explanations of Azure Security Center's supported kill chain intents. Known values are: - "Unknown", "PreAttack", "InitialAccess", "Persistence", "PrivilegeEscalation", - "DefenseEvasion", "CredentialAccess", "Discovery", "LateralMovement", "Execution", - "Collection", "Exfiltration", "CommandAndControl", "Impact", "Probing", and "Exploitation". - :vartype intent: str or ~azure.mgmt.security.v2022_01_01.models.Intent - :ivar start_time_utc: The UTC time of the first event or activity included in the alert in - ISO8601 format. - :vartype start_time_utc: ~datetime.datetime - :ivar end_time_utc: The UTC time of the last event or activity included in the alert in ISO8601 - format. - :vartype end_time_utc: ~datetime.datetime - :ivar resource_identifiers: The resource identifiers that can be used to direct the alert to - the right product exposure group (tenant, workspace, subscription etc.). There can be multiple - identifiers of different type per alert. - :vartype resource_identifiers: list[~azure.mgmt.security.v2022_01_01.models.ResourceIdentifier] - :ivar remediation_steps: Manual action items to take to remediate the alert. - :vartype remediation_steps: list[str] - :ivar vendor_name: The name of the vendor that raises the alert. - :vartype vendor_name: str - :ivar status: The life cycle status of the alert. Known values are: "Active", "InProgress", - "Resolved", and "Dismissed". - :vartype status: str or ~azure.mgmt.security.v2022_01_01.models.AlertStatus - :ivar extended_links: Links related to the alert. - :vartype extended_links: list[dict[str, str]] - :ivar alert_uri: A direct link to the alert page in Azure Portal. - :vartype alert_uri: str - :ivar time_generated_utc: The UTC time the alert was generated in ISO8601 format. - :vartype time_generated_utc: ~datetime.datetime - :ivar product_name: The name of the product which published this alert (Microsoft Sentinel, - Microsoft Defender for Identity, Microsoft Defender for Endpoint, Microsoft Defender for - Office, Microsoft Defender for Cloud Apps, and so on). - :vartype product_name: str - :ivar processing_end_time_utc: The UTC processing end time of the alert in ISO8601 format. - :vartype processing_end_time_utc: ~datetime.datetime - :ivar entities: A list of entities related to the alert. - :vartype entities: list[~azure.mgmt.security.v2022_01_01.models.AlertEntity] - :ivar is_incident: This field determines whether the alert is an incident (a compound grouping - of several alerts) or a single alert. - :vartype is_incident: bool - :ivar correlation_key: Key for corelating related alerts. Alerts with the same correlation key - considered to be related. - :vartype correlation_key: str - :ivar extended_properties: Custom properties for the alert. - :vartype extended_properties: dict[str, str] - :ivar compromised_entity: The display name of the resource most related to this alert. - :vartype compromised_entity: str - :ivar techniques: kill chain related techniques behind the alert. - :vartype techniques: list[str] - :ivar sub_techniques: Kill chain related sub-techniques behind the alert. - :vartype sub_techniques: list[str] - :ivar supporting_evidence: Changing set of properties depending on the supportingEvidence type. - :vartype supporting_evidence: - ~azure.mgmt.security.v2022_01_01.models.AlertPropertiesSupportingEvidence - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "version": {"readonly": True}, - "alert_type": {"readonly": True}, - "system_alert_id": {"readonly": True}, - "product_component_name": {"readonly": True}, - "alert_display_name": {"readonly": True}, - "description": {"readonly": True}, - "severity": {"readonly": True}, - "intent": {"readonly": True}, - "start_time_utc": {"readonly": True}, - "end_time_utc": {"readonly": True}, - "resource_identifiers": {"readonly": True}, - "remediation_steps": {"readonly": True}, - "vendor_name": {"readonly": True}, - "status": {"readonly": True}, - "extended_links": {"readonly": True}, - "alert_uri": {"readonly": True}, - "time_generated_utc": {"readonly": True}, - "product_name": {"readonly": True}, - "processing_end_time_utc": {"readonly": True}, - "entities": {"readonly": True}, - "is_incident": {"readonly": True}, - "correlation_key": {"readonly": True}, - "compromised_entity": {"readonly": True}, - "techniques": {"readonly": True}, - "sub_techniques": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "alert_type": {"key": "properties.alertType", "type": "str"}, - "system_alert_id": {"key": "properties.systemAlertId", "type": "str"}, - "product_component_name": {"key": "properties.productComponentName", "type": "str"}, - "alert_display_name": {"key": "properties.alertDisplayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "severity": {"key": "properties.severity", "type": "str"}, - "intent": {"key": "properties.intent", "type": "str"}, - "start_time_utc": {"key": "properties.startTimeUtc", "type": "iso-8601"}, - "end_time_utc": {"key": "properties.endTimeUtc", "type": "iso-8601"}, - "resource_identifiers": {"key": "properties.resourceIdentifiers", "type": "[ResourceIdentifier]"}, - "remediation_steps": {"key": "properties.remediationSteps", "type": "[str]"}, - "vendor_name": {"key": "properties.vendorName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "extended_links": {"key": "properties.extendedLinks", "type": "[{str}]"}, - "alert_uri": {"key": "properties.alertUri", "type": "str"}, - "time_generated_utc": {"key": "properties.timeGeneratedUtc", "type": "iso-8601"}, - "product_name": {"key": "properties.productName", "type": "str"}, - "processing_end_time_utc": {"key": "properties.processingEndTimeUtc", "type": "iso-8601"}, - "entities": {"key": "properties.entities", "type": "[AlertEntity]"}, - "is_incident": {"key": "properties.isIncident", "type": "bool"}, - "correlation_key": {"key": "properties.correlationKey", "type": "str"}, - "extended_properties": {"key": "properties.extendedProperties", "type": "{str}"}, - "compromised_entity": {"key": "properties.compromisedEntity", "type": "str"}, - "techniques": {"key": "properties.techniques", "type": "[str]"}, - "sub_techniques": {"key": "properties.subTechniques", "type": "[str]"}, - "supporting_evidence": {"key": "properties.supportingEvidence", "type": "AlertPropertiesSupportingEvidence"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - extended_properties: Optional[Dict[str, str]] = None, - supporting_evidence: Optional["_models.AlertPropertiesSupportingEvidence"] = None, - **kwargs: Any - ) -> None: - """ - :keyword extended_properties: Custom properties for the alert. - :paramtype extended_properties: dict[str, str] - :keyword supporting_evidence: Changing set of properties depending on the supportingEvidence - type. - :paramtype supporting_evidence: - ~azure.mgmt.security.v2022_01_01.models.AlertPropertiesSupportingEvidence - """ - super().__init__(**kwargs) - self.version = None - self.alert_type = None - self.system_alert_id = None - self.product_component_name = None - self.alert_display_name = None - self.description = None - self.severity = None - self.intent = None - self.start_time_utc = None - self.end_time_utc = None - self.resource_identifiers = None - self.remediation_steps = None - self.vendor_name = None - self.status = None - self.extended_links = None - self.alert_uri = None - self.time_generated_utc = None - self.product_name = None - self.processing_end_time_utc = None - self.entities = None - self.is_incident = None - self.correlation_key = None - self.extended_properties = extended_properties - self.compromised_entity = None - self.techniques = None - self.sub_techniques = None - self.supporting_evidence = supporting_evidence - - -class AlertEntity(_serialization.Model): - """Changing set of properties depending on the entity type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar type: Type of entity. - :vartype type: str - """ - - _validation = { - "type": {"readonly": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs: Any) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.type = None - - -class AlertList(_serialization.Model): - """List of security alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: describes security alert properties. - :vartype value: list[~azure.mgmt.security.v2022_01_01.models.Alert] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Alert]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Alert"]] = None, **kwargs: Any) -> None: - """ - :keyword value: describes security alert properties. - :paramtype value: list[~azure.mgmt.security.v2022_01_01.models.Alert] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class AlertPropertiesSupportingEvidence(_serialization.Model): - """Changing set of properties depending on the supportingEvidence type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar type: Type of the supportingEvidence. - :vartype type: str - """ - - _validation = { - "type": {"readonly": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs: Any) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.type = None - - -class AlertSimulatorRequestProperties(_serialization.Model): - """Describes properties of an alert simulation request. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AlertSimulatorBundlesRequestProperties - - All required parameters must be populated in order to send to server. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar kind: The kind of alert simulation. Required. "Bundles" - :vartype kind: str or ~azure.mgmt.security.v2022_01_01.models.KindEnum - """ - - _validation = { - "kind": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "kind": {"key": "kind", "type": "str"}, - } - - _subtype_map = {"kind": {"Bundles": "AlertSimulatorBundlesRequestProperties"}} - - def __init__(self, *, additional_properties: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.kind: Optional[str] = None - - -class AlertSimulatorBundlesRequestProperties(AlertSimulatorRequestProperties): - """Simulate alerts according to this bundles. - - All required parameters must be populated in order to send to server. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar kind: The kind of alert simulation. Required. "Bundles" - :vartype kind: str or ~azure.mgmt.security.v2022_01_01.models.KindEnum - :ivar bundles: Bundles list. - :vartype bundles: list[str or ~azure.mgmt.security.v2022_01_01.models.BundleType] - """ - - _validation = { - "kind": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "kind": {"key": "kind", "type": "str"}, - "bundles": {"key": "bundles", "type": "[str]"}, - } - - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - bundles: Optional[List[Union[str, "_models.BundleType"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword bundles: Bundles list. - :paramtype bundles: list[str or ~azure.mgmt.security.v2022_01_01.models.BundleType] - """ - super().__init__(additional_properties=additional_properties, **kwargs) - self.kind: str = "Bundles" - self.bundles = bundles - - -class AlertSimulatorRequestBody(_serialization.Model): - """Alert Simulator request body. - - :ivar properties: Alert Simulator request body data. - :vartype properties: ~azure.mgmt.security.v2022_01_01.models.AlertSimulatorRequestProperties - """ - - _attribute_map = { - "properties": {"key": "properties", "type": "AlertSimulatorRequestProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.AlertSimulatorRequestProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Alert Simulator request body data. - :paramtype properties: ~azure.mgmt.security.v2022_01_01.models.AlertSimulatorRequestProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class ResourceIdentifier(_serialization.Model): - """A resource identifier for an alert which can be used to direct the alert to the right product - exposure group (tenant, workspace, subscription etc.). - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureResourceIdentifier, LogAnalyticsIdentifier - - All required parameters must be populated in order to send to server. - - :ivar type: There can be multiple identifiers of different type per alert, this field specify - the identifier type. Required. Known values are: "AzureResource" and "LogAnalytics". - :vartype type: str or ~azure.mgmt.security.v2022_01_01.models.ResourceIdentifierType - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - _subtype_map = {"type": {"AzureResource": "AzureResourceIdentifier", "LogAnalytics": "LogAnalyticsIdentifier"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - - -class AzureResourceIdentifier(ResourceIdentifier): - """Azure resource identifier. - - 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 type: There can be multiple identifiers of different type per alert, this field specify - the identifier type. Required. Known values are: "AzureResource" and "LogAnalytics". - :vartype type: str or ~azure.mgmt.security.v2022_01_01.models.ResourceIdentifierType - :ivar azure_resource_id: ARM resource identifier for the cloud resource being alerted on. - :vartype azure_resource_id: str - """ - - _validation = { - "type": {"required": True}, - "azure_resource_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "azure_resource_id": {"key": "azureResourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "AzureResource" - self.azure_resource_id = None - - -class CloudErrorBody(_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.security.v2022_01_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2022_01_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class LogAnalyticsIdentifier(ResourceIdentifier): - """Represents a Log Analytics workspace scope identifier. - - 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 type: There can be multiple identifiers of different type per alert, this field specify - the identifier type. Required. Known values are: "AzureResource" and "LogAnalytics". - :vartype type: str or ~azure.mgmt.security.v2022_01_01.models.ResourceIdentifierType - :ivar workspace_id: The LogAnalytics workspace id that stores this alert. - :vartype workspace_id: str - :ivar workspace_subscription_id: The azure subscription id for the LogAnalytics workspace - storing this alert. - :vartype workspace_subscription_id: str - :ivar workspace_resource_group: The azure resource group for the LogAnalytics workspace storing - this alert. - :vartype workspace_resource_group: str - :ivar agent_id: (optional) The LogAnalytics agent id reporting the event that this alert is - based on. - :vartype agent_id: str - """ - - _validation = { - "type": {"required": True}, - "workspace_id": {"readonly": True}, - "workspace_subscription_id": { - "readonly": True, - "pattern": r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", - }, - "workspace_resource_group": {"readonly": True}, - "agent_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "workspace_subscription_id": {"key": "workspaceSubscriptionId", "type": "str"}, - "workspace_resource_group": {"key": "workspaceResourceGroup", "type": "str"}, - "agent_id": {"key": "agentId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "LogAnalytics" - self.workspace_id = None - self.workspace_subscription_id = None - self.workspace_resource_group = None - self.agent_id = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_security_center_enums.py deleted file mode 100644 index fdd7e56dda7b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_security_center_enums.py +++ /dev/null @@ -1,127 +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 AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The risk level of the threat that was detected. Learn more: - https://docs.microsoft.com/en-us/azure/security-center/security-center-alerts-overview#how-are-alerts-classified. - """ - - INFORMATIONAL = "Informational" - """Informational""" - LOW = "Low" - """Low""" - MEDIUM = "Medium" - """Medium""" - HIGH = "High" - """High""" - - -class AlertStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The life cycle status of the alert.""" - - ACTIVE = "Active" - """An alert which doesn't specify a value is assigned the status 'Active'""" - IN_PROGRESS = "InProgress" - """An alert which is in handling state""" - RESOLVED = "Resolved" - """Alert closed after handling""" - DISMISSED = "Dismissed" - """Alert dismissed as false positive""" - - -class BundleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Alert Simulator supported bundles.""" - - APP_SERVICES = "AppServices" - DNS = "DNS" - KEY_VAULTS = "KeyVaults" - KUBERNETES_SERVICE = "KubernetesService" - RESOURCE_MANAGER = "ResourceManager" - SQL_SERVERS = "SqlServers" - STORAGE_ACCOUNTS = "StorageAccounts" - VIRTUAL_MACHINES = "VirtualMachines" - COSMOS_DBS = "CosmosDbs" - - -class Intent(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kill chain related intent behind the alert. For list of supported values, and explanations - of Azure Security Center's supported kill chain intents. - """ - - UNKNOWN = "Unknown" - """Unknown""" - PRE_ATTACK = "PreAttack" - """PreAttack could be either an attempt to access a certain resource regardless of a malicious - intent, or a failed attempt to gain access to a target system to gather information prior to - exploitation. This step is usually detected as an attempt, originating from outside the - network, to scan the target system and find a way in. Further details on the PreAttack stage - can be read in `MITRE Pre-Att&ck matrix `_.""" - INITIAL_ACCESS = "InitialAccess" - """InitialAccess is the stage where an attacker manages to get foothold on the attacked resource.""" - PERSISTENCE = "Persistence" - """Persistence is any access, action, or configuration change to a system that gives a threat - actor a persistent presence on that system.""" - PRIVILEGE_ESCALATION = "PrivilegeEscalation" - """Privilege escalation is the result of actions that allow an adversary to obtain a higher level - of permissions on a system or network.""" - DEFENSE_EVASION = "DefenseEvasion" - """Defense evasion consists of techniques an adversary may use to evade detection or avoid other - defenses.""" - CREDENTIAL_ACCESS = "CredentialAccess" - """Credential access represents techniques resulting in access to or control over system, domain, - or service credentials that are used within an enterprise environment.""" - DISCOVERY = "Discovery" - """Discovery consists of techniques that allow the adversary to gain knowledge about the system - and internal network.""" - LATERAL_MOVEMENT = "LateralMovement" - """Lateral movement consists of techniques that enable an adversary to access and control remote - systems on a network and could, but does not necessarily, include execution of tools on remote - systems.""" - EXECUTION = "Execution" - """The execution tactic represents techniques that result in execution of adversary-controlled - code on a local or remote system.""" - COLLECTION = "Collection" - """Collection consists of techniques used to identify and gather information, such as sensitive - files, from a target network prior to exfiltration.""" - EXFILTRATION = "Exfiltration" - """Exfiltration refers to techniques and attributes that result or aid in the adversary removing - files and information from a target network.""" - COMMAND_AND_CONTROL = "CommandAndControl" - """The command and control tactic represents how adversaries communicate with systems under their - control within a target network.""" - IMPACT = "Impact" - """Impact events primarily try to directly reduce the availability or integrity of a system, - service, or network; including manipulation of data to impact a business or operational - process.""" - PROBING = "Probing" - """Probing could be either an attempt to access a certain resource regardless of a malicious - intent, or a failed attempt to gain access to a target system to gather information prior to - exploitation.""" - EXPLOITATION = "Exploitation" - """Exploitation is the stage where an attacker manages to get a foothold on the attacked resource. - This stage is relevant for compute hosts and resources such as user accounts, certificates etc.""" - - -class KindEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of alert simulation.""" - - BUNDLES = "Bundles" - """Simulate alerts according to bundles""" - - -class ResourceIdentifierType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """There can be multiple identifiers of different type per alert, this field specify the - identifier type. - """ - - AZURE_RESOURCE = "AzureResource" - LOG_ANALYTICS = "LogAnalytics" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/__init__.py deleted file mode 100644 index b3a334939bbd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._alerts_operations import AlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py deleted file mode 100644 index 4df5342b1e4d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py +++ /dev/null @@ -1,1625 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_subscription_level_by_region_request( # pylint: disable=name-too-long - asc_location: 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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_resource_group_level_by_region_request( # pylint: disable=name-too-long - asc_location: str, resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_subscription_level_request( - asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_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_get_resource_group_level_request( - resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_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_update_subscription_level_state_to_dismiss_request( # pylint: disable=name-too-long - asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_subscription_level_state_to_resolve_request( # pylint: disable=name-too-long - asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_subscription_level_state_to_activate_request( # pylint: disable=name-too-long - asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_subscription_level_state_to_in_progress_request( # pylint: disable=name-too-long - asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/inProgress", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_resource_group_level_state_to_resolve_request( # pylint: disable=name-too-long - resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_resource_group_level_state_to_dismiss_request( # pylint: disable=name-too-long - resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_resource_group_level_state_to_activate_request( # pylint: disable=name-too-long - resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_resource_group_level_state_to_in_progress_request( # pylint: disable=name-too-long - resource_group_name: str, asc_location: str, alert_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", "2022-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/inProgress", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_simulate_request(asc_location: 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", "2022-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}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_01_01.SecurityCenter`'s - :attr:`alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Alert"]: - """List all the alerts that are associated with the subscription. - - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_01_01.models.Alert] - :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._api_version or "2022-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Alert"]: - """List all the alerts that are associated with the resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_01_01.models.Alert] - :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._api_version or "2022-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> Iterable["_models.Alert"]: - """List all the alerts that are associated with the subscription that are stored in a specific - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_01_01.models.Alert] - :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._api_version or "2022-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_subscription_level_by_region_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_resource_group_level_by_region( - self, asc_location: str, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.Alert"]: - """List all the alerts that are associated with the resource group that are stored in a specific - location. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_01_01.models.Alert] - :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._api_version or "2022-01-01")) - cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_group_level_by_region_request( - asc_location=asc_location, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: Any) -> _models.Alert: - """Get an alert that is associated with a subscription. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01.models.Alert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - - _request = build_get_subscription_level_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Alert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_resource_group_level( - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> _models.Alert: - """Get an alert that is associated a resource group or a resource in a resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01.models.Alert - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - - _request = build_get_resource_group_level_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Alert", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_dismiss_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_resolve_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_subscription_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_activate_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_subscription_level_state_to_in_progress( # pylint: disable=inconsistent-return-statements,name-too-long - self, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_subscription_level_state_to_in_progress_request( - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_resource_group_level_state_to_resolve( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_resolve_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_dismiss_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_resource_group_level_state_to_activate( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_activate_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def update_resource_group_level_state_to_in_progress( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, asc_location: str, alert_name: str, **kwargs: Any - ) -> None: - """Update the alert's state. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_name: Name of the alert object. Required. - :type alert_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_update_resource_group_level_state_to_in_progress_request( - resource_group_name=resource_group_name, - asc_location=asc_location, - alert_name=alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _simulate_initial( # pylint: disable=inconsistent-return-statements - self, - asc_location: str, - alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], - **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_simulator_request_body, (IOBase, bytes)): - _content = alert_simulator_request_body - else: - _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") - - _request = build_simulate_request( - asc_location=asc_location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: _models.AlertSimulatorRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Required. - :type alert_simulator_request_body: - ~azure.mgmt.security.v2022_01_01.models.AlertSimulatorRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Required. - :type alert_simulator_request_body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_simulate( - self, - asc_location: str, - alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Simulate security alerts. - - :param asc_location: The location where ASC stores the data of the subscription. can be - retrieved from Get locations. Required. - :type asc_location: str - :param alert_simulator_request_body: Alert Simulator Request Properties. Is either a - AlertSimulatorRequestBody type or a IO[bytes] type. Required. - :type alert_simulator_request_body: - ~azure.mgmt.security.v2022_01_01.models.AlertSimulatorRequestBody or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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._api_version or "2022-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._simulate_initial( # type: ignore - asc_location=asc_location, - alert_simulator_request_body=alert_simulator_request_body, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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": "original-uri"}, **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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_configuration.py deleted file mode 100644 index b822dd212ec4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_metadata.json deleted file mode 100644 index 59ceb6374562..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_metadata.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "chosen_version": "2022-01-01-preview", - "total_api_version_list": ["2022-01-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "governance_assignments": "GovernanceAssignmentsOperations", - "governance_rules": "GovernanceRulesOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_security_center.py deleted file mode 100644 index 8a7fe54ca5c5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_security_center.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import GovernanceAssignmentsOperations, GovernanceRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar governance_assignments: GovernanceAssignmentsOperations operations - :vartype governance_assignments: - azure.mgmt.security.v2022_01_01_preview.operations.GovernanceAssignmentsOperations - :ivar governance_rules: GovernanceRulesOperations operations - :vartype governance_rules: - azure.mgmt.security.v2022_01_01_preview.operations.GovernanceRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-01-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", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.governance_assignments = GovernanceAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-01-preview" - ) - self.governance_rules = GovernanceRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_configuration.py deleted file mode 100644 index 3a9a045bc314..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_security_center.py deleted file mode 100644 index 9bc01cdb0fb6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_security_center.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import GovernanceAssignmentsOperations, GovernanceRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar governance_assignments: GovernanceAssignmentsOperations operations - :vartype governance_assignments: - azure.mgmt.security.v2022_01_01_preview.aio.operations.GovernanceAssignmentsOperations - :ivar governance_rules: GovernanceRulesOperations operations - :vartype governance_rules: - azure.mgmt.security.v2022_01_01_preview.aio.operations.GovernanceRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-01-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", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.governance_assignments = GovernanceAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-01-preview" - ) - self.governance_rules = GovernanceRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/__init__.py deleted file mode 100644 index ecf203ec9b1d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,21 +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 ._governance_assignments_operations import GovernanceAssignmentsOperations -from ._governance_rules_operations import GovernanceRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GovernanceAssignmentsOperations", - "GovernanceRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py deleted file mode 100644 index 8f5e1fb3f5f2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py +++ /dev/null @@ -1,437 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._governance_assignments_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GovernanceAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_01_01_preview.aio.SecurityCenter`'s - :attr:`governance_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, assessment_name: str, **kwargs: Any) -> AsyncIterable["_models.GovernanceAssignment"]: - """Get governance assignments on all of your resources inside a scope. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :return: An iterator like instance of either GovernanceAssignment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment] - :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._api_version or "2022-01-01-preview") - ) - cls: ClsType[_models.GovernanceAssignmentsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - assessment_name=assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GovernanceAssignmentsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, scope: str, assessment_name: str, assignment_key: str, **kwargs: Any - ) -> _models.GovernanceAssignment: - """Get a specific governanceAssignment for the requested scope by AssignmentKey. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :return: GovernanceAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - assessment_name=assessment_name, - assignment_key=assignment_key, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GovernanceAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - scope: str, - assessment_name: str, - assignment_key: str, - governance_assignment: _models.GovernanceAssignment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GovernanceAssignment: - """Creates or updates a governance assignment on the given subscription. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :param governance_assignment: Governance assignment over a subscription scope. Required. - :type governance_assignment: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GovernanceAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - scope: str, - assessment_name: str, - assignment_key: str, - governance_assignment: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GovernanceAssignment: - """Creates or updates a governance assignment on the given subscription. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :param governance_assignment: Governance assignment over a subscription scope. Required. - :type governance_assignment: 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: GovernanceAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - scope: str, - assessment_name: str, - assignment_key: str, - governance_assignment: Union[_models.GovernanceAssignment, IO[bytes]], - **kwargs: Any - ) -> _models.GovernanceAssignment: - """Creates or updates a governance assignment on the given subscription. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :param governance_assignment: Governance assignment over a subscription scope. Is either a - GovernanceAssignment type or a IO[bytes] type. Required. - :type governance_assignment: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment or IO[bytes] - :return: GovernanceAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(governance_assignment, (IOBase, bytes)): - _content = governance_assignment - else: - _json = self._serialize.body(governance_assignment, "GovernanceAssignment") - - _request = build_create_or_update_request( - scope=scope, - assessment_name=assessment_name, - assignment_key=assignment_key, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GovernanceAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GovernanceAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, assessment_name: str, assignment_key: str, **kwargs: Any - ) -> None: - """Delete a GovernanceAssignment over a given scope. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - scope=scope, - assessment_name=assessment_name, - assignment_key=assignment_key, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py deleted file mode 100644 index 9c4b330c7b30..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py +++ /dev/null @@ -1,744 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._governance_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_execute_request, - build_get_request, - build_list_request, - build_operation_results_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GovernanceRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_01_01_preview.aio.SecurityCenter`'s - :attr:`governance_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.GovernanceRule"]: - """Get a list of all relevant governance rules over a scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :return: An iterator like instance of either GovernanceRule or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule] - :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._api_version or "2022-01-01-preview") - ) - cls: ClsType[_models.GovernanceRuleList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GovernanceRuleList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, scope: str, rule_id: str, **kwargs: Any) -> _models.GovernanceRule: - """Get a specific governance rule for the requested scope by ruleId. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :return: GovernanceRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - rule_id=rule_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GovernanceRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - scope: str, - rule_id: str, - governance_rule: _models.GovernanceRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GovernanceRule: - """Creates or updates a governance rule over a given scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param governance_rule: Governance rule over a given scope. Required. - :type governance_rule: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GovernanceRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - scope: str, - rule_id: str, - governance_rule: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GovernanceRule: - """Creates or updates a governance rule over a given scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param governance_rule: Governance rule over a given scope. Required. - :type governance_rule: 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: GovernanceRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, scope: str, rule_id: str, governance_rule: Union[_models.GovernanceRule, IO[bytes]], **kwargs: Any - ) -> _models.GovernanceRule: - """Creates or updates a governance rule over a given scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param governance_rule: Governance rule over a given scope. Is either a GovernanceRule type or - a IO[bytes] type. Required. - :type governance_rule: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule or - IO[bytes] - :return: GovernanceRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(governance_rule, (IOBase, bytes)): - _content = governance_rule - else: - _json = self._serialize.body(governance_rule, "GovernanceRule") - - _request = build_create_or_update_request( - scope=scope, - rule_id=rule_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GovernanceRule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GovernanceRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, scope: str, rule_id: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - scope=scope, - rule_id=rule_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete(self, scope: str, rule_id: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Delete a Governance rule over a given scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: 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._api_version or "2022-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - scope=scope, - rule_id=rule_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # 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 _execute_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - rule_id: str, - execute_governance_rule_params: Optional[Union[_models.ExecuteGovernanceRuleParams, IO[bytes]]] = None, - **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(execute_governance_rule_params, (IOBase, bytes)): - _content = execute_governance_rule_params - else: - if execute_governance_rule_params is not None: - _json = self._serialize.body(execute_governance_rule_params, "ExecuteGovernanceRuleParams") - else: - _json = None - - _request = build_execute_request( - scope=scope, - rule_id=rule_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - async def begin_execute( - self, - scope: str, - rule_id: str, - execute_governance_rule_params: Optional[_models.ExecuteGovernanceRuleParams] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Execute a governance rule. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param execute_governance_rule_params: Execute governance rule over a given scope. Default - value is None. - :type execute_governance_rule_params: - ~azure.mgmt.security.v2022_01_01_preview.models.ExecuteGovernanceRuleParams - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_execute( - self, - scope: str, - rule_id: str, - execute_governance_rule_params: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Execute a governance rule. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param execute_governance_rule_params: Execute governance rule over a given scope. Default - value is None. - :type execute_governance_rule_params: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_execute( - self, - scope: str, - rule_id: str, - execute_governance_rule_params: Optional[Union[_models.ExecuteGovernanceRuleParams, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Execute a governance rule. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param execute_governance_rule_params: Execute governance rule over a given scope. Is either a - ExecuteGovernanceRuleParams type or a IO[bytes] type. Default value is None. - :type execute_governance_rule_params: - ~azure.mgmt.security.v2022_01_01_preview.models.ExecuteGovernanceRuleParams or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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._api_version or "2022-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._execute_initial( # type: ignore - scope=scope, - rule_id=rule_id, - execute_governance_rule_params=execute_governance_rule_params, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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_async - async def operation_results( - self, scope: str, rule_id: str, operation_id: str, **kwargs: Any - ) -> Optional[_models.OperationResultAutoGenerated]: - """Get governance rules long run operation result for the requested scope by ruleId and - operationId. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param operation_id: The governance rule long running operation unique key. Required. - :type operation_id: str - :return: OperationResultAutoGenerated or None or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.OperationResultAutoGenerated or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[Optional[_models.OperationResultAutoGenerated]] = kwargs.pop("cls", None) - - _request = build_operation_results_request( - scope=scope, - rule_id=rule_id, - operation_id=operation_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OperationResultAutoGenerated", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/__init__.py deleted file mode 100644 index 7cecb4ad458c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/__init__.py +++ /dev/null @@ -1,59 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import Condition -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ExecuteGovernanceRuleParams -from ._models_py3 import GovernanceAssignment -from ._models_py3 import GovernanceAssignmentAdditionalData -from ._models_py3 import GovernanceAssignmentsList -from ._models_py3 import GovernanceEmailNotification -from ._models_py3 import GovernanceRule -from ._models_py3 import GovernanceRuleEmailNotification -from ._models_py3 import GovernanceRuleList -from ._models_py3 import GovernanceRuleMetadata -from ._models_py3 import GovernanceRuleOwnerSource -from ._models_py3 import OperationResultAutoGenerated -from ._models_py3 import RemediationEta -from ._models_py3 import Resource - -from ._security_center_enums import GovernanceRuleConditionOperator -from ._security_center_enums import GovernanceRuleOwnerSourceType -from ._security_center_enums import GovernanceRuleSourceResourceType -from ._security_center_enums import GovernanceRuleType -from ._security_center_enums import OperationResult -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "Condition", - "ErrorAdditionalInfo", - "ExecuteGovernanceRuleParams", - "GovernanceAssignment", - "GovernanceAssignmentAdditionalData", - "GovernanceAssignmentsList", - "GovernanceEmailNotification", - "GovernanceRule", - "GovernanceRuleEmailNotification", - "GovernanceRuleList", - "GovernanceRuleMetadata", - "GovernanceRuleOwnerSource", - "OperationResultAutoGenerated", - "RemediationEta", - "Resource", - "GovernanceRuleConditionOperator", - "GovernanceRuleOwnerSourceType", - "GovernanceRuleSourceResourceType", - "GovernanceRuleType", - "OperationResult", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_models_py3.py deleted file mode 100644 index f4f2f28269aa..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_models_py3.py +++ /dev/null @@ -1,754 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class CloudErrorBody(_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.security.v2022_01_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2022_01_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Condition(_serialization.Model): - """Governance rule's condition. - - :ivar property: The governance rule Condition's Property, e.g. Severity or AssessmentKey, see - examples. - :vartype property: str - :ivar value: The governance rule Condition's Value like severity Low, High or assessments keys, - see examples. - :vartype value: str - :ivar operator: The governance rule Condition's Operator, for example Equals for severity or In - for list of assessments, see examples. Known values are: "Equals" and "In". - :vartype operator: str or - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleConditionOperator - """ - - _attribute_map = { - "property": {"key": "property", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - } - - def __init__( - self, - *, - property: Optional[str] = None, # pylint: disable=redefined-builtin - value: Optional[str] = None, - operator: Optional[Union[str, "_models.GovernanceRuleConditionOperator"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword property: The governance rule Condition's Property, e.g. Severity or AssessmentKey, - see examples. - :paramtype property: str - :keyword value: The governance rule Condition's Value like severity Low, High or assessments - keys, see examples. - :paramtype value: str - :keyword operator: The governance rule Condition's Operator, for example Equals for severity or - In for list of assessments, see examples. Known values are: "Equals" and "In". - :paramtype operator: str or - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleConditionOperator - """ - super().__init__(**kwargs) - self.property = property - self.value = value - self.operator = operator - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ExecuteGovernanceRuleParams(_serialization.Model): - """Governance rule execution parameters. - - :ivar override: Describe if governance rule should be override. - :vartype override: bool - """ - - _attribute_map = { - "override": {"key": "override", "type": "bool"}, - } - - def __init__(self, *, override: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword override: Describe if governance rule should be override. - :paramtype override: bool - """ - super().__init__(**kwargs) - self.override = override - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class GovernanceAssignment(Resource): - """Governance assignment over a given scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar owner: The Owner for the governance assignment - e.g. user@contoso.com - see example. - :vartype owner: str - :ivar remediation_due_date: The remediation due-date - after this date Secure Score will be - affected (in case of active grace-period). - :vartype remediation_due_date: ~datetime.datetime - :ivar remediation_eta: The ETA (estimated time of arrival) for remediation (optional), see - example. - :vartype remediation_eta: ~azure.mgmt.security.v2022_01_01_preview.models.RemediationEta - :ivar is_grace_period: Defines whether there is a grace period on the governance assignment. - :vartype is_grace_period: bool - :ivar governance_email_notification: The email notifications settings for the governance rule, - states whether to disable notifications for mangers and owners. - :vartype governance_email_notification: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceEmailNotification - :ivar additional_data: The additional data for the governance assignment - e.g. links to ticket - (optional), see example. - :vartype additional_data: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignmentAdditionalData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "owner": {"key": "properties.owner", "type": "str"}, - "remediation_due_date": {"key": "properties.remediationDueDate", "type": "iso-8601"}, - "remediation_eta": {"key": "properties.remediationEta", "type": "RemediationEta"}, - "is_grace_period": {"key": "properties.isGracePeriod", "type": "bool"}, - "governance_email_notification": { - "key": "properties.governanceEmailNotification", - "type": "GovernanceEmailNotification", - }, - "additional_data": {"key": "properties.additionalData", "type": "GovernanceAssignmentAdditionalData"}, - } - - def __init__( - self, - *, - owner: Optional[str] = None, - remediation_due_date: Optional[datetime.datetime] = None, - remediation_eta: Optional["_models.RemediationEta"] = None, - is_grace_period: Optional[bool] = None, - governance_email_notification: Optional["_models.GovernanceEmailNotification"] = None, - additional_data: Optional["_models.GovernanceAssignmentAdditionalData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword owner: The Owner for the governance assignment - e.g. user@contoso.com - see example. - :paramtype owner: str - :keyword remediation_due_date: The remediation due-date - after this date Secure Score will be - affected (in case of active grace-period). - :paramtype remediation_due_date: ~datetime.datetime - :keyword remediation_eta: The ETA (estimated time of arrival) for remediation (optional), see - example. - :paramtype remediation_eta: ~azure.mgmt.security.v2022_01_01_preview.models.RemediationEta - :keyword is_grace_period: Defines whether there is a grace period on the governance assignment. - :paramtype is_grace_period: bool - :keyword governance_email_notification: The email notifications settings for the governance - rule, states whether to disable notifications for mangers and owners. - :paramtype governance_email_notification: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceEmailNotification - :keyword additional_data: The additional data for the governance assignment - e.g. links to - ticket (optional), see example. - :paramtype additional_data: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignmentAdditionalData - """ - super().__init__(**kwargs) - self.owner = owner - self.remediation_due_date = remediation_due_date - self.remediation_eta = remediation_eta - self.is_grace_period = is_grace_period - self.governance_email_notification = governance_email_notification - self.additional_data = additional_data - - -class GovernanceAssignmentAdditionalData(_serialization.Model): - """Describe the additional data of governance assignment - optional. - - :ivar ticket_number: Ticket number associated with this governance assignment. - :vartype ticket_number: int - :ivar ticket_link: Ticket link associated with this governance assignment - for example: - https://snow.com. - :vartype ticket_link: str - :ivar ticket_status: The ticket status associated with this governance assignment - for - example: Active. - :vartype ticket_status: str - """ - - _validation = { - "ticket_number": {"minimum": 0}, - } - - _attribute_map = { - "ticket_number": {"key": "ticketNumber", "type": "int"}, - "ticket_link": {"key": "ticketLink", "type": "str"}, - "ticket_status": {"key": "ticketStatus", "type": "str"}, - } - - def __init__( - self, - *, - ticket_number: Optional[int] = None, - ticket_link: Optional[str] = None, - ticket_status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword ticket_number: Ticket number associated with this governance assignment. - :paramtype ticket_number: int - :keyword ticket_link: Ticket link associated with this governance assignment - for example: - https://snow.com. - :paramtype ticket_link: str - :keyword ticket_status: The ticket status associated with this governance assignment - for - example: Active. - :paramtype ticket_status: str - """ - super().__init__(**kwargs) - self.ticket_number = ticket_number - self.ticket_link = ticket_link - self.ticket_status = ticket_status - - -class GovernanceAssignmentsList(_serialization.Model): - """Page of a governance assignments list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of governance assignments in this page. - :vartype value: list[~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GovernanceAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class GovernanceEmailNotification(_serialization.Model): - """The governance email weekly notification configuration. - - :ivar disable_manager_email_notification: Exclude manager from weekly email notification. - :vartype disable_manager_email_notification: bool - :ivar disable_owner_email_notification: Exclude owner from weekly email notification. - :vartype disable_owner_email_notification: bool - """ - - _attribute_map = { - "disable_manager_email_notification": {"key": "disableManagerEmailNotification", "type": "bool"}, - "disable_owner_email_notification": {"key": "disableOwnerEmailNotification", "type": "bool"}, - } - - def __init__( - self, - *, - disable_manager_email_notification: Optional[bool] = None, - disable_owner_email_notification: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disable_manager_email_notification: Exclude manager from weekly email notification. - :paramtype disable_manager_email_notification: bool - :keyword disable_owner_email_notification: Exclude owner from weekly email notification. - :paramtype disable_owner_email_notification: bool - """ - super().__init__(**kwargs) - self.disable_manager_email_notification = disable_manager_email_notification - self.disable_owner_email_notification = disable_owner_email_notification - - -class GovernanceRule(Resource): # pylint: disable=too-many-instance-attributes - """Governance rule over a given scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar tenant_id: The tenantId (GUID). - :vartype tenant_id: str - :ivar display_name: Display name of the governance rule. - :vartype display_name: str - :ivar description: Description of the governance rule. - :vartype description: str - :ivar remediation_timeframe: Governance rule remediation timeframe - this is the time that will - affect on the grace-period duration e.g. 7.00:00:00 - means 7 days. - :vartype remediation_timeframe: str - :ivar is_grace_period: Defines whether there is a grace period on the governance rule. - :vartype is_grace_period: bool - :ivar rule_priority: The governance rule priority, priority to the lower number. Rules with the - same priority on the same scope will not be allowed. - :vartype rule_priority: int - :ivar is_disabled: Defines whether the rule is active/inactive. - :vartype is_disabled: bool - :ivar rule_type: The rule type of the governance rule, defines the source of the rule e.g. - Integrated. Known values are: "Integrated" and "ServiceNow". - :vartype rule_type: str or ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleType - :ivar source_resource_type: The governance rule source, what the rule affects, e.g. - Assessments. "Assessments" - :vartype source_resource_type: str or - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleSourceResourceType - :ivar excluded_scopes: Excluded scopes, filter out the descendants of the scope (on management - scopes). - :vartype excluded_scopes: list[str] - :ivar condition_sets: The governance rule conditionSets - see examples. - :vartype condition_sets: list[JSON] - :ivar include_member_scopes: Defines whether the rule is management scope rule (master - connector as a single scope or management scope). - :vartype include_member_scopes: bool - :ivar owner_source: The owner source for the governance rule - e.g. Manually by - user@contoso.com - see example. - :vartype owner_source: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleOwnerSource - :ivar governance_email_notification: The email notifications settings for the governance rule, - states whether to disable notifications for mangers and owners. - :vartype governance_email_notification: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleEmailNotification - :ivar metadata: The governance rule metadata. - :vartype metadata: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleMetadata - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "tenant_id": {"readonly": True}, - "remediation_timeframe": {"pattern": r"^[0-9]+\.[0-9]{2}:[0-9]{2}:[0-9]{2}$"}, - "rule_priority": {"maximum": 1000, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tenant_id": {"key": "properties.tenantId", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "remediation_timeframe": {"key": "properties.remediationTimeframe", "type": "str"}, - "is_grace_period": {"key": "properties.isGracePeriod", "type": "bool"}, - "rule_priority": {"key": "properties.rulePriority", "type": "int"}, - "is_disabled": {"key": "properties.isDisabled", "type": "bool"}, - "rule_type": {"key": "properties.ruleType", "type": "str"}, - "source_resource_type": {"key": "properties.sourceResourceType", "type": "str"}, - "excluded_scopes": {"key": "properties.excludedScopes", "type": "[str]"}, - "condition_sets": {"key": "properties.conditionSets", "type": "[object]"}, - "include_member_scopes": {"key": "properties.includeMemberScopes", "type": "bool"}, - "owner_source": {"key": "properties.ownerSource", "type": "GovernanceRuleOwnerSource"}, - "governance_email_notification": { - "key": "properties.governanceEmailNotification", - "type": "GovernanceRuleEmailNotification", - }, - "metadata": {"key": "properties.metadata", "type": "GovernanceRuleMetadata"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - remediation_timeframe: Optional[str] = None, - is_grace_period: Optional[bool] = None, - rule_priority: Optional[int] = None, - is_disabled: Optional[bool] = None, - rule_type: Optional[Union[str, "_models.GovernanceRuleType"]] = None, - source_resource_type: Optional[Union[str, "_models.GovernanceRuleSourceResourceType"]] = None, - excluded_scopes: Optional[List[str]] = None, - condition_sets: Optional[List[JSON]] = None, - include_member_scopes: Optional[bool] = None, - owner_source: Optional["_models.GovernanceRuleOwnerSource"] = None, - governance_email_notification: Optional["_models.GovernanceRuleEmailNotification"] = None, - metadata: Optional["_models.GovernanceRuleMetadata"] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: Display name of the governance rule. - :paramtype display_name: str - :keyword description: Description of the governance rule. - :paramtype description: str - :keyword remediation_timeframe: Governance rule remediation timeframe - this is the time that - will affect on the grace-period duration e.g. 7.00:00:00 - means 7 days. - :paramtype remediation_timeframe: str - :keyword is_grace_period: Defines whether there is a grace period on the governance rule. - :paramtype is_grace_period: bool - :keyword rule_priority: The governance rule priority, priority to the lower number. Rules with - the same priority on the same scope will not be allowed. - :paramtype rule_priority: int - :keyword is_disabled: Defines whether the rule is active/inactive. - :paramtype is_disabled: bool - :keyword rule_type: The rule type of the governance rule, defines the source of the rule e.g. - Integrated. Known values are: "Integrated" and "ServiceNow". - :paramtype rule_type: str or ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleType - :keyword source_resource_type: The governance rule source, what the rule affects, e.g. - Assessments. "Assessments" - :paramtype source_resource_type: str or - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleSourceResourceType - :keyword excluded_scopes: Excluded scopes, filter out the descendants of the scope (on - management scopes). - :paramtype excluded_scopes: list[str] - :keyword condition_sets: The governance rule conditionSets - see examples. - :paramtype condition_sets: list[JSON] - :keyword include_member_scopes: Defines whether the rule is management scope rule (master - connector as a single scope or management scope). - :paramtype include_member_scopes: bool - :keyword owner_source: The owner source for the governance rule - e.g. Manually by - user@contoso.com - see example. - :paramtype owner_source: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleOwnerSource - :keyword governance_email_notification: The email notifications settings for the governance - rule, states whether to disable notifications for mangers and owners. - :paramtype governance_email_notification: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleEmailNotification - :keyword metadata: The governance rule metadata. - :paramtype metadata: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleMetadata - """ - super().__init__(**kwargs) - self.tenant_id = None - self.display_name = display_name - self.description = description - self.remediation_timeframe = remediation_timeframe - self.is_grace_period = is_grace_period - self.rule_priority = rule_priority - self.is_disabled = is_disabled - self.rule_type = rule_type - self.source_resource_type = source_resource_type - self.excluded_scopes = excluded_scopes - self.condition_sets = condition_sets - self.include_member_scopes = include_member_scopes - self.owner_source = owner_source - self.governance_email_notification = governance_email_notification - self.metadata = metadata - - -class GovernanceRuleEmailNotification(_serialization.Model): - """The governance email weekly notification configuration. - - :ivar disable_manager_email_notification: Defines whether manager email notifications are - disabled. - :vartype disable_manager_email_notification: bool - :ivar disable_owner_email_notification: Defines whether owner email notifications are disabled. - :vartype disable_owner_email_notification: bool - """ - - _attribute_map = { - "disable_manager_email_notification": {"key": "disableManagerEmailNotification", "type": "bool"}, - "disable_owner_email_notification": {"key": "disableOwnerEmailNotification", "type": "bool"}, - } - - def __init__( - self, - *, - disable_manager_email_notification: Optional[bool] = None, - disable_owner_email_notification: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disable_manager_email_notification: Defines whether manager email notifications are - disabled. - :paramtype disable_manager_email_notification: bool - :keyword disable_owner_email_notification: Defines whether owner email notifications are - disabled. - :paramtype disable_owner_email_notification: bool - """ - super().__init__(**kwargs) - self.disable_manager_email_notification = disable_manager_email_notification - self.disable_owner_email_notification = disable_owner_email_notification - - -class GovernanceRuleList(_serialization.Model): - """Page of a governance rules list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of governance rules in this page. - :vartype value: list[~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GovernanceRule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class GovernanceRuleMetadata(_serialization.Model): - """The governance rule metadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar created_by: Governance rule Created by object id (GUID). - :vartype created_by: str - :ivar created_on: Governance rule creation date. - :vartype created_on: ~datetime.datetime - :ivar updated_by: Governance rule last updated by object id (GUID). - :vartype updated_by: str - :ivar updated_on: Governance rule last update date. - :vartype updated_on: ~datetime.datetime - """ - - _validation = { - "created_by": {"readonly": True}, - "created_on": {"readonly": True}, - "updated_by": {"readonly": True}, - "updated_on": {"readonly": True}, - } - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_on": {"key": "createdOn", "type": "iso-8601"}, - "updated_by": {"key": "updatedBy", "type": "str"}, - "updated_on": {"key": "updatedOn", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.created_by = None - self.created_on = None - self.updated_by = None - self.updated_on = None - - -class GovernanceRuleOwnerSource(_serialization.Model): - """Describe the owner source of governance rule. - - :ivar type: The owner type for the governance rule owner source. Known values are: "ByTag" and - "Manually". - :vartype type: str or - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleOwnerSourceType - :ivar value: The source value e.g. tag key like owner name or email address. - :vartype value: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.GovernanceRuleOwnerSourceType"]] = None, - value: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The owner type for the governance rule owner source. Known values are: "ByTag" - and "Manually". - :paramtype type: str or - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRuleOwnerSourceType - :keyword value: The source value e.g. tag key like owner name or email address. - :paramtype value: str - """ - super().__init__(**kwargs) - self.type = type - self.value = value - - -class OperationResultAutoGenerated(_serialization.Model): - """Long run operation status of governance rule over a given scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the long run operation result of governance rule. Known values are: - "Succeeded", "Failed", and "Canceled". - :vartype status: str or ~azure.mgmt.security.v2022_01_01_preview.models.OperationResult - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status = None - - -class RemediationEta(_serialization.Model): - """The ETA (estimated time of arrival) for remediation. - - All required parameters must be populated in order to send to server. - - :ivar eta: ETA for remediation. Required. - :vartype eta: ~datetime.datetime - :ivar justification: Justification for change of Eta. Required. - :vartype justification: str - """ - - _validation = { - "eta": {"required": True}, - "justification": {"required": True}, - } - - _attribute_map = { - "eta": {"key": "eta", "type": "iso-8601"}, - "justification": {"key": "justification", "type": "str"}, - } - - def __init__(self, *, eta: datetime.datetime, justification: str, **kwargs: Any) -> None: - """ - :keyword eta: ETA for remediation. Required. - :paramtype eta: ~datetime.datetime - :keyword justification: Justification for change of Eta. Required. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.eta = eta - self.justification = justification diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_security_center_enums.py deleted file mode 100644 index f3b5f33e2b11..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,58 +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 GovernanceRuleConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The governance rule Condition's Operator, for example Equals for severity or In for list of - assessments, see examples. - """ - - EQUALS = "Equals" - """Checks that the string value of the data defined in Property equals the given value - exact fit""" - IN_ENUM = "In" - """Checks that the string value of the data defined in Property equals any of the given values - (exact fit)""" - - -class GovernanceRuleOwnerSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The owner type for the governance rule owner source.""" - - BY_TAG = "ByTag" - """The rule source type defined using resource tag""" - MANUALLY = "Manually" - """The rule source type defined manually""" - - -class GovernanceRuleSourceResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The governance rule source, what the rule affects, e.g. Assessments.""" - - ASSESSMENTS = "Assessments" - """The source of the governance rule is assessments""" - - -class GovernanceRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rule type of the governance rule, defines the source of the rule e.g. Integrated.""" - - INTEGRATED = "Integrated" - """The source of the rule type definition is integrated""" - SERVICE_NOW = "ServiceNow" - """The source of the rule type definition is ServiceNow""" - - -class OperationResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the long run operation result of governance rule.""" - - SUCCEEDED = "Succeeded" - """The operation succeeded""" - FAILED = "Failed" - """The operation failed""" - CANCELED = "Canceled" - """The operation canceled""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/__init__.py deleted file mode 100644 index ecf203ec9b1d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/__init__.py +++ /dev/null @@ -1,21 +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 ._governance_assignments_operations import GovernanceAssignmentsOperations -from ._governance_rules_operations import GovernanceRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GovernanceAssignmentsOperations", - "GovernanceRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py deleted file mode 100644 index 1b845e3ecf33..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py +++ /dev/null @@ -1,543 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(scope: str, assessment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments" - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str"), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str", pattern=r"^[-\w\._\(\)]+$"), - } - - _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_request(scope: str, assessment_name: str, assignment_key: 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", "2022-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments/{assignmentKey}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str"), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str", pattern=r"^[-\w\._\(\)]+$"), - "assignmentKey": _SERIALIZER.url("assignment_key", assignment_key, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(scope: str, assessment_name: str, assignment_key: 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", "2022-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments/{assignmentKey}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str"), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str", pattern=r"^[-\w\._\(\)]+$"), - "assignmentKey": _SERIALIZER.url("assignment_key", assignment_key, "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_delete_request(scope: str, assessment_name: str, assignment_key: str, **kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments/{assignmentKey}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str"), - "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str", pattern=r"^[-\w\._\(\)]+$"), - "assignmentKey": _SERIALIZER.url("assignment_key", assignment_key, "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) - - -class GovernanceAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_01_01_preview.SecurityCenter`'s - :attr:`governance_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, assessment_name: str, **kwargs: Any) -> Iterable["_models.GovernanceAssignment"]: - """Get governance assignments on all of your resources inside a scope. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :return: An iterator like instance of either GovernanceAssignment or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment] - :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._api_version or "2022-01-01-preview") - ) - cls: ClsType[_models.GovernanceAssignmentsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - assessment_name=assessment_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GovernanceAssignmentsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, scope: str, assessment_name: str, assignment_key: str, **kwargs: Any) -> _models.GovernanceAssignment: - """Get a specific governanceAssignment for the requested scope by AssignmentKey. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :return: GovernanceAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - assessment_name=assessment_name, - assignment_key=assignment_key, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GovernanceAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - scope: str, - assessment_name: str, - assignment_key: str, - governance_assignment: _models.GovernanceAssignment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GovernanceAssignment: - """Creates or updates a governance assignment on the given subscription. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :param governance_assignment: Governance assignment over a subscription scope. Required. - :type governance_assignment: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GovernanceAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - scope: str, - assessment_name: str, - assignment_key: str, - governance_assignment: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GovernanceAssignment: - """Creates or updates a governance assignment on the given subscription. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :param governance_assignment: Governance assignment over a subscription scope. Required. - :type governance_assignment: 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: GovernanceAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - scope: str, - assessment_name: str, - assignment_key: str, - governance_assignment: Union[_models.GovernanceAssignment, IO[bytes]], - **kwargs: Any - ) -> _models.GovernanceAssignment: - """Creates or updates a governance assignment on the given subscription. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :param governance_assignment: Governance assignment over a subscription scope. Is either a - GovernanceAssignment type or a IO[bytes] type. Required. - :type governance_assignment: - ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment or IO[bytes] - :return: GovernanceAssignment or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(governance_assignment, (IOBase, bytes)): - _content = governance_assignment - else: - _json = self._serialize.body(governance_assignment, "GovernanceAssignment") - - _request = build_create_or_update_request( - scope=scope, - assessment_name=assessment_name, - assignment_key=assignment_key, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GovernanceAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GovernanceAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, assessment_name: str, assignment_key: str, **kwargs: Any - ) -> None: - """Delete a GovernanceAssignment over a given scope. - - :param scope: The scope of the Governance assignments. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param assessment_name: The Assessment Key - A unique key for the assessment type. Required. - :type assessment_name: str - :param assignment_key: The governance assignment key - the assessment key of the required - governance assignment. Required. - :type assignment_key: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - scope=scope, - assessment_name=assessment_name, - assignment_key=assignment_key, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py deleted file mode 100644 index 7ba3858be5ad..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py +++ /dev/null @@ -1,891 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "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_get_request(scope: str, rule_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", "2022-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_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_create_or_update_request(scope: str, rule_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", "2022-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_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 - 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(scope: str, rule_id: str, **kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_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="DELETE", url=_url, params=_params, **kwargs) - - -def build_execute_request(scope: str, rule_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", "2022-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}/execute") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_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 - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_operation_results_request(scope: str, rule_id: str, operation_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", "2022-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}/operationResults/{operationId}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "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) - - -class GovernanceRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_01_01_preview.SecurityCenter`'s - :attr:`governance_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> Iterable["_models.GovernanceRule"]: - """Get a list of all relevant governance rules over a scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :return: An iterator like instance of either GovernanceRule or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule] - :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._api_version or "2022-01-01-preview") - ) - cls: ClsType[_models.GovernanceRuleList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GovernanceRuleList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, scope: str, rule_id: str, **kwargs: Any) -> _models.GovernanceRule: - """Get a specific governance rule for the requested scope by ruleId. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :return: GovernanceRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) - - _request = build_get_request( - scope=scope, - rule_id=rule_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GovernanceRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - scope: str, - rule_id: str, - governance_rule: _models.GovernanceRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GovernanceRule: - """Creates or updates a governance rule over a given scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param governance_rule: Governance rule over a given scope. Required. - :type governance_rule: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GovernanceRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - scope: str, - rule_id: str, - governance_rule: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GovernanceRule: - """Creates or updates a governance rule over a given scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param governance_rule: Governance rule over a given scope. Required. - :type governance_rule: 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: GovernanceRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, scope: str, rule_id: str, governance_rule: Union[_models.GovernanceRule, IO[bytes]], **kwargs: Any - ) -> _models.GovernanceRule: - """Creates or updates a governance rule over a given scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param governance_rule: Governance rule over a given scope. Is either a GovernanceRule type or - a IO[bytes] type. Required. - :type governance_rule: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule or - IO[bytes] - :return: GovernanceRule or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.GovernanceRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(governance_rule, (IOBase, bytes)): - _content = governance_rule - else: - _json = self._serialize.body(governance_rule, "GovernanceRule") - - _request = build_create_or_update_request( - scope=scope, - rule_id=rule_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GovernanceRule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GovernanceRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, scope: str, rule_id: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - scope=scope, - rule_id=rule_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete(self, scope: str, rule_id: str, **kwargs: Any) -> LROPoller[None]: - """Delete a Governance rule over a given scope. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: 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._api_version or "2022-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - scope=scope, - rule_id=rule_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # 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 _execute_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - rule_id: str, - execute_governance_rule_params: Optional[Union[_models.ExecuteGovernanceRuleParams, IO[bytes]]] = None, - **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(execute_governance_rule_params, (IOBase, bytes)): - _content = execute_governance_rule_params - else: - if execute_governance_rule_params is not None: - _json = self._serialize.body(execute_governance_rule_params, "ExecuteGovernanceRuleParams") - else: - _json = None - - _request = build_execute_request( - scope=scope, - rule_id=rule_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - def begin_execute( - self, - scope: str, - rule_id: str, - execute_governance_rule_params: Optional[_models.ExecuteGovernanceRuleParams] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Execute a governance rule. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param execute_governance_rule_params: Execute governance rule over a given scope. Default - value is None. - :type execute_governance_rule_params: - ~azure.mgmt.security.v2022_01_01_preview.models.ExecuteGovernanceRuleParams - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_execute( - self, - scope: str, - rule_id: str, - execute_governance_rule_params: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Execute a governance rule. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param execute_governance_rule_params: Execute governance rule over a given scope. Default - value is None. - :type execute_governance_rule_params: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_execute( - self, - scope: str, - rule_id: str, - execute_governance_rule_params: Optional[Union[_models.ExecuteGovernanceRuleParams, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Execute a governance rule. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param execute_governance_rule_params: Execute governance rule over a given scope. Is either a - ExecuteGovernanceRuleParams type or a IO[bytes] type. Default value is None. - :type execute_governance_rule_params: - ~azure.mgmt.security.v2022_01_01_preview.models.ExecuteGovernanceRuleParams or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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._api_version or "2022-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._execute_initial( # type: ignore - scope=scope, - rule_id=rule_id, - execute_governance_rule_params=execute_governance_rule_params, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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 operation_results( - self, scope: str, rule_id: str, operation_id: str, **kwargs: Any - ) -> Optional[_models.OperationResultAutoGenerated]: - """Get governance rules long run operation result for the requested scope by ruleId and - operationId. - - :param scope: The scope of the Governance rules. Valid scopes are: management group (format: - 'providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - Required. - :type scope: str - :param rule_id: The governance rule key - unique key for the standard governance rule (GUID). - Required. - :type rule_id: str - :param operation_id: The governance rule long running operation unique key. Required. - :type operation_id: str - :return: OperationResultAutoGenerated or None or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_01_01_preview.models.OperationResultAutoGenerated or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") - ) - cls: ClsType[Optional[_models.OperationResultAutoGenerated]] = kwargs.pop("cls", None) - - _request = build_operation_results_request( - scope=scope, - rule_id=rule_id, - operation_id=operation_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OperationResultAutoGenerated", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_configuration.py deleted file mode 100644 index 9c4f49f40b40..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-03-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_metadata.json deleted file mode 100644 index 06641fba8d17..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2022-03-01", - "total_api_version_list": ["2022-03-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "pricings": "PricingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_security_center.py deleted file mode 100644 index 3fb86b37837f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_security_center.py +++ /dev/null @@ -1,107 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import PricingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.v2022_03_01.operations.PricingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-03-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_configuration.py deleted file mode 100644 index c90c1b05b83d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-03-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_security_center.py deleted file mode 100644 index 09f0daec148a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_security_center.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import PricingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.v2022_03_01.aio.operations.PricingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-03-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/__init__.py deleted file mode 100644 index 3f34d5a48636..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._pricings_operations import PricingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PricingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py deleted file mode 100644 index 7fe672d518c6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py +++ /dev/null @@ -1,263 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._pricings_operations import build_get_request, build_list_request, build_update_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PricingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_03_01.aio.SecurityCenter`'s - :attr:`pricings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.PricingList: - """Lists Microsoft Defender for Cloud pricing configurations in the subscription. - - :return: PricingList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.PricingList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) - cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PricingList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: - """Gets a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - _request = build_get_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, pricing_name: str, pricing: _models.Pricing, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: ~azure.mgmt.security.v2022_03_01.models.Pricing - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, pricing_name: str, pricing: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: 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: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. - :type pricing: ~azure.mgmt.security.v2022_03_01.models.Pricing or IO[bytes] - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pricing, (IOBase, bytes)): - _content = pricing - else: - _json = self._serialize.body(pricing, "Pricing") - - _request = build_update_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/__init__.py deleted file mode 100644 index 82e99d49aec6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/__init__.py +++ /dev/null @@ -1,29 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Pricing -from ._models_py3 import PricingList -from ._models_py3 import Resource - -from ._security_center_enums import PricingTier -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "ErrorAdditionalInfo", - "Pricing", - "PricingList", - "Resource", - "PricingTier", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/_models_py3.py deleted file mode 100644 index f8726eb52447..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/_models_py3.py +++ /dev/null @@ -1,225 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CloudErrorBody(_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.security.v2022_03_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2022_03_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Pricing(Resource): - """Microsoft Defender for Cloud is provided in two pricing tiers: free and standard, with the - standard tier available with a trial period. The standard tier offers advanced security - capabilities, while the free tier offers basic security features. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar pricing_tier: The pricing tier value. Microsoft Defender for Cloud is provided in two - pricing tiers: free and standard, with the standard tier available with a trial period. The - standard tier offers advanced security capabilities, while the free tier offers basic security - features. Known values are: "Free" and "Standard". - :vartype pricing_tier: str or ~azure.mgmt.security.v2022_03_01.models.PricingTier - :ivar sub_plan: The sub-plan selected for a Standard pricing configuration, when more than one - sub-plan is available. Each sub-plan enables a set of security features. When not specified, - full plan is applied. - :vartype sub_plan: str - :ivar free_trial_remaining_time: The duration left for the subscriptions free trial period - in - ISO 8601 format (e.g. P3Y6M4DT12H30M5S). - :vartype free_trial_remaining_time: ~datetime.timedelta - :ivar deprecated: Optional. True if the plan is deprecated. If there are replacing plans they - will appear in ``replacedBy`` property. - :vartype deprecated: bool - :ivar replaced_by: Optional. List of plans that replace this plan. This property exists only if - this plan is deprecated. - :vartype replaced_by: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "free_trial_remaining_time": {"readonly": True}, - "deprecated": {"readonly": True}, - "replaced_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "pricing_tier": {"key": "properties.pricingTier", "type": "str"}, - "sub_plan": {"key": "properties.subPlan", "type": "str"}, - "free_trial_remaining_time": {"key": "properties.freeTrialRemainingTime", "type": "duration"}, - "deprecated": {"key": "properties.deprecated", "type": "bool"}, - "replaced_by": {"key": "properties.replacedBy", "type": "[str]"}, - } - - def __init__( - self, - *, - pricing_tier: Optional[Union[str, "_models.PricingTier"]] = None, - sub_plan: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword pricing_tier: The pricing tier value. Microsoft Defender for Cloud is provided in two - pricing tiers: free and standard, with the standard tier available with a trial period. The - standard tier offers advanced security capabilities, while the free tier offers basic security - features. Known values are: "Free" and "Standard". - :paramtype pricing_tier: str or ~azure.mgmt.security.v2022_03_01.models.PricingTier - :keyword sub_plan: The sub-plan selected for a Standard pricing configuration, when more than - one sub-plan is available. Each sub-plan enables a set of security features. When not - specified, full plan is applied. - :paramtype sub_plan: str - """ - super().__init__(**kwargs) - self.pricing_tier = pricing_tier - self.sub_plan = sub_plan - self.free_trial_remaining_time = None - self.deprecated = None - self.replaced_by = None - - -class PricingList(_serialization.Model): - """List of pricing configurations response. - - All required parameters must be populated in order to send to server. - - :ivar value: List of pricing configurations. Required. - :vartype value: list[~azure.mgmt.security.v2022_03_01.models.Pricing] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Pricing]"}, - } - - def __init__(self, *, value: List["_models.Pricing"], **kwargs: Any) -> None: - """ - :keyword value: List of pricing configurations. Required. - :paramtype value: list[~azure.mgmt.security.v2022_03_01.models.Pricing] - """ - super().__init__(**kwargs) - self.value = value diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/_security_center_enums.py deleted file mode 100644 index 340d6e87274f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/models/_security_center_enums.py +++ /dev/null @@ -1,22 +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 PricingTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The pricing tier value. Microsoft Defender for Cloud is provided in two pricing tiers: free and - standard, with the standard tier available with a trial period. The standard tier offers - advanced security capabilities, while the free tier offers basic security features. - """ - - FREE = "Free" - """Get free Microsoft Defender for Cloud experience with basic security features""" - STANDARD = "Standard" - """Get the standard Microsoft Defender for Cloud experience with advanced security features""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/__init__.py deleted file mode 100644 index 3f34d5a48636..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._pricings_operations import PricingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PricingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py deleted file mode 100644 index 62221fd0c2ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py +++ /dev/null @@ -1,351 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2022-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(pricing_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", "2022-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url("pricing_name", pricing_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_update_request(pricing_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", "2022-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url("pricing_name", pricing_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) - - -class PricingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_03_01.SecurityCenter`'s - :attr:`pricings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> _models.PricingList: - """Lists Microsoft Defender for Cloud pricing configurations in the subscription. - - :return: PricingList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.PricingList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) - cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PricingList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: - """Gets a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - _request = build_get_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, pricing_name: str, pricing: _models.Pricing, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: ~azure.mgmt.security.v2022_03_01.models.Pricing - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, pricing_name: str, pricing: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: 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: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. - :type pricing: ~azure.mgmt.security.v2022_03_01.models.Pricing or IO[bytes] - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_03_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pricing, (IOBase, bytes)): - _content = pricing - else: - _json = self._serialize.body(pricing, "Pricing") - - _request = build_update_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_configuration.py deleted file mode 100644 index f96d322e88f8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-05-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_metadata.json deleted file mode 100644 index 000473759a5c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2022-05-01", - "total_api_version_list": ["2022-05-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "settings": "SettingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_security_center.py deleted file mode 100644 index 609dfa142dbf..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_security_center.py +++ /dev/null @@ -1,107 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar settings: SettingsOperations operations - :vartype settings: azure.mgmt.security.v2022_05_01.operations.SettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-05-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_configuration.py deleted file mode 100644 index ae2332c5f6c5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-05-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_security_center.py deleted file mode 100644 index d010d839e1b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_security_center.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar settings: SettingsOperations operations - :vartype settings: azure.mgmt.security.v2022_05_01.aio.operations.SettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-05-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/__init__.py deleted file mode 100644 index 1046445c98b6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._settings_operations import SettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py deleted file mode 100644 index 3c4b0b2833e5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py +++ /dev/null @@ -1,308 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._settings_operations import build_get_request, build_list_request, build_update_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_05_01.aio.SecurityCenter`'s - :attr:`settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: - """Settings about different configurations in Microsoft Defender for Cloud. - - :return: An iterator like instance of either Setting or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_05_01.models.Setting] - :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._api_version or "2022-05-01")) - cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SettingsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _models.Setting: - """Settings of different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2022_05_01.models.SettingName - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - setting_name: Union[str, _models.SettingName], - setting: _models.Setting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2022_05_01.models.SettingName - :param setting: Setting object. Required. - :type setting: ~azure.mgmt.security.v2022_05_01.models.Setting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - setting_name: Union[str, _models.SettingName], - setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2022_05_01.models.SettingName - :param setting: Setting object. Required. - :type setting: 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: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, setting_name: Union[str, _models.SettingName], setting: Union[_models.Setting, IO[bytes]], **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2022_05_01.models.SettingName - :param setting: Setting object. Is either a Setting type or a IO[bytes] type. Required. - :type setting: ~azure.mgmt.security.v2022_05_01.models.Setting or IO[bytes] - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(setting, (IOBase, bytes)): - _content = setting - else: - _json = self._serialize.body(setting, "Setting") - - _request = build_update_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/__init__.py deleted file mode 100644 index ce862c57b5f2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/__init__.py +++ /dev/null @@ -1,35 +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 ._models_py3 import AlertSyncSettings -from ._models_py3 import CloudErrorBody -from ._models_py3 import DataExportSettings -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Resource -from ._models_py3 import Setting -from ._models_py3 import SettingsList - -from ._security_center_enums import SettingKind -from ._security_center_enums import SettingName -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertSyncSettings", - "CloudErrorBody", - "DataExportSettings", - "ErrorAdditionalInfo", - "Resource", - "Setting", - "SettingsList", - "SettingKind", - "SettingName", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/_models_py3.py deleted file mode 100644 index f25ef7df8547..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/_models_py3.py +++ /dev/null @@ -1,283 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Setting(Resource): - """The kind of the security setting. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AlertSyncSettings, DataExportSettings - - 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: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", - "AlertSuppressionSetting", and "AlertSyncSettings". - :vartype kind: str or ~azure.mgmt.security.v2022_05_01.models.SettingKind - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - } - - _subtype_map = {"kind": {"AlertSyncSettings": "AlertSyncSettings", "DataExportSettings": "DataExportSettings"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - - -class AlertSyncSettings(Setting): - """Represents an alert sync setting. - - 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: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", - "AlertSuppressionSetting", and "AlertSyncSettings". - :vartype kind: str or ~azure.mgmt.security.v2022_05_01.models.SettingKind - :ivar enabled: Is the alert sync setting enabled. - :vartype enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is the alert sync setting enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.kind: str = "AlertSyncSettings" - self.enabled = enabled - - -class CloudErrorBody(_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.security.v2022_05_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2022_05_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class DataExportSettings(Setting): - """Represents a data export setting. - - 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: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: the kind of the settings string. Required. Known values are: "DataExportSettings", - "AlertSuppressionSetting", and "AlertSyncSettings". - :vartype kind: str or ~azure.mgmt.security.v2022_05_01.models.SettingKind - :ivar enabled: Is the data export setting enabled. - :vartype enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is the data export setting enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.kind: str = "DataExportSettings" - self.enabled = enabled - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class SettingsList(_serialization.Model): - """Subscription settings list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The settings list. - :vartype value: list[~azure.mgmt.security.v2022_05_01.models.Setting] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Setting]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Setting"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The settings list. - :paramtype value: list[~azure.mgmt.security.v2022_05_01.models.Setting] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/_security_center_enums.py deleted file mode 100644 index 1874ecd66426..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/models/_security_center_enums.py +++ /dev/null @@ -1,28 +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 SettingKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the kind of the settings string.""" - - DATA_EXPORT_SETTINGS = "DataExportSettings" - ALERT_SUPPRESSION_SETTING = "AlertSuppressionSetting" - ALERT_SYNC_SETTINGS = "AlertSyncSettings" - - -class SettingName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SettingName.""" - - MCAS = "MCAS" - WDATP = "WDATP" - WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW = "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW" - WDATP_UNIFIED_SOLUTION = "WDATP_UNIFIED_SOLUTION" - SENTINEL = "Sentinel" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/__init__.py deleted file mode 100644 index 1046445c98b6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._settings_operations import SettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py deleted file mode 100644 index b36aebecad2d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py +++ /dev/null @@ -1,400 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2022-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request( - setting_name: Union[str, _models.SettingName], 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", "2022-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "settingName": _SERIALIZER.url("setting_name", setting_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_update_request( - setting_name: Union[str, _models.SettingName], 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", "2022-05-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}/providers/Microsoft.Security/settings/{settingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "settingName": _SERIALIZER.url("setting_name", setting_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) - - -class SettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_05_01.SecurityCenter`'s - :attr:`settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: - """Settings about different configurations in Microsoft Defender for Cloud. - - :return: An iterator like instance of either Setting or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_05_01.models.Setting] - :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._api_version or "2022-05-01")) - cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SettingsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _models.Setting: - """Settings of different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2022_05_01.models.SettingName - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - setting_name: Union[str, _models.SettingName], - setting: _models.Setting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2022_05_01.models.SettingName - :param setting: Setting object. Required. - :type setting: ~azure.mgmt.security.v2022_05_01.models.Setting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - setting_name: Union[str, _models.SettingName], - setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2022_05_01.models.SettingName - :param setting: Setting object. Required. - :type setting: 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: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, setting_name: Union[str, _models.SettingName], setting: Union[_models.Setting, IO[bytes]], **kwargs: Any - ) -> _models.Setting: - """updating settings about different configurations in Microsoft Defender for Cloud. - - :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", - "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW", "WDATP_UNIFIED_SOLUTION", and "Sentinel". Required. - :type setting_name: str or ~azure.mgmt.security.v2022_05_01.models.SettingName - :param setting: Setting object. Is either a Setting type or a IO[bytes] type. Required. - :type setting: ~azure.mgmt.security.v2022_05_01.models.Setting or IO[bytes] - :return: Setting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01.models.Setting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Setting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(setting, (IOBase, bytes)): - _content = setting - else: - _json = self._serialize.body(setting, "Setting") - - _request = build_update_request( - setting_name=setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Setting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_configuration.py deleted file mode 100644 index fb29ada2f1e5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-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", "2022-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_metadata.json deleted file mode 100644 index 338c4a897367..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2022-05-01-preview", - "total_api_version_list": ["2022-05-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "security_connectors": "SecurityConnectorsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_security_center.py deleted file mode 100644 index 040129d892f1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_security_center.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityConnectorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2022_05_01_preview.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_configuration.py deleted file mode 100644 index 84078824c2da..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-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", "2022-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_security_center.py deleted file mode 100644 index f475fc7e7c1e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_security_center.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityConnectorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2022_05_01_preview.aio.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/__init__.py deleted file mode 100644 index 8e4ac6c4f04e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py deleted file mode 100644 index 6fe1eca26c61..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py +++ /dev/null @@ -1,625 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_connectors_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_05_01_preview.aio.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector] - :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._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector] - :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._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/__init__.py deleted file mode 100644 index a72e752d54cd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/__init__.py +++ /dev/null @@ -1,167 +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 ._models_py3 import AWSEnvironmentData -from ._models_py3 import AwsOrganizationalData -from ._models_py3 import AwsOrganizationalDataMaster -from ._models_py3 import AwsOrganizationalDataMember -from ._models_py3 import AzureDevOpsScopeEnvironmentData -from ._models_py3 import AzureTrackedResourceLocation -from ._models_py3 import CloudErrorBody -from ._models_py3 import CloudOffering -from ._models_py3 import CspmMonitorAwsOffering -from ._models_py3 import CspmMonitorAwsOfferingNativeCloudConnection -from ._models_py3 import CspmMonitorAzureDevOpsOffering -from ._models_py3 import CspmMonitorGcpOffering -from ._models_py3 import CspmMonitorGcpOfferingNativeCloudConnection -from ._models_py3 import CspmMonitorGithubOffering -from ._models_py3 import DefenderFoDatabasesAwsOffering -from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioning -from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata -from ._models_py3 import DefenderForContainersAwsOffering -from ._models_py3 import DefenderForContainersAwsOfferingCloudWatchToKinesis -from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessment -from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask -from ._models_py3 import DefenderForContainersAwsOfferingKinesisToS3 -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesScubaReader -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesService -from ._models_py3 import DefenderForContainersGcpOffering -from ._models_py3 import DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection -from ._models_py3 import DefenderForContainersGcpOfferingNativeCloudConnection -from ._models_py3 import DefenderForDatabasesGcpOffering -from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioning -from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning -from ._models_py3 import DefenderForServersAwsOffering -from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata -from ._models_py3 import DefenderForServersAwsOfferingDefenderForServers -from ._models_py3 import DefenderForServersAwsOfferingMdeAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingSubPlan -from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersAwsOfferingVmScanners -from ._models_py3 import DefenderForServersAwsOfferingVmScannersConfiguration -from ._models_py3 import DefenderForServersGcpOffering -from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersGcpOfferingDefenderForServers -from ._models_py3 import DefenderForServersGcpOfferingMdeAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingSubPlan -from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioningConfiguration -from ._models_py3 import ETag -from ._models_py3 import EnvironmentData -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import GcpOrganizationalData -from ._models_py3 import GcpOrganizationalDataMember -from ._models_py3 import GcpOrganizationalDataOrganization -from ._models_py3 import GcpProjectDetails -from ._models_py3 import GcpProjectEnvironmentData -from ._models_py3 import GithubScopeEnvironmentData -from ._models_py3 import InformationProtectionAwsOffering -from ._models_py3 import InformationProtectionAwsOfferingInformationProtection -from ._models_py3 import Kind -from ._models_py3 import Resource -from ._models_py3 import SecurityConnector -from ._models_py3 import SecurityConnectorsList -from ._models_py3 import SystemData -from ._models_py3 import Tags -from ._models_py3 import TrackedResource - -from ._security_center_enums import CloudName -from ._security_center_enums import CreatedByType -from ._security_center_enums import EnvironmentType -from ._security_center_enums import OfferingType -from ._security_center_enums import OrganizationMembershipType -from ._security_center_enums import ScanningMode -from ._security_center_enums import SubPlan -from ._security_center_enums import Type -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AWSEnvironmentData", - "AwsOrganizationalData", - "AwsOrganizationalDataMaster", - "AwsOrganizationalDataMember", - "AzureDevOpsScopeEnvironmentData", - "AzureTrackedResourceLocation", - "CloudErrorBody", - "CloudOffering", - "CspmMonitorAwsOffering", - "CspmMonitorAwsOfferingNativeCloudConnection", - "CspmMonitorAzureDevOpsOffering", - "CspmMonitorGcpOffering", - "CspmMonitorGcpOfferingNativeCloudConnection", - "CspmMonitorGithubOffering", - "DefenderFoDatabasesAwsOffering", - "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", - "DefenderFoDatabasesAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata", - "DefenderForContainersAwsOffering", - "DefenderForContainersAwsOfferingCloudWatchToKinesis", - "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", - "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", - "DefenderForContainersAwsOfferingKinesisToS3", - "DefenderForContainersAwsOfferingKubernetesScubaReader", - "DefenderForContainersAwsOfferingKubernetesService", - "DefenderForContainersGcpOffering", - "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", - "DefenderForContainersGcpOfferingNativeCloudConnection", - "DefenderForDatabasesGcpOffering", - "DefenderForDatabasesGcpOfferingArcAutoProvisioning", - "DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration", - "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", - "DefenderForServersAwsOffering", - "DefenderForServersAwsOfferingArcAutoProvisioning", - "DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata", - "DefenderForServersAwsOfferingDefenderForServers", - "DefenderForServersAwsOfferingMdeAutoProvisioning", - "DefenderForServersAwsOfferingSubPlan", - "DefenderForServersAwsOfferingVaAutoProvisioning", - "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", - "DefenderForServersAwsOfferingVmScanners", - "DefenderForServersAwsOfferingVmScannersConfiguration", - "DefenderForServersGcpOffering", - "DefenderForServersGcpOfferingArcAutoProvisioning", - "DefenderForServersGcpOfferingArcAutoProvisioningConfiguration", - "DefenderForServersGcpOfferingDefenderForServers", - "DefenderForServersGcpOfferingMdeAutoProvisioning", - "DefenderForServersGcpOfferingSubPlan", - "DefenderForServersGcpOfferingVaAutoProvisioning", - "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", - "ETag", - "EnvironmentData", - "ErrorAdditionalInfo", - "GcpOrganizationalData", - "GcpOrganizationalDataMember", - "GcpOrganizationalDataOrganization", - "GcpProjectDetails", - "GcpProjectEnvironmentData", - "GithubScopeEnvironmentData", - "InformationProtectionAwsOffering", - "InformationProtectionAwsOfferingInformationProtection", - "Kind", - "Resource", - "SecurityConnector", - "SecurityConnectorsList", - "SystemData", - "Tags", - "TrackedResource", - "CloudName", - "CreatedByType", - "EnvironmentType", - "OfferingType", - "OrganizationMembershipType", - "ScanningMode", - "SubPlan", - "Type", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_models_py3.py deleted file mode 100644 index 18beecf7e331..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_models_py3.py +++ /dev/null @@ -1,2747 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class EnvironmentData(_serialization.Model): - """The security connector environment data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AWSEnvironmentData, AzureDevOpsScopeEnvironmentData, GcpProjectEnvironmentData, - GithubScopeEnvironmentData - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - _subtype_map = { - "environment_type": { - "AwsAccount": "AWSEnvironmentData", - "AzureDevOpsScope": "AzureDevOpsScopeEnvironmentData", - "GcpProject": "GcpProjectEnvironmentData", - "GithubScope": "GithubScopeEnvironmentData", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: Optional[str] = None - - -class AWSEnvironmentData(EnvironmentData): - """The aws connector environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.EnvironmentType - :ivar organizational_data: The AWS account's organizational data. - :vartype organizational_data: - ~azure.mgmt.security.v2022_05_01_preview.models.AwsOrganizationalData - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - "organizational_data": {"key": "organizationalData", "type": "AwsOrganizationalData"}, - } - - def __init__(self, *, organizational_data: Optional["_models.AwsOrganizationalData"] = None, **kwargs: Any) -> None: - """ - :keyword organizational_data: The AWS account's organizational data. - :paramtype organizational_data: - ~azure.mgmt.security.v2022_05_01_preview.models.AwsOrganizationalData - """ - super().__init__(**kwargs) - self.environment_type: str = "AwsAccount" - self.organizational_data = organizational_data - - -class AwsOrganizationalData(_serialization.Model): - """The awsOrganization data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AwsOrganizationalDataMember, AwsOrganizationalDataMaster - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.OrganizationMembershipType - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - } - - _subtype_map = { - "organization_membership_type": { - "Member": "AwsOrganizationalDataMember", - "Organization": "AwsOrganizationalDataMaster", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.organization_membership_type: Optional[str] = None - - -class AwsOrganizationalDataMaster(AwsOrganizationalData): - """The awsOrganization data for the master account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.OrganizationMembershipType - :ivar stackset_name: If the multi cloud account is of membership type organization, this will - be the name of the onboarding stackset. - :vartype stackset_name: str - :ivar excluded_account_ids: If the multi cloud account is of membership type organization, list - of accounts excluded from offering. - :vartype excluded_account_ids: list[str] - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "stackset_name": {"key": "stacksetName", "type": "str"}, - "excluded_account_ids": {"key": "excludedAccountIds", "type": "[str]"}, - } - - def __init__( - self, *, stackset_name: Optional[str] = None, excluded_account_ids: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword stackset_name: If the multi cloud account is of membership type organization, this - will be the name of the onboarding stackset. - :paramtype stackset_name: str - :keyword excluded_account_ids: If the multi cloud account is of membership type organization, - list of accounts excluded from offering. - :paramtype excluded_account_ids: list[str] - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Organization" - self.stackset_name = stackset_name - self.excluded_account_ids = excluded_account_ids - - -class AwsOrganizationalDataMember(AwsOrganizationalData): - """The awsOrganization data for the member account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.OrganizationMembershipType - :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, - this will be the ID of the account's parent. - :vartype parent_hierarchy_id: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, - } - - def __init__(self, *, parent_hierarchy_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword parent_hierarchy_id: If the multi cloud account is not of membership type - organization, this will be the ID of the account's parent. - :paramtype parent_hierarchy_id: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Member" - self.parent_hierarchy_id = parent_hierarchy_id - - -class AzureDevOpsScopeEnvironmentData(EnvironmentData): - """The AzureDevOps scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "AzureDevOpsScope" - - -class AzureTrackedResourceLocation(_serialization.Model): - """Describes an Azure resource with location. - - :ivar location: Location where the resource is stored. - :vartype location: str - """ - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - - -class CloudErrorBody(_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.security.v2022_05_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2022_05_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class CloudOffering(_serialization.Model): - """The security offering details. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - CspmMonitorAwsOffering, CspmMonitorAzureDevOpsOffering, CspmMonitorGcpOffering, - CspmMonitorGithubOffering, DefenderForContainersAwsOffering, DefenderForContainersGcpOffering, - DefenderFoDatabasesAwsOffering, DefenderForDatabasesGcpOffering, DefenderForServersAwsOffering, - DefenderForServersGcpOffering, InformationProtectionAwsOffering - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - _subtype_map = { - "offering_type": { - "CspmMonitorAws": "CspmMonitorAwsOffering", - "CspmMonitorAzureDevOps": "CspmMonitorAzureDevOpsOffering", - "CspmMonitorGcp": "CspmMonitorGcpOffering", - "CspmMonitorGithub": "CspmMonitorGithubOffering", - "DefenderForContainersAws": "DefenderForContainersAwsOffering", - "DefenderForContainersGcp": "DefenderForContainersGcpOffering", - "DefenderForDatabasesAws": "DefenderFoDatabasesAwsOffering", - "DefenderForDatabasesGcp": "DefenderForDatabasesGcpOffering", - "DefenderForServersAws": "DefenderForServersAwsOffering", - "DefenderForServersGcp": "DefenderForServersGcpOffering", - "InformationProtectionAws": "InformationProtectionAwsOffering", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: Optional[str] = None - self.description = None - - -class CspmMonitorAwsOffering(CloudOffering): - """The CSPM monitoring for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2022_05_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "CspmMonitorAwsOfferingNativeCloudConnection", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.CspmMonitorAwsOfferingNativeCloudConnection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2022_05_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorAws" - self.native_cloud_connection = native_cloud_connection - - -class CspmMonitorAwsOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class CspmMonitorAzureDevOpsOffering(CloudOffering): - """The CSPM monitoring for AzureDevOps offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorAzureDevOps" - - -class CspmMonitorGcpOffering(CloudOffering): - """The CSPM monitoring for GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2022_05_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "CspmMonitorGcpOfferingNativeCloudConnection", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.CspmMonitorGcpOfferingNativeCloudConnection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2022_05_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection - """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGcp" - self.native_cloud_connection = native_cloud_connection - - -class CspmMonitorGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar workload_identity_provider_id: The GCP workload identity provider id for the offering. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword workload_identity_provider_id: The GCP workload identity provider id for the offering. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class CspmMonitorGithubOffering(CloudOffering): - """The CSPM monitoring for github offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGithub" - - -class DefenderFoDatabasesAwsOffering(CloudOffering): - """The Defender for Databases AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", - }, - } - - def __init__( - self, - *, - arc_auto_provisioning: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning"] = None, - **kwargs: Any - ) -> None: - """ - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDatabasesAws" - self.arc_auto_provisioning = arc_auto_provisioning - - -class DefenderFoDatabasesAwsOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar service_principal_secret_metadata: Metadata of Service Principal secret for - autoprovisioning. - :vartype service_principal_secret_metadata: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata # pylint: disable=line-too-long - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "service_principal_secret_metadata": { - "key": "servicePrincipalSecretMetadata", - "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - cloud_role_arn: Optional[str] = None, - service_principal_secret_metadata: Optional[ - "_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword service_principal_secret_metadata: Metadata of Service Principal secret for - autoprovisioning. - :paramtype service_principal_secret_metadata: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - self.service_principal_secret_metadata = service_principal_secret_metadata - - -class DefenderFoDatabasesAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata( - _serialization.Model -): # pylint: disable=name-too-long - """Metadata of Service Principal secret for autoprovisioning. - - :ivar expiry_date: expiration date of service principal secret. - :vartype expiry_date: ~datetime.datetime - :ivar parameter_store_region: region of parameter store where secret is kept. - :vartype parameter_store_region: str - :ivar parameter_name_in_store: name of secret resource in parameter store. - :vartype parameter_name_in_store: str - """ - - _attribute_map = { - "expiry_date": {"key": "expiryDate", "type": "iso-8601"}, - "parameter_store_region": {"key": "parameterStoreRegion", "type": "str"}, - "parameter_name_in_store": {"key": "parameterNameInStore", "type": "str"}, - } - - def __init__( - self, - *, - expiry_date: Optional[datetime.datetime] = None, - parameter_store_region: Optional[str] = None, - parameter_name_in_store: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword expiry_date: expiration date of service principal secret. - :paramtype expiry_date: ~datetime.datetime - :keyword parameter_store_region: region of parameter store where secret is kept. - :paramtype parameter_store_region: str - :keyword parameter_name_in_store: name of secret resource in parameter store. - :paramtype parameter_name_in_store: str - """ - super().__init__(**kwargs) - self.expiry_date = expiry_date - self.parameter_store_region = parameter_store_region - self.parameter_name_in_store = parameter_name_in_store - - -class DefenderForContainersAwsOffering(CloudOffering): # pylint: disable=too-many-instance-attributes - """The Defender for Containers AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar kubernetes_service: The kubernetes service connection configuration. - :vartype kubernetes_service: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :ivar kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :vartype kubernetes_scuba_reader: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :ivar cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :vartype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :ivar kinesis_to_s3: The kinesis to s3 connection configuration. - :vartype kinesis_to_s3: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - :ivar container_vulnerability_assessment: The container vulnerability assessment configuration. - :vartype container_vulnerability_assessment: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment - :ivar container_vulnerability_assessment_task: The container vulnerability assessment task - configuration. - :vartype container_vulnerability_assessment_task: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask # pylint: disable=line-too-long - :ivar enable_container_vulnerability_assessment: Enable container vulnerability assessment - feature. - :vartype enable_container_vulnerability_assessment: bool - :ivar auto_provisioning: Is audit logs pipeline auto provisioning enabled. - :vartype auto_provisioning: bool - :ivar kube_audit_retention_time: The retention time in days of kube audit logs set on the - CloudWatch log group. - :vartype kube_audit_retention_time: int - :ivar scuba_external_id: The externalId used by the data reader to prevent the confused deputy - attack. - :vartype scuba_external_id: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "kubernetes_service": {"key": "kubernetesService", "type": "DefenderForContainersAwsOfferingKubernetesService"}, - "kubernetes_scuba_reader": { - "key": "kubernetesScubaReader", - "type": "DefenderForContainersAwsOfferingKubernetesScubaReader", - }, - "cloud_watch_to_kinesis": { - "key": "cloudWatchToKinesis", - "type": "DefenderForContainersAwsOfferingCloudWatchToKinesis", - }, - "kinesis_to_s3": {"key": "kinesisToS3", "type": "DefenderForContainersAwsOfferingKinesisToS3"}, - "container_vulnerability_assessment": { - "key": "containerVulnerabilityAssessment", - "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", - }, - "container_vulnerability_assessment_task": { - "key": "containerVulnerabilityAssessmentTask", - "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", - }, - "enable_container_vulnerability_assessment": {"key": "enableContainerVulnerabilityAssessment", "type": "bool"}, - "auto_provisioning": {"key": "autoProvisioning", "type": "bool"}, - "kube_audit_retention_time": {"key": "kubeAuditRetentionTime", "type": "int"}, - "scuba_external_id": {"key": "scubaExternalId", "type": "str"}, - } - - def __init__( - self, - *, - kubernetes_service: Optional["_models.DefenderForContainersAwsOfferingKubernetesService"] = None, - kubernetes_scuba_reader: Optional["_models.DefenderForContainersAwsOfferingKubernetesScubaReader"] = None, - cloud_watch_to_kinesis: Optional["_models.DefenderForContainersAwsOfferingCloudWatchToKinesis"] = None, - kinesis_to_s3: Optional["_models.DefenderForContainersAwsOfferingKinesisToS3"] = None, - container_vulnerability_assessment: Optional[ - "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment" - ] = None, - container_vulnerability_assessment_task: Optional[ - "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask" - ] = None, - enable_container_vulnerability_assessment: Optional[bool] = None, - auto_provisioning: Optional[bool] = None, - kube_audit_retention_time: Optional[int] = None, - scuba_external_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword kubernetes_service: The kubernetes service connection configuration. - :paramtype kubernetes_service: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :keyword kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :paramtype kubernetes_scuba_reader: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :keyword cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :paramtype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :keyword kinesis_to_s3: The kinesis to s3 connection configuration. - :paramtype kinesis_to_s3: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - :keyword container_vulnerability_assessment: The container vulnerability assessment - configuration. - :paramtype container_vulnerability_assessment: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment # pylint: disable=line-too-long - :keyword container_vulnerability_assessment_task: The container vulnerability assessment task - configuration. - :paramtype container_vulnerability_assessment_task: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask # pylint: disable=line-too-long - :keyword enable_container_vulnerability_assessment: Enable container vulnerability assessment - feature. - :paramtype enable_container_vulnerability_assessment: bool - :keyword auto_provisioning: Is audit logs pipeline auto provisioning enabled. - :paramtype auto_provisioning: bool - :keyword kube_audit_retention_time: The retention time in days of kube audit logs set on the - CloudWatch log group. - :paramtype kube_audit_retention_time: int - :keyword scuba_external_id: The externalId used by the data reader to prevent the confused - deputy attack. - :paramtype scuba_external_id: str - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForContainersAws" - self.kubernetes_service = kubernetes_service - self.kubernetes_scuba_reader = kubernetes_scuba_reader - self.cloud_watch_to_kinesis = cloud_watch_to_kinesis - self.kinesis_to_s3 = kinesis_to_s3 - self.container_vulnerability_assessment = container_vulnerability_assessment - self.container_vulnerability_assessment_task = container_vulnerability_assessment_task - self.enable_container_vulnerability_assessment = enable_container_vulnerability_assessment - self.auto_provisioning = auto_provisioning - self.kube_audit_retention_time = kube_audit_retention_time - self.scuba_external_id = scuba_external_id - - -class DefenderForContainersAwsOfferingCloudWatchToKinesis(_serialization.Model): # pylint: disable=name-too-long - """The cloudwatch to kinesis connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into - Kinesis. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into - Kinesis. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingContainerVulnerabilityAssessment( - _serialization.Model -): # pylint: disable=name-too-long - """The container vulnerability assessment configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask( - _serialization.Model -): # pylint: disable=name-too-long - """The container vulnerability assessment task configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKinesisToS3(_serialization.Model): # pylint: disable=name-too-long - """The kinesis to s3 connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesScubaReader(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes to scuba connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesService(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes service connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning - resources. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning - resources. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersGcpOffering(CloudOffering): - """The containers GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection - :ivar data_pipeline_native_cloud_connection: The native cloud connection configuration. - :vartype data_pipeline_native_cloud_connection: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection - :ivar audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. - :vartype audit_logs_auto_provisioning_flag: bool - :ivar defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes agent - auto provisioning enabled. - :vartype defender_agent_auto_provisioning_flag: bool - :ivar policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning - enabled. - :vartype policy_agent_auto_provisioning_flag: bool - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "DefenderForContainersGcpOfferingNativeCloudConnection", - }, - "data_pipeline_native_cloud_connection": { - "key": "dataPipelineNativeCloudConnection", - "type": "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", - }, - "audit_logs_auto_provisioning_flag": {"key": "auditLogsAutoProvisioningFlag", "type": "bool"}, - "defender_agent_auto_provisioning_flag": {"key": "defenderAgentAutoProvisioningFlag", "type": "bool"}, - "policy_agent_auto_provisioning_flag": {"key": "policyAgentAutoProvisioningFlag", "type": "bool"}, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.DefenderForContainersGcpOfferingNativeCloudConnection"] = None, - data_pipeline_native_cloud_connection: Optional[ - "_models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection" - ] = None, - audit_logs_auto_provisioning_flag: Optional[bool] = None, - defender_agent_auto_provisioning_flag: Optional[bool] = None, - policy_agent_auto_provisioning_flag: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection - :keyword data_pipeline_native_cloud_connection: The native cloud connection configuration. - :paramtype data_pipeline_native_cloud_connection: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection # pylint: disable=line-too-long - :keyword audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. - :paramtype audit_logs_auto_provisioning_flag: bool - :keyword defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes - agent auto provisioning enabled. - :paramtype defender_agent_auto_provisioning_flag: bool - :keyword policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning - enabled. - :paramtype policy_agent_auto_provisioning_flag: bool - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForContainersGcp" - self.native_cloud_connection = native_cloud_connection - self.data_pipeline_native_cloud_connection = data_pipeline_native_cloud_connection - self.audit_logs_auto_provisioning_flag = audit_logs_auto_provisioning_flag - self.defender_agent_auto_provisioning_flag = defender_agent_auto_provisioning_flag - self.policy_agent_auto_provisioning_flag = policy_agent_auto_provisioning_flag - - -class DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection( - _serialization.Model -): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The data collection service account email address in GCP - for this offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The data collection GCP workload identity provider id for - this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The data collection service account email address in - GCP for this offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The data collection GCP workload identity provider id - for this offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForContainersGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id for this - offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForDatabasesGcpOffering(CloudOffering): - """The Defender for Databases GCP offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning - :ivar defender_for_databases_arc_auto_provisioning: The native cloud connection configuration. - :vartype defender_for_databases_arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning # pylint: disable=line-too-long - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioning", - }, - "defender_for_databases_arc_auto_provisioning": { - "key": "defenderForDatabasesArcAutoProvisioning", - "type": "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", - }, - } - - def __init__( - self, - *, - arc_auto_provisioning: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioning"] = None, - defender_for_databases_arc_auto_provisioning: Optional[ - "_models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning - :keyword defender_for_databases_arc_auto_provisioning: The native cloud connection - configuration. - :paramtype defender_for_databases_arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDatabasesGcp" - self.arc_auto_provisioning = arc_auto_provisioning - self.defender_for_databases_arc_auto_provisioning = defender_for_databases_arc_auto_provisioning - - -class DefenderForDatabasesGcpOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: Configuration for ARC autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: Configuration for ARC autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for ARC autoprovisioning. - - :ivar client_id: The Azure service principal client id for agent onboarding. - :vartype client_id: str - :ivar agent_onboarding_service_account_numeric_id: The agent onboarding service account numeric - id. - :vartype agent_onboarding_service_account_numeric_id: str - """ - - _attribute_map = { - "client_id": {"key": "clientId", "type": "str"}, - "agent_onboarding_service_account_numeric_id": {"key": "agentOnboardingServiceAccountNumericId", "type": "str"}, - } - - def __init__( - self, - *, - client_id: Optional[str] = None, - agent_onboarding_service_account_numeric_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword client_id: The Azure service principal client id for agent onboarding. - :paramtype client_id: str - :keyword agent_onboarding_service_account_numeric_id: The agent onboarding service account - numeric id. - :paramtype agent_onboarding_service_account_numeric_id: str - """ - super().__init__(**kwargs) - self.client_id = client_id - self.agent_onboarding_service_account_numeric_id = agent_onboarding_service_account_numeric_id - - -class DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning( - _serialization.Model -): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id for this - offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForServersAwsOffering(CloudOffering): - """The Defender for Servers AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar defender_for_servers: The Defender for servers connection configuration. - :vartype defender_for_servers: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :vartype va_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning - :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :vartype mde_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning - :ivar sub_plan: configuration for the servers offering subPlan. - :vartype sub_plan: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingSubPlan - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingVmScanners - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "defender_for_servers": { - "key": "defenderForServers", - "type": "DefenderForServersAwsOfferingDefenderForServers", - }, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForServersAwsOfferingArcAutoProvisioning", - }, - "va_auto_provisioning": { - "key": "vaAutoProvisioning", - "type": "DefenderForServersAwsOfferingVaAutoProvisioning", - }, - "mde_auto_provisioning": { - "key": "mdeAutoProvisioning", - "type": "DefenderForServersAwsOfferingMdeAutoProvisioning", - }, - "sub_plan": {"key": "subPlan", "type": "DefenderForServersAwsOfferingSubPlan"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersAwsOfferingVmScanners"}, - } - - def __init__( - self, - *, - defender_for_servers: Optional["_models.DefenderForServersAwsOfferingDefenderForServers"] = None, - arc_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioning"] = None, - va_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioning"] = None, - mde_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingMdeAutoProvisioning"] = None, - sub_plan: Optional["_models.DefenderForServersAwsOfferingSubPlan"] = None, - vm_scanners: Optional["_models.DefenderForServersAwsOfferingVmScanners"] = None, - **kwargs: Any - ) -> None: - """ - :keyword defender_for_servers: The Defender for servers connection configuration. - :paramtype defender_for_servers: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :paramtype va_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning - :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :paramtype mde_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning - :keyword sub_plan: configuration for the servers offering subPlan. - :paramtype sub_plan: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingSubPlan - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingVmScanners - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForServersAws" - self.defender_for_servers = defender_for_servers - self.arc_auto_provisioning = arc_auto_provisioning - self.va_auto_provisioning = va_auto_provisioning - self.mde_auto_provisioning = mde_auto_provisioning - self.sub_plan = sub_plan - self.vm_scanners = vm_scanners - - -class DefenderForServersAwsOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar service_principal_secret_metadata: Metadata of Service Principal secret for - autoprovisioning. - :vartype service_principal_secret_metadata: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata # pylint: disable=line-too-long - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "service_principal_secret_metadata": { - "key": "servicePrincipalSecretMetadata", - "type": "DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - cloud_role_arn: Optional[str] = None, - service_principal_secret_metadata: Optional[ - "_models.DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword service_principal_secret_metadata: Metadata of Service Principal secret for - autoprovisioning. - :paramtype service_principal_secret_metadata: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - self.service_principal_secret_metadata = service_principal_secret_metadata - - -class DefenderForServersAwsOfferingArcAutoProvisioningServicePrincipalSecretMetadata( - _serialization.Model -): # pylint: disable=name-too-long - """Metadata of Service Principal secret for autoprovisioning. - - :ivar expiry_date: expiration date of service principal secret. - :vartype expiry_date: str - :ivar parameter_store_region: region of parameter store where secret is kept. - :vartype parameter_store_region: str - :ivar parameter_name_in_store: name of secret resource in parameter store. - :vartype parameter_name_in_store: str - """ - - _attribute_map = { - "expiry_date": {"key": "expiryDate", "type": "str"}, - "parameter_store_region": {"key": "parameterStoreRegion", "type": "str"}, - "parameter_name_in_store": {"key": "parameterNameInStore", "type": "str"}, - } - - def __init__( - self, - *, - expiry_date: Optional[str] = None, - parameter_store_region: Optional[str] = None, - parameter_name_in_store: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword expiry_date: expiration date of service principal secret. - :paramtype expiry_date: str - :keyword parameter_store_region: region of parameter store where secret is kept. - :paramtype parameter_store_region: str - :keyword parameter_name_in_store: name of secret resource in parameter store. - :paramtype parameter_name_in_store: str - """ - super().__init__(**kwargs) - self.expiry_date = expiry_date - self.parameter_store_region = parameter_store_region - self.parameter_name_in_store = parameter_name_in_store - - -class DefenderForServersAwsOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long - """The Defender for servers connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForServersAwsOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender for Endpoint autoprovisioning configuration. - - :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :vartype configuration: JSON - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "object"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :paramtype configuration: JSON - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingSubPlan(_serialization.Model): - """configuration for the servers offering subPlan. - - :ivar type: The available sub plans. Known values are: "P1" and "P2". - :vartype type: str or ~azure.mgmt.security.v2022_05_01_preview.models.SubPlan - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The available sub plans. Known values are: "P1" and "P2". - :paramtype type: str or ~azure.mgmt.security.v2022_05_01_preview.models.SubPlan - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersAwsOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Vulnerability Assessment autoprovisioning configuration. - - :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingVaAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """configuration for Vulnerability Assessment autoprovisioning. - - :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :vartype type: str or ~azure.mgmt.security.v2022_05_01_preview.models.Type - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :paramtype type: str or ~azure.mgmt.security.v2022_05_01_preview.models.Type - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersAwsOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderForServersAwsOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar scanning_mode: The scanning mode for the vm scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2022_05_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. - :vartype exclusion_tags: JSON - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "object"}, - } - - def __init__( - self, - *, - cloud_role_arn: Optional[str] = None, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword scanning_mode: The scanning mode for the vm scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2022_05_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. - :paramtype exclusion_tags: JSON - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class DefenderForServersGcpOffering(CloudOffering): - """The Defender for Servers GCP offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar defender_for_servers: The Defender for servers connection configuration. - :vartype defender_for_servers: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingDefenderForServers - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning - :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :vartype va_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning - :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :vartype mde_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning - :ivar sub_plan: configuration for the servers offering subPlan. - :vartype sub_plan: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingSubPlan - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "defender_for_servers": { - "key": "defenderForServers", - "type": "DefenderForServersGcpOfferingDefenderForServers", - }, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForServersGcpOfferingArcAutoProvisioning", - }, - "va_auto_provisioning": { - "key": "vaAutoProvisioning", - "type": "DefenderForServersGcpOfferingVaAutoProvisioning", - }, - "mde_auto_provisioning": { - "key": "mdeAutoProvisioning", - "type": "DefenderForServersGcpOfferingMdeAutoProvisioning", - }, - "sub_plan": {"key": "subPlan", "type": "DefenderForServersGcpOfferingSubPlan"}, - } - - def __init__( - self, - *, - defender_for_servers: Optional["_models.DefenderForServersGcpOfferingDefenderForServers"] = None, - arc_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioning"] = None, - va_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioning"] = None, - mde_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingMdeAutoProvisioning"] = None, - sub_plan: Optional["_models.DefenderForServersGcpOfferingSubPlan"] = None, - **kwargs: Any - ) -> None: - """ - :keyword defender_for_servers: The Defender for servers connection configuration. - :paramtype defender_for_servers: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingDefenderForServers - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning - :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :paramtype va_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning - :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :paramtype mde_auto_provisioning: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning - :keyword sub_plan: configuration for the servers offering subPlan. - :paramtype sub_plan: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingSubPlan - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForServersGcp" - self.defender_for_servers = defender_for_servers - self.arc_auto_provisioning = arc_auto_provisioning - self.va_auto_provisioning = va_auto_provisioning - self.mde_auto_provisioning = mde_auto_provisioning - self.sub_plan = sub_plan - - -class DefenderForServersGcpOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: Configuration for ARC autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersGcpOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: Configuration for ARC autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for ARC autoprovisioning. - - :ivar client_id: The Azure service principal client id for agent onboarding. - :vartype client_id: str - :ivar agent_onboarding_service_account_numeric_id: The agent onboarding service account numeric - id. - :vartype agent_onboarding_service_account_numeric_id: str - """ - - _attribute_map = { - "client_id": {"key": "clientId", "type": "str"}, - "agent_onboarding_service_account_numeric_id": {"key": "agentOnboardingServiceAccountNumericId", "type": "str"}, - } - - def __init__( - self, - *, - client_id: Optional[str] = None, - agent_onboarding_service_account_numeric_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword client_id: The Azure service principal client id for agent onboarding. - :paramtype client_id: str - :keyword agent_onboarding_service_account_numeric_id: The agent onboarding service account - numeric id. - :paramtype agent_onboarding_service_account_numeric_id: str - """ - super().__init__(**kwargs) - self.client_id = client_id - self.agent_onboarding_service_account_numeric_id = agent_onboarding_service_account_numeric_id - - -class DefenderForServersGcpOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long - """The Defender for servers connection configuration. - - :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this feature. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword workload_identity_provider_id: The workload identity provider id in GCP for this - feature. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - feature. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class DefenderForServersGcpOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender for Endpoint autoprovisioning configuration. - - :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :vartype configuration: JSON - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "object"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :paramtype configuration: JSON - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingSubPlan(_serialization.Model): - """configuration for the servers offering subPlan. - - :ivar type: The available sub plans. Known values are: "P1" and "P2". - :vartype type: str or ~azure.mgmt.security.v2022_05_01_preview.models.SubPlan - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The available sub plans. Known values are: "P1" and "P2". - :paramtype type: str or ~azure.mgmt.security.v2022_05_01_preview.models.SubPlan - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersGcpOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Vulnerability Assessment autoprovisioning configuration. - - :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2022_05_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingVaAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """configuration for Vulnerability Assessment autoprovisioning. - - :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :vartype type: str or ~azure.mgmt.security.v2022_05_01_preview.models.Type - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :paramtype type: str or ~azure.mgmt.security.v2022_05_01_preview.models.Type - """ - super().__init__(**kwargs) - self.type = type - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ETag(_serialization.Model): - """Entity tag is used for comparing two or more entities from the same requested resource. - - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - """ - - _attribute_map = { - "etag": {"key": "etag", "type": "str"}, - } - - def __init__(self, *, etag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - """ - super().__init__(**kwargs) - self.etag = etag - - -class GcpOrganizationalData(_serialization.Model): - """The gcpOrganization data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - GcpOrganizationalDataMember, GcpOrganizationalDataOrganization - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.OrganizationMembershipType - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - } - - _subtype_map = { - "organization_membership_type": { - "Member": "GcpOrganizationalDataMember", - "Organization": "GcpOrganizationalDataOrganization", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.organization_membership_type: Optional[str] = None - - -class GcpOrganizationalDataMember(GcpOrganizationalData): - """The gcpOrganization data for the member account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.OrganizationMembershipType - :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, - this will be the ID of the project's parent. - :vartype parent_hierarchy_id: str - :ivar management_project_number: The GCP management project number from organizational - onboarding. - :vartype management_project_number: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, - "management_project_number": {"key": "managementProjectNumber", "type": "str"}, - } - - def __init__( - self, - *, - parent_hierarchy_id: Optional[str] = None, - management_project_number: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword parent_hierarchy_id: If the multi cloud account is not of membership type - organization, this will be the ID of the project's parent. - :paramtype parent_hierarchy_id: str - :keyword management_project_number: The GCP management project number from organizational - onboarding. - :paramtype management_project_number: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Member" - self.parent_hierarchy_id = parent_hierarchy_id - self.management_project_number = management_project_number - - -class GcpOrganizationalDataOrganization(GcpOrganizationalData): - """The gcpOrganization data for the parent account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.OrganizationMembershipType - :ivar excluded_project_numbers: If the multi cloud account is of membership type organization, - list of accounts excluded from offering. - :vartype excluded_project_numbers: list[str] - :ivar service_account_email_address: The service account email address which represents the - organization level permissions container. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id which represents the - permissions required to auto provision security connectors. - :vartype workload_identity_provider_id: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "excluded_project_numbers": {"key": "excludedProjectNumbers", "type": "[str]"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - excluded_project_numbers: Optional[List[str]] = None, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword excluded_project_numbers: If the multi cloud account is of membership type - organization, list of accounts excluded from offering. - :paramtype excluded_project_numbers: list[str] - :keyword service_account_email_address: The service account email address which represents the - organization level permissions container. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id which represents - the permissions required to auto provision security connectors. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Organization" - self.excluded_project_numbers = excluded_project_numbers - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class GcpProjectDetails(_serialization.Model): - """The details about the project represented by the security connector. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar project_number: The unique GCP Project number. - :vartype project_number: str - :ivar project_id: The GCP Project id. - :vartype project_id: str - :ivar workload_identity_pool_id: The GCP workload identity federation pool id. - :vartype workload_identity_pool_id: str - """ - - _validation = { - "workload_identity_pool_id": {"readonly": True}, - } - - _attribute_map = { - "project_number": {"key": "projectNumber", "type": "str"}, - "project_id": {"key": "projectId", "type": "str"}, - "workload_identity_pool_id": {"key": "workloadIdentityPoolId", "type": "str"}, - } - - def __init__( - self, *, project_number: Optional[str] = None, project_id: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword project_number: The unique GCP Project number. - :paramtype project_number: str - :keyword project_id: The GCP Project id. - :paramtype project_id: str - """ - super().__init__(**kwargs) - self.project_number = project_number - self.project_id = project_id - self.workload_identity_pool_id = None - - -class GcpProjectEnvironmentData(EnvironmentData): - """The GCP project connector environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.EnvironmentType - :ivar organizational_data: The Gcp project's organizational data. - :vartype organizational_data: - ~azure.mgmt.security.v2022_05_01_preview.models.GcpOrganizationalData - :ivar project_details: The Gcp project's details. - :vartype project_details: ~azure.mgmt.security.v2022_05_01_preview.models.GcpProjectDetails - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - "organizational_data": {"key": "organizationalData", "type": "GcpOrganizationalData"}, - "project_details": {"key": "projectDetails", "type": "GcpProjectDetails"}, - } - - def __init__( - self, - *, - organizational_data: Optional["_models.GcpOrganizationalData"] = None, - project_details: Optional["_models.GcpProjectDetails"] = None, - **kwargs: Any - ) -> None: - """ - :keyword organizational_data: The Gcp project's organizational data. - :paramtype organizational_data: - ~azure.mgmt.security.v2022_05_01_preview.models.GcpOrganizationalData - :keyword project_details: The Gcp project's details. - :paramtype project_details: ~azure.mgmt.security.v2022_05_01_preview.models.GcpProjectDetails - """ - super().__init__(**kwargs) - self.environment_type: str = "GcpProject" - self.organizational_data = organizational_data - self.project_details = project_details - - -class GithubScopeEnvironmentData(EnvironmentData): - """The github scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_05_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "GithubScope" - - -class InformationProtectionAwsOffering(CloudOffering): - """The information protection for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", and - "DefenderForDatabasesGcp". - :vartype offering_type: str or ~azure.mgmt.security.v2022_05_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar information_protection: The native cloud connection configuration. - :vartype information_protection: - ~azure.mgmt.security.v2022_05_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "information_protection": { - "key": "informationProtection", - "type": "InformationProtectionAwsOfferingInformationProtection", - }, - } - - def __init__( - self, - *, - information_protection: Optional["_models.InformationProtectionAwsOfferingInformationProtection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword information_protection: The native cloud connection configuration. - :paramtype information_protection: - ~azure.mgmt.security.v2022_05_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - super().__init__(**kwargs) - self.offering_type: str = "InformationProtectionAws" - self.information_protection = information_protection - - -class InformationProtectionAwsOfferingInformationProtection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class Kind(_serialization.Model): - """Describes an Azure resource with kind. - - :ivar kind: Kind of the resource. - :vartype kind: str - """ - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__(self, *, kind: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword kind: Kind of the resource. - :paramtype kind: str - """ - super().__init__(**kwargs) - self.kind = kind - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Tags(_serialization.Model): - """A list of key value pairs that describe the resource. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class TrackedResource(Resource, AzureTrackedResourceLocation, Kind, ETag, Tags): - """Describes an Azure tracked resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) - self.tags = tags - self.etag = etag - self.kind = kind - self.location = location - self.id = None - self.name = None - self.type = None - - -class SecurityConnector(TrackedResource): # pylint: disable=too-many-instance-attributes - """The security connector resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2022_05_01_preview.models.SystemData - :ivar hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector, project number in case of GCP connector). - :vartype hierarchy_identifier: str - :ivar hierarchy_identifier_trial_end_date: The date on which the trial period will end, if - applicable. Trial period exists for 30 days after upgrading to payed offerings. - :vartype hierarchy_identifier_trial_end_date: ~datetime.datetime - :ivar environment_name: The multi cloud resource's cloud name. Known values are: "Azure", - "AWS", "GCP", "Github", and "AzureDevOps". - :vartype environment_name: str or ~azure.mgmt.security.v2022_05_01_preview.models.CloudName - :ivar offerings: A collection of offerings for the security connector. - :vartype offerings: list[~azure.mgmt.security.v2022_05_01_preview.models.CloudOffering] - :ivar environment_data: The security connector environment data. - :vartype environment_data: ~azure.mgmt.security.v2022_05_01_preview.models.EnvironmentData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "hierarchy_identifier_trial_end_date": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "hierarchy_identifier": {"key": "properties.hierarchyIdentifier", "type": "str"}, - "hierarchy_identifier_trial_end_date": { - "key": "properties.hierarchyIdentifierTrialEndDate", - "type": "iso-8601", - }, - "environment_name": {"key": "properties.environmentName", "type": "str"}, - "offerings": {"key": "properties.offerings", "type": "[CloudOffering]"}, - "environment_data": {"key": "properties.environmentData", "type": "EnvironmentData"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - hierarchy_identifier: Optional[str] = None, - environment_name: Optional[Union[str, "_models.CloudName"]] = None, - offerings: Optional[List["_models.CloudOffering"]] = None, - environment_data: Optional["_models.EnvironmentData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - :keyword hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector, project number in case of GCP connector). - :paramtype hierarchy_identifier: str - :keyword environment_name: The multi cloud resource's cloud name. Known values are: "Azure", - "AWS", "GCP", "Github", and "AzureDevOps". - :paramtype environment_name: str or ~azure.mgmt.security.v2022_05_01_preview.models.CloudName - :keyword offerings: A collection of offerings for the security connector. - :paramtype offerings: list[~azure.mgmt.security.v2022_05_01_preview.models.CloudOffering] - :keyword environment_data: The security connector environment data. - :paramtype environment_data: ~azure.mgmt.security.v2022_05_01_preview.models.EnvironmentData - """ - super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) - self.system_data = None - self.hierarchy_identifier = hierarchy_identifier - self.hierarchy_identifier_trial_end_date = None - self.environment_name = environment_name - self.offerings = offerings - self.environment_data = environment_data - - -class SecurityConnectorsList(_serialization.Model): - """List of security connectors response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of security connectors under the given scope. Required. - :vartype value: list[~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityConnector]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.SecurityConnector"], **kwargs: Any) -> None: - """ - :keyword value: The list of security connectors under the given scope. Required. - :paramtype value: list[~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = 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.security.v2022_05_01_preview.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.security.v2022_05_01_preview.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.security.v2022_05_01_preview.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.security.v2022_05_01_preview.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 diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_security_center_enums.py deleted file mode 100644 index 5e4d93f819c6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,81 +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 CloudName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud resource's cloud name.""" - - AZURE = "Azure" - AWS = "AWS" - GCP = "GCP" - GITHUB = "Github" - AZURE_DEV_OPS = "AzureDevOps" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class EnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the environment data.""" - - AWS_ACCOUNT = "AwsAccount" - GCP_PROJECT = "GcpProject" - GITHUB_SCOPE = "GithubScope" - AZURE_DEV_OPS_SCOPE = "AzureDevOpsScope" - - -class OfferingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the security offering.""" - - CSPM_MONITOR_AWS = "CspmMonitorAws" - DEFENDER_FOR_CONTAINERS_AWS = "DefenderForContainersAws" - DEFENDER_FOR_SERVERS_AWS = "DefenderForServersAws" - DEFENDER_FOR_DATABASES_AWS = "DefenderForDatabasesAws" - INFORMATION_PROTECTION_AWS = "InformationProtectionAws" - CSPM_MONITOR_GCP = "CspmMonitorGcp" - CSPM_MONITOR_GITHUB = "CspmMonitorGithub" - CSPM_MONITOR_AZURE_DEV_OPS = "CspmMonitorAzureDevOps" - DEFENDER_FOR_SERVERS_GCP = "DefenderForServersGcp" - DEFENDER_FOR_CONTAINERS_GCP = "DefenderForContainersGcp" - DEFENDER_FOR_DATABASES_GCP = "DefenderForDatabasesGcp" - - -class OrganizationMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud account's membership type in the organization.""" - - MEMBER = "Member" - ORGANIZATION = "Organization" - - -class ScanningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scanning mode for the vm scan.""" - - DEFAULT = "Default" - - -class SubPlan(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The available sub plans.""" - - P1 = "P1" - P2 = "P2" - - -class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or 'Qualys'.""" - - QUALYS = "Qualys" - TVM = "TVM" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/__init__.py deleted file mode 100644 index 8e4ac6c4f04e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py deleted file mode 100644 index bd0b234c0fd7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py +++ /dev/null @@ -1,820 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_request( - resource_group_name: str, security_connector_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", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, security_connector_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", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, security_connector_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", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, security_connector_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", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_05_01_preview.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector] - :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._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector] - :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._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_05_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_configuration.py deleted file mode 100644 index 28e646a5e0aa..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-07-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", "2022-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_metadata.json deleted file mode 100644 index 9029fc5833ab..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2022-07-01-preview", - "total_api_version_list": ["2022-07-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "applications": "ApplicationsOperations", - "application": "ApplicationOperations", - "security_connector_applications": "SecurityConnectorApplicationsOperations", - "security_connector_application": "SecurityConnectorApplicationOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_security_center.py deleted file mode 100644 index 435452d29273..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_security_center.py +++ /dev/null @@ -1,132 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - ApplicationOperations, - ApplicationsOperations, - SecurityConnectorApplicationOperations, - SecurityConnectorApplicationsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar applications: ApplicationsOperations operations - :vartype applications: - azure.mgmt.security.v2022_07_01_preview.operations.ApplicationsOperations - :ivar application: ApplicationOperations operations - :vartype application: azure.mgmt.security.v2022_07_01_preview.operations.ApplicationOperations - :ivar security_connector_applications: SecurityConnectorApplicationsOperations operations - :vartype security_connector_applications: - azure.mgmt.security.v2022_07_01_preview.operations.SecurityConnectorApplicationsOperations - :ivar security_connector_application: SecurityConnectorApplicationOperations operations - :vartype security_connector_application: - azure.mgmt.security.v2022_07_01_preview.operations.SecurityConnectorApplicationOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-07-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.applications = ApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" - ) - self.application = ApplicationOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" - ) - self.security_connector_applications = SecurityConnectorApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" - ) - self.security_connector_application = SecurityConnectorApplicationOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_configuration.py deleted file mode 100644 index c00ed599f5e4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-07-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", "2022-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_security_center.py deleted file mode 100644 index 8be4ada0d4ec..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_security_center.py +++ /dev/null @@ -1,135 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - ApplicationOperations, - ApplicationsOperations, - SecurityConnectorApplicationOperations, - SecurityConnectorApplicationsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar applications: ApplicationsOperations operations - :vartype applications: - azure.mgmt.security.v2022_07_01_preview.aio.operations.ApplicationsOperations - :ivar application: ApplicationOperations operations - :vartype application: - azure.mgmt.security.v2022_07_01_preview.aio.operations.ApplicationOperations - :ivar security_connector_applications: SecurityConnectorApplicationsOperations operations - :vartype security_connector_applications: - azure.mgmt.security.v2022_07_01_preview.aio.operations.SecurityConnectorApplicationsOperations - :ivar security_connector_application: SecurityConnectorApplicationOperations operations - :vartype security_connector_application: - azure.mgmt.security.v2022_07_01_preview.aio.operations.SecurityConnectorApplicationOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-07-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.applications = ApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" - ) - self.application = ApplicationOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" - ) - self.security_connector_applications = SecurityConnectorApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" - ) - self.security_connector_application = SecurityConnectorApplicationOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/__init__.py deleted file mode 100644 index c85f8d56b434..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,25 +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 ._applications_operations import ApplicationsOperations -from ._application_operations import ApplicationOperations -from ._security_connector_applications_operations import SecurityConnectorApplicationsOperations -from ._security_connector_application_operations import SecurityConnectorApplicationOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApplicationsOperations", - "ApplicationOperations", - "SecurityConnectorApplicationsOperations", - "SecurityConnectorApplicationOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py deleted file mode 100644 index c1aa54689f9b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py +++ /dev/null @@ -1,289 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._application_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApplicationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_07_01_preview.aio.SecurityCenter`'s - :attr:`application` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, application_id: str, **kwargs: Any) -> _models.Application: - """Get a specific application for the requested scope by applicationId. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - - _request = build_get_request( - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - application_id: str, - application: _models.Application, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Application: - """Creates or update a security application on the given subscription. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Required. - :type application: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, application_id: str, application: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Application: - """Creates or update a security application on the given subscription. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Required. - :type application: 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: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, application_id: str, application: Union[_models.Application, IO[bytes]], **kwargs: Any - ) -> _models.Application: - """Creates or update a security application on the given subscription. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Is either a Application type or a - IO[bytes] type. Required. - :type application: ~azure.mgmt.security.v2022_07_01_preview.models.Application or IO[bytes] - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(application, (IOBase, bytes)): - _content = application - else: - _json = self._serialize.body(application, "Application") - - _request = build_create_or_update_request( - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Application", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, application_id: str, **kwargs: Any - ) -> None: - """Delete an Application over a given scope. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py deleted file mode 100644 index 80d2ef587e4f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py +++ /dev/null @@ -1,138 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._applications_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_07_01_preview.aio.SecurityCenter`'s - :attr:`applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Application"]: - """Get a list of all relevant applications over a subscription level scope. - - :return: An iterator like instance of either Application or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_07_01_preview.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[_models.ApplicationsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ApplicationsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py deleted file mode 100644 index 812daae52eab..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py +++ /dev/null @@ -1,336 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_connector_application_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityConnectorApplicationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_07_01_preview.aio.SecurityCenter`'s - :attr:`security_connector_application` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, resource_group_name: str, security_connector_name: str, application_id: str, **kwargs: Any - ) -> _models.Application: - """Get a specific application for the requested scope by applicationId. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Application", pipeline_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, - security_connector_name: str, - application_id: str, - application: _models.Application, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Application: - """Creates or update a security Application on the given security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Required. - :type application: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - application_id: str, - application: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Application: - """Creates or update a security Application on the given security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Required. - :type application: 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: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - application_id: str, - application: Union[_models.Application, IO[bytes]], - **kwargs: Any - ) -> _models.Application: - """Creates or update a security Application on the given security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Is either a Application type or a - IO[bytes] type. Required. - :type application: ~azure.mgmt.security.v2022_07_01_preview.models.Application or IO[bytes] - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(application, (IOBase, bytes)): - _content = application - else: - _json = self._serialize.body(application, "Application") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Application", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, application_id: str, **kwargs: Any - ) -> None: - """Delete an Application over a given scope. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py deleted file mode 100644 index 2401b3eafdeb..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py +++ /dev/null @@ -1,147 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_connector_applications_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityConnectorApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_07_01_preview.aio.SecurityCenter`'s - :attr:`security_connector_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Application"]: - """Get a list of all relevant applications over a security connector level scope. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either Application or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_07_01_preview.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[_models.ApplicationsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ApplicationsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/__init__.py deleted file mode 100644 index 0958c7d80773..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/__init__.py +++ /dev/null @@ -1,33 +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 ._models_py3 import Application -from ._models_py3 import ApplicationCondition -from ._models_py3 import ApplicationsList -from ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Resource - -from ._security_center_enums import ApplicationConditionOperator -from ._security_center_enums import ApplicationSourceResourceType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Application", - "ApplicationCondition", - "ApplicationsList", - "CloudErrorBody", - "ErrorAdditionalInfo", - "Resource", - "ApplicationConditionOperator", - "ApplicationSourceResourceType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_models_py3.py deleted file mode 100644 index 6f7d99436f2b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_models_py3.py +++ /dev/null @@ -1,267 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Application(Resource): - """Security Application over a given scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: display name of the application. - :vartype display_name: str - :ivar description: description of the application. - :vartype description: str - :ivar source_resource_type: The application source, what it affects, e.g. Assessments. - "Assessments" - :vartype source_resource_type: str or - ~azure.mgmt.security.v2022_07_01_preview.models.ApplicationSourceResourceType - :ivar condition_sets: The application conditionSets - see examples. - :vartype condition_sets: list[JSON] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "source_resource_type": {"key": "properties.sourceResourceType", "type": "str"}, - "condition_sets": {"key": "properties.conditionSets", "type": "[object]"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - source_resource_type: Optional[Union[str, "_models.ApplicationSourceResourceType"]] = None, - condition_sets: Optional[List[JSON]] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: display name of the application. - :paramtype display_name: str - :keyword description: description of the application. - :paramtype description: str - :keyword source_resource_type: The application source, what it affects, e.g. Assessments. - "Assessments" - :paramtype source_resource_type: str or - ~azure.mgmt.security.v2022_07_01_preview.models.ApplicationSourceResourceType - :keyword condition_sets: The application conditionSets - see examples. - :paramtype condition_sets: list[JSON] - """ - super().__init__(**kwargs) - self.display_name = display_name - self.description = description - self.source_resource_type = source_resource_type - self.condition_sets = condition_sets - - -class ApplicationCondition(_serialization.Model): - """Application's condition. - - :ivar property: The application Condition's Property, e.g. ID, see examples. - :vartype property: str - :ivar value: The application Condition's Value like IDs that contain some string, see examples. - :vartype value: str - :ivar operator: The application Condition's Operator, for example Contains for id or In for - list of possible IDs, see examples. Known values are: "Contains", "Equals", and "In". - :vartype operator: str or - ~azure.mgmt.security.v2022_07_01_preview.models.ApplicationConditionOperator - """ - - _attribute_map = { - "property": {"key": "property", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - } - - def __init__( - self, - *, - property: Optional[str] = None, # pylint: disable=redefined-builtin - value: Optional[str] = None, - operator: Optional[Union[str, "_models.ApplicationConditionOperator"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword property: The application Condition's Property, e.g. ID, see examples. - :paramtype property: str - :keyword value: The application Condition's Value like IDs that contain some string, see - examples. - :paramtype value: str - :keyword operator: The application Condition's Operator, for example Contains for id or In for - list of possible IDs, see examples. Known values are: "Contains", "Equals", and "In". - :paramtype operator: str or - ~azure.mgmt.security.v2022_07_01_preview.models.ApplicationConditionOperator - """ - super().__init__(**kwargs) - self.property = property - self.value = value - self.operator = operator - - -class ApplicationsList(_serialization.Model): - """Page of a security applications list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of applications in this page. - :vartype value: list[~azure.mgmt.security.v2022_07_01_preview.models.Application] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Application]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class CloudErrorBody(_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.security.v2022_07_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2022_07_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_security_center_enums.py deleted file mode 100644 index e49ee5a27f81..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,31 +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 ApplicationConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The application Condition's Operator, for example Contains for id or In for list of possible - IDs, see examples. - """ - - CONTAINS = "Contains" - """Checks that the string value of the data defined in Property contains the given value""" - EQUALS = "Equals" - """Checks that the string value of the data defined in Property equals the given value""" - IN_ENUM = "In" - """Checks that the string value of the data defined in Property equals any of the given values - (exact fit)""" - - -class ApplicationSourceResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The application source, what it affects, e.g. Assessments.""" - - ASSESSMENTS = "Assessments" - """The source of the application is assessments""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/__init__.py deleted file mode 100644 index c85f8d56b434..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/__init__.py +++ /dev/null @@ -1,25 +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 ._applications_operations import ApplicationsOperations -from ._application_operations import ApplicationOperations -from ._security_connector_applications_operations import SecurityConnectorApplicationsOperations -from ._security_connector_application_operations import SecurityConnectorApplicationOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApplicationsOperations", - "ApplicationOperations", - "SecurityConnectorApplicationsOperations", - "SecurityConnectorApplicationOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py deleted file mode 100644 index 46beb9d6a936..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py +++ /dev/null @@ -1,370 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(application_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", "2022-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applications/{applicationId}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "applicationId": _SERIALIZER.url("application_id", application_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_create_or_update_request(application_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", "2022-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applications/{applicationId}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "applicationId": _SERIALIZER.url("application_id", application_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 - 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(application_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", "2022-07-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applications/{applicationId}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "applicationId": _SERIALIZER.url("application_id", application_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="DELETE", url=_url, params=_params, **kwargs) - - -class ApplicationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_07_01_preview.SecurityCenter`'s - :attr:`application` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, application_id: str, **kwargs: Any) -> _models.Application: - """Get a specific application for the requested scope by applicationId. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - - _request = build_get_request( - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - application_id: str, - application: _models.Application, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Application: - """Creates or update a security application on the given subscription. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Required. - :type application: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, application_id: str, application: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Application: - """Creates or update a security application on the given subscription. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Required. - :type application: 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: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, application_id: str, application: Union[_models.Application, IO[bytes]], **kwargs: Any - ) -> _models.Application: - """Creates or update a security application on the given subscription. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Is either a Application type or a - IO[bytes] type. Required. - :type application: ~azure.mgmt.security.v2022_07_01_preview.models.Application or IO[bytes] - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(application, (IOBase, bytes)): - _content = application - else: - _json = self._serialize.body(application, "Application") - - _request = build_create_or_update_request( - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Application", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete(self, application_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete an Application over a given scope. - - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py deleted file mode 100644 index a33cd30cb99b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py +++ /dev/null @@ -1,167 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2022-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applications") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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) - - -class ApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_07_01_preview.SecurityCenter`'s - :attr:`applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Application"]: - """Get a list of all relevant applications over a subscription level scope. - - :return: An iterator like instance of either Application or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_07_01_preview.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[_models.ApplicationsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ApplicationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py deleted file mode 100644 index 2389279997ec..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py +++ /dev/null @@ -1,440 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, security_connector_name: str, application_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", "2022-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/applications/{applicationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "applicationId": _SERIALIZER.url("application_id", application_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_create_or_update_request( - resource_group_name: str, security_connector_name: str, application_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", "2022-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/applications/{applicationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "applicationId": _SERIALIZER.url("application_id", application_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 - 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, security_connector_name: str, application_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", "2022-07-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/applications/{applicationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "applicationId": _SERIALIZER.url("application_id", application_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="DELETE", url=_url, params=_params, **kwargs) - - -class SecurityConnectorApplicationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_07_01_preview.SecurityCenter`'s - :attr:`security_connector_application` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, resource_group_name: str, security_connector_name: str, application_id: str, **kwargs: Any - ) -> _models.Application: - """Get a specific application for the requested scope by applicationId. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - application_id: str, - application: _models.Application, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Application: - """Creates or update a security Application on the given security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Required. - :type application: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - application_id: str, - application: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Application: - """Creates or update a security Application on the given security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Required. - :type application: 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: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - application_id: str, - application: Union[_models.Application, IO[bytes]], - **kwargs: Any - ) -> _models.Application: - """Creates or update a security Application on the given security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :param application: Application over a subscription scope. Is either a Application type or a - IO[bytes] type. Required. - :type application: ~azure.mgmt.security.v2022_07_01_preview.models.Application or IO[bytes] - :return: Application or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_07_01_preview.models.Application - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(application, (IOBase, bytes)): - _content = application - else: - _json = self._serialize.body(application, "Application") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Application", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, application_id: str, **kwargs: Any - ) -> None: - """Delete an Application over a given scope. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param application_id: The security Application key - unique key for the standard application. - Required. - :type application_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - application_id=application_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py deleted file mode 100644 index eb0daea47f9e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py +++ /dev/null @@ -1,185 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_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", "2022-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/applications", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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) - - -class SecurityConnectorApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_07_01_preview.SecurityCenter`'s - :attr:`security_connector_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> Iterable["_models.Application"]: - """Get a list of all relevant applications over a security connector level scope. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either Application or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_07_01_preview.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") - ) - cls: ClsType[_models.ApplicationsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ApplicationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_configuration.py deleted file mode 100644 index dda5665d8acc..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-08-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", "2022-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_metadata.json deleted file mode 100644 index 08cb37743f99..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2022-08-01-preview", - "total_api_version_list": ["2022-08-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "security_connectors": "SecurityConnectorsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py deleted file mode 100644 index edbe7eb6c5ec..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityConnectorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2022_08_01_preview.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_configuration.py deleted file mode 100644 index 81411244a6a2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-08-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", "2022-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py deleted file mode 100644 index 9776df709cf0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityConnectorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2022_08_01_preview.aio.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/__init__.py deleted file mode 100644 index 8e4ac6c4f04e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py deleted file mode 100644 index badc76df4c7f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py +++ /dev/null @@ -1,625 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_connectors_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_08_01_preview.aio.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] - :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._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] - :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._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/__init__.py deleted file mode 100644 index 15b0d0a8e79b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/__init__.py +++ /dev/null @@ -1,173 +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 ._models_py3 import AwsEnvironmentData -from ._models_py3 import AwsOrganizationalData -from ._models_py3 import AwsOrganizationalDataMaster -from ._models_py3 import AwsOrganizationalDataMember -from ._models_py3 import AzureDevOpsScopeEnvironmentData -from ._models_py3 import AzureTrackedResourceLocation -from ._models_py3 import CloudErrorBody -from ._models_py3 import CloudOffering -from ._models_py3 import CspmMonitorAwsOffering -from ._models_py3 import CspmMonitorAwsOfferingNativeCloudConnection -from ._models_py3 import CspmMonitorAzureDevOpsOffering -from ._models_py3 import CspmMonitorGcpOffering -from ._models_py3 import CspmMonitorGcpOfferingNativeCloudConnection -from ._models_py3 import CspmMonitorGithubOffering -from ._models_py3 import DefenderCspmAwsOffering -from ._models_py3 import DefenderCspmAwsOfferingVmScanners -from ._models_py3 import DefenderCspmAwsOfferingVmScannersConfiguration -from ._models_py3 import DefenderCspmGcpOffering -from ._models_py3 import DefenderFoDatabasesAwsOffering -from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioning -from ._models_py3 import DefenderFoDatabasesAwsOfferingRds -from ._models_py3 import DefenderForContainersAwsOffering -from ._models_py3 import DefenderForContainersAwsOfferingCloudWatchToKinesis -from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessment -from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask -from ._models_py3 import DefenderForContainersAwsOfferingKinesisToS3 -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesScubaReader -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesService -from ._models_py3 import DefenderForContainersGcpOffering -from ._models_py3 import DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection -from ._models_py3 import DefenderForContainersGcpOfferingNativeCloudConnection -from ._models_py3 import DefenderForDatabasesGcpOffering -from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioning -from ._models_py3 import DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning -from ._models_py3 import DefenderForDevOpsAzureDevOpsOffering -from ._models_py3 import DefenderForDevOpsGithubOffering -from ._models_py3 import DefenderForServersAwsOffering -from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingDefenderForServers -from ._models_py3 import DefenderForServersAwsOfferingMdeAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingSubPlan -from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersAwsOfferingVmScanners -from ._models_py3 import DefenderForServersAwsOfferingVmScannersConfiguration -from ._models_py3 import DefenderForServersGcpOffering -from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingDefenderForServers -from ._models_py3 import DefenderForServersGcpOfferingMdeAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingSubPlan -from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioningConfiguration -from ._models_py3 import ETag -from ._models_py3 import EnvironmentData -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import GcpOrganizationalData -from ._models_py3 import GcpOrganizationalDataMember -from ._models_py3 import GcpOrganizationalDataOrganization -from ._models_py3 import GcpProjectDetails -from ._models_py3 import GcpProjectEnvironmentData -from ._models_py3 import GithubScopeEnvironmentData -from ._models_py3 import InformationProtectionAwsOffering -from ._models_py3 import InformationProtectionAwsOfferingInformationProtection -from ._models_py3 import Kind -from ._models_py3 import Resource -from ._models_py3 import SecurityConnector -from ._models_py3 import SecurityConnectorsList -from ._models_py3 import SystemData -from ._models_py3 import Tags -from ._models_py3 import TrackedResource - -from ._security_center_enums import CloudName -from ._security_center_enums import CreatedByType -from ._security_center_enums import EnvironmentType -from ._security_center_enums import OfferingType -from ._security_center_enums import OrganizationMembershipType -from ._security_center_enums import ScanningMode -from ._security_center_enums import SubPlan -from ._security_center_enums import Type -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AwsEnvironmentData", - "AwsOrganizationalData", - "AwsOrganizationalDataMaster", - "AwsOrganizationalDataMember", - "AzureDevOpsScopeEnvironmentData", - "AzureTrackedResourceLocation", - "CloudErrorBody", - "CloudOffering", - "CspmMonitorAwsOffering", - "CspmMonitorAwsOfferingNativeCloudConnection", - "CspmMonitorAzureDevOpsOffering", - "CspmMonitorGcpOffering", - "CspmMonitorGcpOfferingNativeCloudConnection", - "CspmMonitorGithubOffering", - "DefenderCspmAwsOffering", - "DefenderCspmAwsOfferingVmScanners", - "DefenderCspmAwsOfferingVmScannersConfiguration", - "DefenderCspmGcpOffering", - "DefenderFoDatabasesAwsOffering", - "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", - "DefenderFoDatabasesAwsOfferingRds", - "DefenderForContainersAwsOffering", - "DefenderForContainersAwsOfferingCloudWatchToKinesis", - "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", - "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", - "DefenderForContainersAwsOfferingKinesisToS3", - "DefenderForContainersAwsOfferingKubernetesScubaReader", - "DefenderForContainersAwsOfferingKubernetesService", - "DefenderForContainersGcpOffering", - "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", - "DefenderForContainersGcpOfferingNativeCloudConnection", - "DefenderForDatabasesGcpOffering", - "DefenderForDatabasesGcpOfferingArcAutoProvisioning", - "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", - "DefenderForDevOpsAzureDevOpsOffering", - "DefenderForDevOpsGithubOffering", - "DefenderForServersAwsOffering", - "DefenderForServersAwsOfferingArcAutoProvisioning", - "DefenderForServersAwsOfferingDefenderForServers", - "DefenderForServersAwsOfferingMdeAutoProvisioning", - "DefenderForServersAwsOfferingSubPlan", - "DefenderForServersAwsOfferingVaAutoProvisioning", - "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", - "DefenderForServersAwsOfferingVmScanners", - "DefenderForServersAwsOfferingVmScannersConfiguration", - "DefenderForServersGcpOffering", - "DefenderForServersGcpOfferingArcAutoProvisioning", - "DefenderForServersGcpOfferingDefenderForServers", - "DefenderForServersGcpOfferingMdeAutoProvisioning", - "DefenderForServersGcpOfferingSubPlan", - "DefenderForServersGcpOfferingVaAutoProvisioning", - "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", - "ETag", - "EnvironmentData", - "ErrorAdditionalInfo", - "GcpOrganizationalData", - "GcpOrganizationalDataMember", - "GcpOrganizationalDataOrganization", - "GcpProjectDetails", - "GcpProjectEnvironmentData", - "GithubScopeEnvironmentData", - "InformationProtectionAwsOffering", - "InformationProtectionAwsOfferingInformationProtection", - "Kind", - "Resource", - "SecurityConnector", - "SecurityConnectorsList", - "SystemData", - "Tags", - "TrackedResource", - "CloudName", - "CreatedByType", - "EnvironmentType", - "OfferingType", - "OrganizationMembershipType", - "ScanningMode", - "SubPlan", - "Type", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_models_py3.py deleted file mode 100644 index d1aec7a44abc..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_models_py3.py +++ /dev/null @@ -1,2787 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class EnvironmentData(_serialization.Model): - """The security connector environment data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AwsEnvironmentData, AzureDevOpsScopeEnvironmentData, GcpProjectEnvironmentData, - GithubScopeEnvironmentData - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - _subtype_map = { - "environment_type": { - "AwsAccount": "AwsEnvironmentData", - "AzureDevOpsScope": "AzureDevOpsScopeEnvironmentData", - "GcpProject": "GcpProjectEnvironmentData", - "GithubScope": "GithubScopeEnvironmentData", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: Optional[str] = None - - -class AwsEnvironmentData(EnvironmentData): - """The aws connector environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType - :ivar organizational_data: The AWS account's organizational data. - :vartype organizational_data: - ~azure.mgmt.security.v2022_08_01_preview.models.AwsOrganizationalData - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - "organizational_data": {"key": "organizationalData", "type": "AwsOrganizationalData"}, - } - - def __init__(self, *, organizational_data: Optional["_models.AwsOrganizationalData"] = None, **kwargs: Any) -> None: - """ - :keyword organizational_data: The AWS account's organizational data. - :paramtype organizational_data: - ~azure.mgmt.security.v2022_08_01_preview.models.AwsOrganizationalData - """ - super().__init__(**kwargs) - self.environment_type: str = "AwsAccount" - self.organizational_data = organizational_data - - -class AwsOrganizationalData(_serialization.Model): - """The awsOrganization data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AwsOrganizationalDataMember, AwsOrganizationalDataMaster - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - } - - _subtype_map = { - "organization_membership_type": { - "Member": "AwsOrganizationalDataMember", - "Organization": "AwsOrganizationalDataMaster", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.organization_membership_type: Optional[str] = None - - -class AwsOrganizationalDataMaster(AwsOrganizationalData): - """The awsOrganization data for the master account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType - :ivar stackset_name: If the multi cloud account is of membership type organization, this will - be the name of the onboarding stackset. - :vartype stackset_name: str - :ivar excluded_account_ids: If the multi cloud account is of membership type organization, list - of accounts excluded from offering. - :vartype excluded_account_ids: list[str] - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "stackset_name": {"key": "stacksetName", "type": "str"}, - "excluded_account_ids": {"key": "excludedAccountIds", "type": "[str]"}, - } - - def __init__( - self, *, stackset_name: Optional[str] = None, excluded_account_ids: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword stackset_name: If the multi cloud account is of membership type organization, this - will be the name of the onboarding stackset. - :paramtype stackset_name: str - :keyword excluded_account_ids: If the multi cloud account is of membership type organization, - list of accounts excluded from offering. - :paramtype excluded_account_ids: list[str] - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Organization" - self.stackset_name = stackset_name - self.excluded_account_ids = excluded_account_ids - - -class AwsOrganizationalDataMember(AwsOrganizationalData): - """The awsOrganization data for the member account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType - :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, - this will be the ID of the account's parent. - :vartype parent_hierarchy_id: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, - } - - def __init__(self, *, parent_hierarchy_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword parent_hierarchy_id: If the multi cloud account is not of membership type - organization, this will be the ID of the account's parent. - :paramtype parent_hierarchy_id: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Member" - self.parent_hierarchy_id = parent_hierarchy_id - - -class AzureDevOpsScopeEnvironmentData(EnvironmentData): - """The AzureDevOps scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "AzureDevOpsScope" - - -class AzureTrackedResourceLocation(_serialization.Model): - """Describes an Azure resource with location. - - :ivar location: Location where the resource is stored. - :vartype location: str - """ - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - - -class CloudErrorBody(_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.security.v2022_08_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2022_08_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class CloudOffering(_serialization.Model): - """The security offering details. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - CspmMonitorAwsOffering, CspmMonitorAzureDevOpsOffering, CspmMonitorGcpOffering, - CspmMonitorGithubOffering, DefenderCspmAwsOffering, DefenderCspmGcpOffering, - DefenderForContainersAwsOffering, DefenderForContainersGcpOffering, - DefenderFoDatabasesAwsOffering, DefenderForDatabasesGcpOffering, - DefenderForDevOpsAzureDevOpsOffering, DefenderForDevOpsGithubOffering, - DefenderForServersAwsOffering, DefenderForServersGcpOffering, InformationProtectionAwsOffering - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - _subtype_map = { - "offering_type": { - "CspmMonitorAws": "CspmMonitorAwsOffering", - "CspmMonitorAzureDevOps": "CspmMonitorAzureDevOpsOffering", - "CspmMonitorGcp": "CspmMonitorGcpOffering", - "CspmMonitorGithub": "CspmMonitorGithubOffering", - "DefenderCspmAws": "DefenderCspmAwsOffering", - "DefenderCspmGcp": "DefenderCspmGcpOffering", - "DefenderForContainersAws": "DefenderForContainersAwsOffering", - "DefenderForContainersGcp": "DefenderForContainersGcpOffering", - "DefenderForDatabasesAws": "DefenderFoDatabasesAwsOffering", - "DefenderForDatabasesGcp": "DefenderForDatabasesGcpOffering", - "DefenderForDevOpsAzureDevOps": "DefenderForDevOpsAzureDevOpsOffering", - "DefenderForDevOpsGithub": "DefenderForDevOpsGithubOffering", - "DefenderForServersAws": "DefenderForServersAwsOffering", - "DefenderForServersGcp": "DefenderForServersGcpOffering", - "InformationProtectionAws": "InformationProtectionAwsOffering", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: Optional[str] = None - self.description = None - - -class CspmMonitorAwsOffering(CloudOffering): - """The CSPM monitoring for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2022_08_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "CspmMonitorAwsOfferingNativeCloudConnection", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.CspmMonitorAwsOfferingNativeCloudConnection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2022_08_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorAws" - self.native_cloud_connection = native_cloud_connection - - -class CspmMonitorAwsOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class CspmMonitorAzureDevOpsOffering(CloudOffering): - """The CSPM monitoring for AzureDevOps offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorAzureDevOps" - - -class CspmMonitorGcpOffering(CloudOffering): - """The CSPM monitoring for GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2022_08_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "CspmMonitorGcpOfferingNativeCloudConnection", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.CspmMonitorGcpOfferingNativeCloudConnection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2022_08_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection - """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGcp" - self.native_cloud_connection = native_cloud_connection - - -class CspmMonitorGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar workload_identity_provider_id: The GCP workload identity provider id for the offering. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword workload_identity_provider_id: The GCP workload identity provider id for the offering. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class CspmMonitorGithubOffering(CloudOffering): - """The CSPM monitoring for github offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGithub" - - -class DefenderCspmAwsOffering(CloudOffering): - """The CSPM P1 for Aws offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderCspmAwsOfferingVmScanners - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderCspmAwsOfferingVmScanners"}, - } - - def __init__( - self, *, vm_scanners: Optional["_models.DefenderCspmAwsOfferingVmScanners"] = None, **kwargs: Any - ) -> None: - """ - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderCspmAwsOfferingVmScanners - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderCspmAws" - self.vm_scanners = vm_scanners - - -class DefenderCspmAwsOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderCspmAwsOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderCspmAwsOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderCspmAwsOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar scanning_mode: The scanning mode for the vm scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2022_08_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. - :vartype exclusion_tags: dict[str, str] - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, - } - - def __init__( - self, - *, - cloud_role_arn: Optional[str] = None, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword scanning_mode: The scanning mode for the vm scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2022_08_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. - :paramtype exclusion_tags: dict[str, str] - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class DefenderCspmGcpOffering(CloudOffering): - """The CSPM P1 for GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderCspmGcp" - - -class DefenderFoDatabasesAwsOffering(CloudOffering): - """The Defender for Databases AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning - :ivar rds: The RDS configuration. - :vartype rds: ~azure.mgmt.security.v2022_08_01_preview.models.DefenderFoDatabasesAwsOfferingRds - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", - }, - "rds": {"key": "rds", "type": "DefenderFoDatabasesAwsOfferingRds"}, - } - - def __init__( - self, - *, - arc_auto_provisioning: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning"] = None, - rds: Optional["_models.DefenderFoDatabasesAwsOfferingRds"] = None, - **kwargs: Any - ) -> None: - """ - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning - :keyword rds: The RDS configuration. - :paramtype rds: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderFoDatabasesAwsOfferingRds - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDatabasesAws" - self.arc_auto_provisioning = arc_auto_provisioning - self.rds = rds - - -class DefenderFoDatabasesAwsOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderFoDatabasesAwsOfferingRds(_serialization.Model): - """The RDS configuration. - - :ivar enabled: Is RDS protection enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is RDS protection enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOffering(CloudOffering): # pylint: disable=too-many-instance-attributes - """The Defender for Containers AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar kubernetes_service: The kubernetes service connection configuration. - :vartype kubernetes_service: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :ivar kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :vartype kubernetes_scuba_reader: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :ivar cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :vartype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :ivar kinesis_to_s3: The kinesis to s3 connection configuration. - :vartype kinesis_to_s3: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - :ivar container_vulnerability_assessment: The container vulnerability assessment configuration. - :vartype container_vulnerability_assessment: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment - :ivar container_vulnerability_assessment_task: The container vulnerability assessment task - configuration. - :vartype container_vulnerability_assessment_task: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask # pylint: disable=line-too-long - :ivar enable_container_vulnerability_assessment: Enable container vulnerability assessment - feature. - :vartype enable_container_vulnerability_assessment: bool - :ivar auto_provisioning: Is audit logs pipeline auto provisioning enabled. - :vartype auto_provisioning: bool - :ivar kube_audit_retention_time: The retention time in days of kube audit logs set on the - CloudWatch log group. - :vartype kube_audit_retention_time: int - :ivar scuba_external_id: The externalId used by the data reader to prevent the confused deputy - attack. - :vartype scuba_external_id: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "kubernetes_service": {"key": "kubernetesService", "type": "DefenderForContainersAwsOfferingKubernetesService"}, - "kubernetes_scuba_reader": { - "key": "kubernetesScubaReader", - "type": "DefenderForContainersAwsOfferingKubernetesScubaReader", - }, - "cloud_watch_to_kinesis": { - "key": "cloudWatchToKinesis", - "type": "DefenderForContainersAwsOfferingCloudWatchToKinesis", - }, - "kinesis_to_s3": {"key": "kinesisToS3", "type": "DefenderForContainersAwsOfferingKinesisToS3"}, - "container_vulnerability_assessment": { - "key": "containerVulnerabilityAssessment", - "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", - }, - "container_vulnerability_assessment_task": { - "key": "containerVulnerabilityAssessmentTask", - "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", - }, - "enable_container_vulnerability_assessment": {"key": "enableContainerVulnerabilityAssessment", "type": "bool"}, - "auto_provisioning": {"key": "autoProvisioning", "type": "bool"}, - "kube_audit_retention_time": {"key": "kubeAuditRetentionTime", "type": "int"}, - "scuba_external_id": {"key": "scubaExternalId", "type": "str"}, - } - - def __init__( - self, - *, - kubernetes_service: Optional["_models.DefenderForContainersAwsOfferingKubernetesService"] = None, - kubernetes_scuba_reader: Optional["_models.DefenderForContainersAwsOfferingKubernetesScubaReader"] = None, - cloud_watch_to_kinesis: Optional["_models.DefenderForContainersAwsOfferingCloudWatchToKinesis"] = None, - kinesis_to_s3: Optional["_models.DefenderForContainersAwsOfferingKinesisToS3"] = None, - container_vulnerability_assessment: Optional[ - "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment" - ] = None, - container_vulnerability_assessment_task: Optional[ - "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask" - ] = None, - enable_container_vulnerability_assessment: Optional[bool] = None, - auto_provisioning: Optional[bool] = None, - kube_audit_retention_time: Optional[int] = None, - scuba_external_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword kubernetes_service: The kubernetes service connection configuration. - :paramtype kubernetes_service: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :keyword kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :paramtype kubernetes_scuba_reader: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :keyword cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :paramtype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :keyword kinesis_to_s3: The kinesis to s3 connection configuration. - :paramtype kinesis_to_s3: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - :keyword container_vulnerability_assessment: The container vulnerability assessment - configuration. - :paramtype container_vulnerability_assessment: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment # pylint: disable=line-too-long - :keyword container_vulnerability_assessment_task: The container vulnerability assessment task - configuration. - :paramtype container_vulnerability_assessment_task: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask # pylint: disable=line-too-long - :keyword enable_container_vulnerability_assessment: Enable container vulnerability assessment - feature. - :paramtype enable_container_vulnerability_assessment: bool - :keyword auto_provisioning: Is audit logs pipeline auto provisioning enabled. - :paramtype auto_provisioning: bool - :keyword kube_audit_retention_time: The retention time in days of kube audit logs set on the - CloudWatch log group. - :paramtype kube_audit_retention_time: int - :keyword scuba_external_id: The externalId used by the data reader to prevent the confused - deputy attack. - :paramtype scuba_external_id: str - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForContainersAws" - self.kubernetes_service = kubernetes_service - self.kubernetes_scuba_reader = kubernetes_scuba_reader - self.cloud_watch_to_kinesis = cloud_watch_to_kinesis - self.kinesis_to_s3 = kinesis_to_s3 - self.container_vulnerability_assessment = container_vulnerability_assessment - self.container_vulnerability_assessment_task = container_vulnerability_assessment_task - self.enable_container_vulnerability_assessment = enable_container_vulnerability_assessment - self.auto_provisioning = auto_provisioning - self.kube_audit_retention_time = kube_audit_retention_time - self.scuba_external_id = scuba_external_id - - -class DefenderForContainersAwsOfferingCloudWatchToKinesis(_serialization.Model): # pylint: disable=name-too-long - """The cloudwatch to kinesis connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into - Kinesis. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into - Kinesis. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingContainerVulnerabilityAssessment( - _serialization.Model -): # pylint: disable=name-too-long - """The container vulnerability assessment configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask( - _serialization.Model -): # pylint: disable=name-too-long - """The container vulnerability assessment task configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKinesisToS3(_serialization.Model): # pylint: disable=name-too-long - """The kinesis to s3 connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesScubaReader(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes to scuba connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesService(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes service connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning - resources. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning - resources. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersGcpOffering(CloudOffering): - """The containers GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection - :ivar data_pipeline_native_cloud_connection: The native cloud connection configuration. - :vartype data_pipeline_native_cloud_connection: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection - :ivar audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. - :vartype audit_logs_auto_provisioning_flag: bool - :ivar defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes agent - auto provisioning enabled. - :vartype defender_agent_auto_provisioning_flag: bool - :ivar policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning - enabled. - :vartype policy_agent_auto_provisioning_flag: bool - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "DefenderForContainersGcpOfferingNativeCloudConnection", - }, - "data_pipeline_native_cloud_connection": { - "key": "dataPipelineNativeCloudConnection", - "type": "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", - }, - "audit_logs_auto_provisioning_flag": {"key": "auditLogsAutoProvisioningFlag", "type": "bool"}, - "defender_agent_auto_provisioning_flag": {"key": "defenderAgentAutoProvisioningFlag", "type": "bool"}, - "policy_agent_auto_provisioning_flag": {"key": "policyAgentAutoProvisioningFlag", "type": "bool"}, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.DefenderForContainersGcpOfferingNativeCloudConnection"] = None, - data_pipeline_native_cloud_connection: Optional[ - "_models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection" - ] = None, - audit_logs_auto_provisioning_flag: Optional[bool] = None, - defender_agent_auto_provisioning_flag: Optional[bool] = None, - policy_agent_auto_provisioning_flag: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection - :keyword data_pipeline_native_cloud_connection: The native cloud connection configuration. - :paramtype data_pipeline_native_cloud_connection: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection # pylint: disable=line-too-long - :keyword audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. - :paramtype audit_logs_auto_provisioning_flag: bool - :keyword defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes - agent auto provisioning enabled. - :paramtype defender_agent_auto_provisioning_flag: bool - :keyword policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning - enabled. - :paramtype policy_agent_auto_provisioning_flag: bool - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForContainersGcp" - self.native_cloud_connection = native_cloud_connection - self.data_pipeline_native_cloud_connection = data_pipeline_native_cloud_connection - self.audit_logs_auto_provisioning_flag = audit_logs_auto_provisioning_flag - self.defender_agent_auto_provisioning_flag = defender_agent_auto_provisioning_flag - self.policy_agent_auto_provisioning_flag = policy_agent_auto_provisioning_flag - - -class DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection( - _serialization.Model -): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The data collection service account email address in GCP - for this offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The data collection GCP workload identity provider id for - this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The data collection service account email address in - GCP for this offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The data collection GCP workload identity provider id - for this offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForContainersGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id for this - offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForDatabasesGcpOffering(CloudOffering): - """The Defender for Databases GCP offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning - :ivar defender_for_databases_arc_auto_provisioning: The native cloud connection configuration. - :vartype defender_for_databases_arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning # pylint: disable=line-too-long - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioning", - }, - "defender_for_databases_arc_auto_provisioning": { - "key": "defenderForDatabasesArcAutoProvisioning", - "type": "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", - }, - } - - def __init__( - self, - *, - arc_auto_provisioning: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioning"] = None, - defender_for_databases_arc_auto_provisioning: Optional[ - "_models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning - :keyword defender_for_databases_arc_auto_provisioning: The native cloud connection - configuration. - :paramtype defender_for_databases_arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDatabasesGcp" - self.arc_auto_provisioning = arc_auto_provisioning - self.defender_for_databases_arc_auto_provisioning = defender_for_databases_arc_auto_provisioning - - -class DefenderForDatabasesGcpOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.enabled = enabled - - -class DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning( - _serialization.Model -): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id for this - offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForDevOpsAzureDevOpsOffering(CloudOffering): - """The Defender for DevOps for Azure DevOps offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDevOpsAzureDevOps" - - -class DefenderForDevOpsGithubOffering(CloudOffering): - """The Defender for DevOps for Github offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDevOpsGithub" - - -class DefenderForServersAwsOffering(CloudOffering): - """The Defender for Servers AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar defender_for_servers: The Defender for servers connection configuration. - :vartype defender_for_servers: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :vartype va_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning - :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :vartype mde_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning - :ivar sub_plan: configuration for the servers offering subPlan. - :vartype sub_plan: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingSubPlan - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVmScanners - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "defender_for_servers": { - "key": "defenderForServers", - "type": "DefenderForServersAwsOfferingDefenderForServers", - }, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForServersAwsOfferingArcAutoProvisioning", - }, - "va_auto_provisioning": { - "key": "vaAutoProvisioning", - "type": "DefenderForServersAwsOfferingVaAutoProvisioning", - }, - "mde_auto_provisioning": { - "key": "mdeAutoProvisioning", - "type": "DefenderForServersAwsOfferingMdeAutoProvisioning", - }, - "sub_plan": {"key": "subPlan", "type": "DefenderForServersAwsOfferingSubPlan"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersAwsOfferingVmScanners"}, - } - - def __init__( - self, - *, - defender_for_servers: Optional["_models.DefenderForServersAwsOfferingDefenderForServers"] = None, - arc_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioning"] = None, - va_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioning"] = None, - mde_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingMdeAutoProvisioning"] = None, - sub_plan: Optional["_models.DefenderForServersAwsOfferingSubPlan"] = None, - vm_scanners: Optional["_models.DefenderForServersAwsOfferingVmScanners"] = None, - **kwargs: Any - ) -> None: - """ - :keyword defender_for_servers: The Defender for servers connection configuration. - :paramtype defender_for_servers: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :paramtype va_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning - :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :paramtype mde_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning - :keyword sub_plan: configuration for the servers offering subPlan. - :paramtype sub_plan: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingSubPlan - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVmScanners - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForServersAws" - self.defender_for_servers = defender_for_servers - self.arc_auto_provisioning = arc_auto_provisioning - self.va_auto_provisioning = va_auto_provisioning - self.mde_auto_provisioning = mde_auto_provisioning - self.sub_plan = sub_plan - self.vm_scanners = vm_scanners - - -class DefenderForServersAwsOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderForServersAwsOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long - """The Defender for servers connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForServersAwsOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender for Endpoint autoprovisioning configuration. - - :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :vartype configuration: JSON - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "object"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :paramtype configuration: JSON - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingSubPlan(_serialization.Model): - """configuration for the servers offering subPlan. - - :ivar type: The available sub plans. Known values are: "P1" and "P2". - :vartype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.SubPlan - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The available sub plans. Known values are: "P1" and "P2". - :paramtype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.SubPlan - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersAwsOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Vulnerability Assessment autoprovisioning configuration. - - :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingVaAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """configuration for Vulnerability Assessment autoprovisioning. - - :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :vartype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.Type - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :paramtype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.Type - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersAwsOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderForServersAwsOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar scanning_mode: The scanning mode for the vm scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2022_08_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. - :vartype exclusion_tags: dict[str, str] - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, - } - - def __init__( - self, - *, - cloud_role_arn: Optional[str] = None, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword scanning_mode: The scanning mode for the vm scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2022_08_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. - :paramtype exclusion_tags: dict[str, str] - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class DefenderForServersGcpOffering(CloudOffering): - """The Defender for Servers GCP offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar defender_for_servers: The Defender for servers connection configuration. - :vartype defender_for_servers: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingDefenderForServers - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning - :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :vartype va_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning - :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :vartype mde_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning - :ivar sub_plan: configuration for the servers offering subPlan. - :vartype sub_plan: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingSubPlan - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "defender_for_servers": { - "key": "defenderForServers", - "type": "DefenderForServersGcpOfferingDefenderForServers", - }, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForServersGcpOfferingArcAutoProvisioning", - }, - "va_auto_provisioning": { - "key": "vaAutoProvisioning", - "type": "DefenderForServersGcpOfferingVaAutoProvisioning", - }, - "mde_auto_provisioning": { - "key": "mdeAutoProvisioning", - "type": "DefenderForServersGcpOfferingMdeAutoProvisioning", - }, - "sub_plan": {"key": "subPlan", "type": "DefenderForServersGcpOfferingSubPlan"}, - } - - def __init__( - self, - *, - defender_for_servers: Optional["_models.DefenderForServersGcpOfferingDefenderForServers"] = None, - arc_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioning"] = None, - va_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioning"] = None, - mde_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingMdeAutoProvisioning"] = None, - sub_plan: Optional["_models.DefenderForServersGcpOfferingSubPlan"] = None, - **kwargs: Any - ) -> None: - """ - :keyword defender_for_servers: The Defender for servers connection configuration. - :paramtype defender_for_servers: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingDefenderForServers - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning - :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :paramtype va_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning - :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :paramtype mde_auto_provisioning: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning - :keyword sub_plan: configuration for the servers offering subPlan. - :paramtype sub_plan: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingSubPlan - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForServersGcp" - self.defender_for_servers = defender_for_servers - self.arc_auto_provisioning = arc_auto_provisioning - self.va_auto_provisioning = va_auto_provisioning - self.mde_auto_provisioning = mde_auto_provisioning - self.sub_plan = sub_plan - - -class DefenderForServersGcpOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.enabled = enabled - - -class DefenderForServersGcpOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long - """The Defender for servers connection configuration. - - :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this feature. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword workload_identity_provider_id: The workload identity provider id in GCP for this - feature. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - feature. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class DefenderForServersGcpOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender for Endpoint autoprovisioning configuration. - - :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :vartype configuration: JSON - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "object"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :paramtype configuration: JSON - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingSubPlan(_serialization.Model): - """configuration for the servers offering subPlan. - - :ivar type: The available sub plans. Known values are: "P1" and "P2". - :vartype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.SubPlan - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The available sub plans. Known values are: "P1" and "P2". - :paramtype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.SubPlan - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersGcpOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Vulnerability Assessment autoprovisioning configuration. - - :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingVaAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """configuration for Vulnerability Assessment autoprovisioning. - - :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :vartype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.Type - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :paramtype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.Type - """ - super().__init__(**kwargs) - self.type = type - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ETag(_serialization.Model): - """Entity tag is used for comparing two or more entities from the same requested resource. - - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - """ - - _attribute_map = { - "etag": {"key": "etag", "type": "str"}, - } - - def __init__(self, *, etag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - """ - super().__init__(**kwargs) - self.etag = etag - - -class GcpOrganizationalData(_serialization.Model): - """The gcpOrganization data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - GcpOrganizationalDataMember, GcpOrganizationalDataOrganization - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - } - - _subtype_map = { - "organization_membership_type": { - "Member": "GcpOrganizationalDataMember", - "Organization": "GcpOrganizationalDataOrganization", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.organization_membership_type: Optional[str] = None - - -class GcpOrganizationalDataMember(GcpOrganizationalData): - """The gcpOrganization data for the member account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType - :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, - this will be the ID of the project's parent. - :vartype parent_hierarchy_id: str - :ivar management_project_number: The GCP management project number from organizational - onboarding. - :vartype management_project_number: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, - "management_project_number": {"key": "managementProjectNumber", "type": "str"}, - } - - def __init__( - self, - *, - parent_hierarchy_id: Optional[str] = None, - management_project_number: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword parent_hierarchy_id: If the multi cloud account is not of membership type - organization, this will be the ID of the project's parent. - :paramtype parent_hierarchy_id: str - :keyword management_project_number: The GCP management project number from organizational - onboarding. - :paramtype management_project_number: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Member" - self.parent_hierarchy_id = parent_hierarchy_id - self.management_project_number = management_project_number - - -class GcpOrganizationalDataOrganization(GcpOrganizationalData): - """The gcpOrganization data for the parent account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType - :ivar excluded_project_numbers: If the multi cloud account is of membership type organization, - list of accounts excluded from offering. - :vartype excluded_project_numbers: list[str] - :ivar service_account_email_address: The service account email address which represents the - organization level permissions container. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id which represents the - permissions required to auto provision security connectors. - :vartype workload_identity_provider_id: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "excluded_project_numbers": {"key": "excludedProjectNumbers", "type": "[str]"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - excluded_project_numbers: Optional[List[str]] = None, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword excluded_project_numbers: If the multi cloud account is of membership type - organization, list of accounts excluded from offering. - :paramtype excluded_project_numbers: list[str] - :keyword service_account_email_address: The service account email address which represents the - organization level permissions container. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id which represents - the permissions required to auto provision security connectors. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Organization" - self.excluded_project_numbers = excluded_project_numbers - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class GcpProjectDetails(_serialization.Model): - """The details about the project represented by the security connector. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar project_number: The unique GCP Project number. - :vartype project_number: str - :ivar project_id: The GCP Project id. - :vartype project_id: str - :ivar workload_identity_pool_id: The GCP workload identity federation pool id. - :vartype workload_identity_pool_id: str - """ - - _validation = { - "workload_identity_pool_id": {"readonly": True}, - } - - _attribute_map = { - "project_number": {"key": "projectNumber", "type": "str"}, - "project_id": {"key": "projectId", "type": "str"}, - "workload_identity_pool_id": {"key": "workloadIdentityPoolId", "type": "str"}, - } - - def __init__( - self, *, project_number: Optional[str] = None, project_id: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword project_number: The unique GCP Project number. - :paramtype project_number: str - :keyword project_id: The GCP Project id. - :paramtype project_id: str - """ - super().__init__(**kwargs) - self.project_number = project_number - self.project_id = project_id - self.workload_identity_pool_id = None - - -class GcpProjectEnvironmentData(EnvironmentData): - """The GCP project connector environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType - :ivar organizational_data: The Gcp project's organizational data. - :vartype organizational_data: - ~azure.mgmt.security.v2022_08_01_preview.models.GcpOrganizationalData - :ivar project_details: The Gcp project's details. - :vartype project_details: ~azure.mgmt.security.v2022_08_01_preview.models.GcpProjectDetails - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - "organizational_data": {"key": "organizationalData", "type": "GcpOrganizationalData"}, - "project_details": {"key": "projectDetails", "type": "GcpProjectDetails"}, - } - - def __init__( - self, - *, - organizational_data: Optional["_models.GcpOrganizationalData"] = None, - project_details: Optional["_models.GcpProjectDetails"] = None, - **kwargs: Any - ) -> None: - """ - :keyword organizational_data: The Gcp project's organizational data. - :paramtype organizational_data: - ~azure.mgmt.security.v2022_08_01_preview.models.GcpOrganizationalData - :keyword project_details: The Gcp project's details. - :paramtype project_details: ~azure.mgmt.security.v2022_08_01_preview.models.GcpProjectDetails - """ - super().__init__(**kwargs) - self.environment_type: str = "GcpProject" - self.organizational_data = organizational_data - self.project_details = project_details - - -class GithubScopeEnvironmentData(EnvironmentData): - """The github scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "GithubScope" - - -class InformationProtectionAwsOffering(CloudOffering): - """The information protection for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and - "DefenderForDevOpsAzureDevOps". - :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar information_protection: The native cloud connection configuration. - :vartype information_protection: - ~azure.mgmt.security.v2022_08_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "information_protection": { - "key": "informationProtection", - "type": "InformationProtectionAwsOfferingInformationProtection", - }, - } - - def __init__( - self, - *, - information_protection: Optional["_models.InformationProtectionAwsOfferingInformationProtection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword information_protection: The native cloud connection configuration. - :paramtype information_protection: - ~azure.mgmt.security.v2022_08_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - super().__init__(**kwargs) - self.offering_type: str = "InformationProtectionAws" - self.information_protection = information_protection - - -class InformationProtectionAwsOfferingInformationProtection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class Kind(_serialization.Model): - """Describes an Azure resource with kind. - - :ivar kind: Kind of the resource. - :vartype kind: str - """ - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__(self, *, kind: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword kind: Kind of the resource. - :paramtype kind: str - """ - super().__init__(**kwargs) - self.kind = kind - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Tags(_serialization.Model): - """A list of key value pairs that describe the resource. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class TrackedResource(Resource, AzureTrackedResourceLocation, Kind, ETag, Tags): - """Describes an Azure tracked resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) - self.tags = tags - self.etag = etag - self.kind = kind - self.location = location - self.id = None - self.name = None - self.type = None - - -class SecurityConnector(TrackedResource): # pylint: disable=too-many-instance-attributes - """The security connector resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2022_08_01_preview.models.SystemData - :ivar hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector, project number in case of GCP connector). - :vartype hierarchy_identifier: str - :ivar hierarchy_identifier_trial_end_date: The date on which the trial period will end, if - applicable. Trial period exists for 30 days after upgrading to payed offerings. - :vartype hierarchy_identifier_trial_end_date: ~datetime.datetime - :ivar environment_name: The multi cloud resource's cloud name. Known values are: "Azure", - "AWS", "GCP", "Github", and "AzureDevOps". - :vartype environment_name: str or ~azure.mgmt.security.v2022_08_01_preview.models.CloudName - :ivar offerings: A collection of offerings for the security connector. - :vartype offerings: list[~azure.mgmt.security.v2022_08_01_preview.models.CloudOffering] - :ivar environment_data: The security connector environment data. - :vartype environment_data: ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "hierarchy_identifier_trial_end_date": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "hierarchy_identifier": {"key": "properties.hierarchyIdentifier", "type": "str"}, - "hierarchy_identifier_trial_end_date": { - "key": "properties.hierarchyIdentifierTrialEndDate", - "type": "iso-8601", - }, - "environment_name": {"key": "properties.environmentName", "type": "str"}, - "offerings": {"key": "properties.offerings", "type": "[CloudOffering]"}, - "environment_data": {"key": "properties.environmentData", "type": "EnvironmentData"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - hierarchy_identifier: Optional[str] = None, - environment_name: Optional[Union[str, "_models.CloudName"]] = None, - offerings: Optional[List["_models.CloudOffering"]] = None, - environment_data: Optional["_models.EnvironmentData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - :keyword hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector, project number in case of GCP connector). - :paramtype hierarchy_identifier: str - :keyword environment_name: The multi cloud resource's cloud name. Known values are: "Azure", - "AWS", "GCP", "Github", and "AzureDevOps". - :paramtype environment_name: str or ~azure.mgmt.security.v2022_08_01_preview.models.CloudName - :keyword offerings: A collection of offerings for the security connector. - :paramtype offerings: list[~azure.mgmt.security.v2022_08_01_preview.models.CloudOffering] - :keyword environment_data: The security connector environment data. - :paramtype environment_data: ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentData - """ - super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) - self.system_data = None - self.hierarchy_identifier = hierarchy_identifier - self.hierarchy_identifier_trial_end_date = None - self.environment_name = environment_name - self.offerings = offerings - self.environment_data = environment_data - - -class SecurityConnectorsList(_serialization.Model): - """List of security connectors response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of security connectors under the given scope. Required. - :vartype value: list[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityConnector]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.SecurityConnector"], **kwargs: Any) -> None: - """ - :keyword value: The list of security connectors under the given scope. Required. - :paramtype value: list[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = 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.security.v2022_08_01_preview.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.security.v2022_08_01_preview.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.security.v2022_08_01_preview.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.security.v2022_08_01_preview.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 diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_security_center_enums.py deleted file mode 100644 index dfcd185f366a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,85 +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 CloudName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud resource's cloud name.""" - - AZURE = "Azure" - AWS = "AWS" - GCP = "GCP" - GITHUB = "Github" - AZURE_DEV_OPS = "AzureDevOps" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class EnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the environment data.""" - - AWS_ACCOUNT = "AwsAccount" - GCP_PROJECT = "GcpProject" - GITHUB_SCOPE = "GithubScope" - AZURE_DEV_OPS_SCOPE = "AzureDevOpsScope" - - -class OfferingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the security offering.""" - - CSPM_MONITOR_AWS = "CspmMonitorAws" - DEFENDER_FOR_CONTAINERS_AWS = "DefenderForContainersAws" - DEFENDER_FOR_SERVERS_AWS = "DefenderForServersAws" - DEFENDER_FOR_DATABASES_AWS = "DefenderForDatabasesAws" - INFORMATION_PROTECTION_AWS = "InformationProtectionAws" - CSPM_MONITOR_GCP = "CspmMonitorGcp" - CSPM_MONITOR_GITHUB = "CspmMonitorGithub" - CSPM_MONITOR_AZURE_DEV_OPS = "CspmMonitorAzureDevOps" - DEFENDER_FOR_SERVERS_GCP = "DefenderForServersGcp" - DEFENDER_FOR_CONTAINERS_GCP = "DefenderForContainersGcp" - DEFENDER_FOR_DATABASES_GCP = "DefenderForDatabasesGcp" - DEFENDER_CSPM_AWS = "DefenderCspmAws" - DEFENDER_CSPM_GCP = "DefenderCspmGcp" - DEFENDER_FOR_DEV_OPS_GITHUB = "DefenderForDevOpsGithub" - DEFENDER_FOR_DEV_OPS_AZURE_DEV_OPS = "DefenderForDevOpsAzureDevOps" - - -class OrganizationMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud account's membership type in the organization.""" - - MEMBER = "Member" - ORGANIZATION = "Organization" - - -class ScanningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scanning mode for the vm scan.""" - - DEFAULT = "Default" - - -class SubPlan(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The available sub plans.""" - - P1 = "P1" - P2 = "P2" - - -class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or 'Qualys'.""" - - QUALYS = "Qualys" - TVM = "TVM" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/__init__.py deleted file mode 100644 index 8e4ac6c4f04e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py deleted file mode 100644 index dd673b59cbc5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py +++ /dev/null @@ -1,820 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_request( - resource_group_name: str, security_connector_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, security_connector_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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, security_connector_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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, security_connector_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_08_01_preview.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] - :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._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] - :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._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_configuration.py deleted file mode 100644 index 0614502a5f07..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-11-20-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", "2022-11-20-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_metadata.json deleted file mode 100644 index 8297ec3c2498..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2022-11-20-preview", - "total_api_version_list": ["2022-11-20-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "api_collection": "APICollectionOperations", - "api_collection_onboarding": "APICollectionOnboardingOperations", - "api_collection_offboarding": "APICollectionOffboardingOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_security_center.py deleted file mode 100644 index e1bbc4543bde..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_security_center.py +++ /dev/null @@ -1,122 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import APICollectionOffboardingOperations, APICollectionOnboardingOperations, APICollectionOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar api_collection: APICollectionOperations operations - :vartype api_collection: - azure.mgmt.security.v2022_11_20_preview.operations.APICollectionOperations - :ivar api_collection_onboarding: APICollectionOnboardingOperations operations - :vartype api_collection_onboarding: - azure.mgmt.security.v2022_11_20_preview.operations.APICollectionOnboardingOperations - :ivar api_collection_offboarding: APICollectionOffboardingOperations operations - :vartype api_collection_offboarding: - azure.mgmt.security.v2022_11_20_preview.operations.APICollectionOffboardingOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-11-20-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.api_collection = APICollectionOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" - ) - self.api_collection_onboarding = APICollectionOnboardingOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" - ) - self.api_collection_offboarding = APICollectionOffboardingOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_configuration.py deleted file mode 100644 index 047b1726ae66..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-11-20-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", "2022-11-20-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_security_center.py deleted file mode 100644 index 5a0a3a5d0262..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_security_center.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import APICollectionOffboardingOperations, APICollectionOnboardingOperations, APICollectionOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar api_collection: APICollectionOperations operations - :vartype api_collection: - azure.mgmt.security.v2022_11_20_preview.aio.operations.APICollectionOperations - :ivar api_collection_onboarding: APICollectionOnboardingOperations operations - :vartype api_collection_onboarding: - azure.mgmt.security.v2022_11_20_preview.aio.operations.APICollectionOnboardingOperations - :ivar api_collection_offboarding: APICollectionOffboardingOperations operations - :vartype api_collection_offboarding: - azure.mgmt.security.v2022_11_20_preview.aio.operations.APICollectionOffboardingOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-11-20-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.api_collection = APICollectionOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" - ) - self.api_collection_onboarding = APICollectionOnboardingOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" - ) - self.api_collection_offboarding = APICollectionOffboardingOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/__init__.py deleted file mode 100644 index ea2e90603dd0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._api_collection_operations import APICollectionOperations -from ._api_collection_onboarding_operations import APICollectionOnboardingOperations -from ._api_collection_offboarding_operations import APICollectionOffboardingOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "APICollectionOperations", - "APICollectionOnboardingOperations", - "APICollectionOffboardingOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_offboarding_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_offboarding_operations.py deleted file mode 100644 index bd55326d8846..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_offboarding_operations.py +++ /dev/null @@ -1,122 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._api_collection_offboarding_operations import build_delete_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class APICollectionOffboardingOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_11_20_preview.aio.SecurityCenter`'s - :attr:`api_collection_offboarding` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, service_name: str, api_collection_id: str, **kwargs: Any - ) -> None: - """Offboard an Azure API Management API from Defender for APIs. - - Offboard an Azure API Management API from Defender for APIs. The system will stop monitoring - the operations within the Azure API Management API for intrusive behaviors. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_collection_id: A string representing the apiCollections resource within the - Microsoft.Security provider namespace. This string matches the Azure API Management API name. - Required. - :type api_collection_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_collection_id=api_collection_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_onboarding_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_onboarding_operations.py deleted file mode 100644 index f78729e071e0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_onboarding_operations.py +++ /dev/null @@ -1,127 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._api_collection_onboarding_operations import build_create_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class APICollectionOnboardingOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_11_20_preview.aio.SecurityCenter`'s - :attr:`api_collection_onboarding` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def create( - self, resource_group_name: str, service_name: str, api_collection_id: str, **kwargs: Any - ) -> _models.ApiCollectionResponse: - """Onboard an Azure API Management API to Defender for APIs. - - Onboard an Azure API Management API to Defender for APIs. The system will start monitoring the - operations within the Azure Management API for intrusive behaviors and provide alerts for - attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_collection_id: A string representing the apiCollections resource within the - Microsoft.Security provider namespace. This string matches the Azure API Management API name. - Required. - :type api_collection_id: str - :return: ApiCollectionResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_11_20_preview.models.ApiCollectionResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") - ) - cls: ClsType[_models.ApiCollectionResponse] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_collection_id=api_collection_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApiCollectionResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_operations.py deleted file mode 100644 index 8cbe6fa71002..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_operations.py +++ /dev/null @@ -1,226 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._api_collection_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class APICollectionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_11_20_preview.aio.SecurityCenter`'s - :attr:`api_collection` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ApiCollectionResponse"]: - """Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. - - Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. If an - Azure API Management API is onboarded to Defender for APIs, the system will monitor the - operations within the Azure API Management API for intrusive behaviors and provide alerts for - attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :return: An iterator like instance of either ApiCollectionResponse or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_11_20_preview.models.ApiCollectionResponse] - :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._api_version or "2022-11-20-preview") - ) - cls: ClsType[_models.ApiCollectionResponseList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ApiCollectionResponseList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, service_name: str, api_collection_id: str, **kwargs: Any - ) -> _models.ApiCollectionResponse: - """Gets an Azure API Management API if it has been onboarded to Defender for APIs. - - Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API - Management API is onboarded to Defender for APIs, the system will monitor the operations within - the Azure API Management API for intrusive behaviors and provide alerts for attacks that have - been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_collection_id: A string representing the apiCollections resource within the - Microsoft.Security provider namespace. This string matches the Azure API Management API name. - Required. - :type api_collection_id: str - :return: ApiCollectionResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_11_20_preview.models.ApiCollectionResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") - ) - cls: ClsType[_models.ApiCollectionResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_collection_id=api_collection_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApiCollectionResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/models/__init__.py deleted file mode 100644 index 32076ea3803a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/models/__init__.py +++ /dev/null @@ -1,28 +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 ._models_py3 import ApiCollectionResponse -from ._models_py3 import ApiCollectionResponseList -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Resource -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApiCollectionResponse", - "ApiCollectionResponseList", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Resource", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/models/_models_py3.py deleted file mode 100644 index 6252e3b24f62..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/models/_models_py3.py +++ /dev/null @@ -1,215 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ApiCollectionResponse(Resource): - """An API collection as represented by Defender for APIs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: The display name of the Azure API Management API. - :vartype display_name: str - :ivar additional_data: Additional data regarding the API collection. - :vartype additional_data: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "additional_data": {"key": "properties.additionalData", "type": "{str}"}, - } - - def __init__( - self, *, display_name: Optional[str] = None, additional_data: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name of the Azure API Management API. - :paramtype display_name: str - :keyword additional_data: Additional data regarding the API collection. - :paramtype additional_data: dict[str, str] - """ - super().__init__(**kwargs) - self.display_name = display_name - self.additional_data = additional_data - - -class ApiCollectionResponseList(_serialization.Model): - """Page of a list of API collections as represented by Defender for APIs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: API collections in this page. - :vartype value: list[~azure.mgmt.security.v2022_11_20_preview.models.ApiCollectionResponse] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ApiCollectionResponse]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.security.v2022_11_20_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2022_11_20_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.security.v2022_11_20_preview.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.security.v2022_11_20_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/__init__.py deleted file mode 100644 index ea2e90603dd0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/__init__.py +++ /dev/null @@ -1,23 +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 ._api_collection_operations import APICollectionOperations -from ._api_collection_onboarding_operations import APICollectionOnboardingOperations -from ._api_collection_offboarding_operations import APICollectionOffboardingOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "APICollectionOperations", - "APICollectionOnboardingOperations", - "APICollectionOffboardingOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_offboarding_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_offboarding_operations.py deleted file mode 100644 index 8bc3019b533c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_offboarding_operations.py +++ /dev/null @@ -1,166 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_delete_request( - resource_group_name: str, service_name: str, api_collection_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", "2022-11-20-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serviceName": _SERIALIZER.url( - "service_name", - service_name, - "str", - max_length=50, - min_length=1, - pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", - ), - "apiCollectionId": _SERIALIZER.url("api_collection_id", api_collection_id, "str", max_length=256, min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class APICollectionOffboardingOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_11_20_preview.SecurityCenter`'s - :attr:`api_collection_offboarding` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, service_name: str, api_collection_id: str, **kwargs: Any - ) -> None: - """Offboard an Azure API Management API from Defender for APIs. - - Offboard an Azure API Management API from Defender for APIs. The system will stop monitoring - the operations within the Azure API Management API for intrusive behaviors. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_collection_id: A string representing the apiCollections resource within the - Microsoft.Security provider namespace. This string matches the Azure API Management API name. - Required. - :type api_collection_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_collection_id=api_collection_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_onboarding_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_onboarding_operations.py deleted file mode 100644 index bea1903c358d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_onboarding_operations.py +++ /dev/null @@ -1,171 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - resource_group_name: str, service_name: str, api_collection_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", "2022-11-20-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serviceName": _SERIALIZER.url( - "service_name", - service_name, - "str", - max_length=50, - min_length=1, - pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", - ), - "apiCollectionId": _SERIALIZER.url("api_collection_id", api_collection_id, "str", max_length=256, 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class APICollectionOnboardingOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_11_20_preview.SecurityCenter`'s - :attr:`api_collection_onboarding` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def create( - self, resource_group_name: str, service_name: str, api_collection_id: str, **kwargs: Any - ) -> _models.ApiCollectionResponse: - """Onboard an Azure API Management API to Defender for APIs. - - Onboard an Azure API Management API to Defender for APIs. The system will start monitoring the - operations within the Azure Management API for intrusive behaviors and provide alerts for - attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_collection_id: A string representing the apiCollections resource within the - Microsoft.Security provider namespace. This string matches the Azure API Management API name. - Required. - :type api_collection_id: str - :return: ApiCollectionResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_11_20_preview.models.ApiCollectionResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") - ) - cls: ClsType[_models.ApiCollectionResponse] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_collection_id=api_collection_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApiCollectionResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_operations.py deleted file mode 100644 index f26f8a6cf1cc..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_operations.py +++ /dev/null @@ -1,307 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_group_name: str, service_name: str, 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", "2022-11-20-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serviceName": _SERIALIZER.url( - "service_name", - service_name, - "str", - max_length=50, - min_length=1, - pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[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_get_request( - resource_group_name: str, service_name: str, api_collection_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", "2022-11-20-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serviceName": _SERIALIZER.url( - "service_name", - service_name, - "str", - max_length=50, - min_length=1, - pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", - ), - "apiCollectionId": _SERIALIZER.url("api_collection_id", api_collection_id, "str", max_length=256, 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 APICollectionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_11_20_preview.SecurityCenter`'s - :attr:`api_collection` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> Iterable["_models.ApiCollectionResponse"]: - """Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. - - Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. If an - Azure API Management API is onboarded to Defender for APIs, the system will monitor the - operations within the Azure API Management API for intrusive behaviors and provide alerts for - attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :return: An iterator like instance of either ApiCollectionResponse or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_11_20_preview.models.ApiCollectionResponse] - :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._api_version or "2022-11-20-preview") - ) - cls: ClsType[_models.ApiCollectionResponseList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ApiCollectionResponseList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, service_name: str, api_collection_id: str, **kwargs: Any - ) -> _models.ApiCollectionResponse: - """Gets an Azure API Management API if it has been onboarded to Defender for APIs. - - Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API - Management API is onboarded to Defender for APIs, the system will monitor the operations within - the Azure API Management API for intrusive behaviors and provide alerts for attacks that have - been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_collection_id: A string representing the apiCollections resource within the - Microsoft.Security provider namespace. This string matches the Azure API Management API name. - Required. - :type api_collection_id: str - :return: ApiCollectionResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_11_20_preview.models.ApiCollectionResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") - ) - cls: ClsType[_models.ApiCollectionResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_collection_id=api_collection_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApiCollectionResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_configuration.py deleted file mode 100644 index d2ad3f4f1f60..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2022-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-12-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_metadata.json deleted file mode 100644 index 23e59dd321b9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2022-12-01-preview", - "total_api_version_list": ["2022-12-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "defender_for_storage": "DefenderForStorageOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_security_center.py deleted file mode 100644 index 8b2037fbdb75..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_security_center.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import DefenderForStorageOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar defender_for_storage: DefenderForStorageOperations operations - :vartype defender_for_storage: - azure.mgmt.security.v2022_12_01_preview.operations.DefenderForStorageOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.defender_for_storage = DefenderForStorageOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-12-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_configuration.py deleted file mode 100644 index 8845bd7dc76a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2022-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-12-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_security_center.py deleted file mode 100644 index 14c01d5fe23f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_security_center.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import DefenderForStorageOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar defender_for_storage: DefenderForStorageOperations operations - :vartype defender_for_storage: - azure.mgmt.security.v2022_12_01_preview.aio.operations.DefenderForStorageOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.defender_for_storage = DefenderForStorageOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-12-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/__init__.py deleted file mode 100644 index 70d5fc321c3b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._defender_for_storage_operations import DefenderForStorageOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DefenderForStorageOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_defender_for_storage_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_defender_for_storage_operations.py deleted file mode 100644 index 17929b22c132..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_defender_for_storage_operations.py +++ /dev/null @@ -1,251 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._defender_for_storage_operations import build_create_request, build_get_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DefenderForStorageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_12_01_preview.aio.SecurityCenter`'s - :attr:`defender_for_storage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, resource_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any - ) -> _models.DefenderForStorageSetting: - """Gets the Defender for Storage settings for the specified storage account. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param setting_name: Defender for Storage setting name. "current" Required. - :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName - :return: DefenderForStorageSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-12-01-preview") - ) - cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - setting_name=setting_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - resource_id: str, - setting_name: Union[str, _models.SettingName], - defender_for_storage_setting: _models.DefenderForStorageSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DefenderForStorageSetting: - """Creates or updates the Defender for Storage settings on a specified storage account. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param setting_name: Defender for Storage setting name. "current" Required. - :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName - :param defender_for_storage_setting: Defender for Storage Settings. Required. - :type defender_for_storage_setting: - ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DefenderForStorageSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_id: str, - setting_name: Union[str, _models.SettingName], - defender_for_storage_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DefenderForStorageSetting: - """Creates or updates the Defender for Storage settings on a specified storage account. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param setting_name: Defender for Storage setting name. "current" Required. - :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName - :param defender_for_storage_setting: Defender for Storage Settings. Required. - :type defender_for_storage_setting: 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: DefenderForStorageSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_id: str, - setting_name: Union[str, _models.SettingName], - defender_for_storage_setting: Union[_models.DefenderForStorageSetting, IO[bytes]], - **kwargs: Any - ) -> _models.DefenderForStorageSetting: - """Creates or updates the Defender for Storage settings on a specified storage account. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param setting_name: Defender for Storage setting name. "current" Required. - :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName - :param defender_for_storage_setting: Defender for Storage Settings. Is either a - DefenderForStorageSetting type or a IO[bytes] type. Required. - :type defender_for_storage_setting: - ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting or IO[bytes] - :return: DefenderForStorageSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(defender_for_storage_setting, (IOBase, bytes)): - _content = defender_for_storage_setting - else: - _json = self._serialize.body(defender_for_storage_setting, "DefenderForStorageSetting") - - _request = build_create_request( - resource_id=resource_id, - setting_name=setting_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/__init__.py deleted file mode 100644 index cdc4834354ce..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/__init__.py +++ /dev/null @@ -1,29 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import DefenderForStorageSetting -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import OperationStatus -from ._models_py3 import Resource - -from ._security_center_enums import SettingName -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "DefenderForStorageSetting", - "ErrorAdditionalInfo", - "OperationStatus", - "Resource", - "SettingName", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_models_py3.py deleted file mode 100644 index c7f7f0eb8723..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_models_py3.py +++ /dev/null @@ -1,265 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Optional - -from ... import _serialization - - -class CloudErrorBody(_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.security.v2022_12_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2022_12_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DefenderForStorageSetting(Resource): # pylint: disable=too-many-instance-attributes - """The Defender for Storage resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar is_enabled_properties_is_enabled: Indicates whether Defender for Storage is enabled on - this storage account. - :vartype is_enabled_properties_is_enabled: bool - :ivar override_subscription_level_settings: Indicates whether the settings defined for this - storage account should override the settings defined for the subscription. - :vartype override_subscription_level_settings: bool - :ivar is_enabled_properties_sensitive_data_discovery_is_enabled: Indicates whether Sensitive - Data Discovery should be enabled. - :vartype is_enabled_properties_sensitive_data_discovery_is_enabled: bool - :ivar operation_status_properties_sensitive_data_discovery_operation_status: Upon failure or - partial success. Additional data describing Sensitive Data Discovery enable/disable operation. - :vartype operation_status_properties_sensitive_data_discovery_operation_status: - ~azure.mgmt.security.v2022_12_01_preview.models.OperationStatus - :ivar scan_results_event_grid_topic_resource_id: Optional. Resource id of an Event Grid Topic - to send scan results to. - :vartype scan_results_event_grid_topic_resource_id: str - :ivar operation_status_properties_malware_scanning_operation_status: Upon failure or partial - success. Additional data describing Malware Scanning enable/disable operation. - :vartype operation_status_properties_malware_scanning_operation_status: - ~azure.mgmt.security.v2022_12_01_preview.models.OperationStatus - :ivar is_enabled_properties_malware_scanning_on_upload_is_enabled: Indicates whether On Upload - malware scanning should be enabled. - :vartype is_enabled_properties_malware_scanning_on_upload_is_enabled: bool - :ivar cap_gb_per_month: Defines the max GB to be scanned per Month. Set to -1 if no capping is - needed. - :vartype cap_gb_per_month: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "operation_status_properties_sensitive_data_discovery_operation_status": {"readonly": True}, - "operation_status_properties_malware_scanning_operation_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "is_enabled_properties_is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "override_subscription_level_settings": {"key": "properties.overrideSubscriptionLevelSettings", "type": "bool"}, - "is_enabled_properties_sensitive_data_discovery_is_enabled": { - "key": "properties.sensitiveDataDiscovery.isEnabled", - "type": "bool", - }, - "operation_status_properties_sensitive_data_discovery_operation_status": { - "key": "properties.sensitiveDataDiscovery.operationStatus", - "type": "OperationStatus", - }, - "scan_results_event_grid_topic_resource_id": { - "key": "properties.malwareScanning.scanResultsEventGridTopicResourceId", - "type": "str", - }, - "operation_status_properties_malware_scanning_operation_status": { - "key": "properties.malwareScanning.operationStatus", - "type": "OperationStatus", - }, - "is_enabled_properties_malware_scanning_on_upload_is_enabled": { - "key": "properties.malwareScanning.onUpload.isEnabled", - "type": "bool", - }, - "cap_gb_per_month": {"key": "properties.malwareScanning.onUpload.capGBPerMonth", "type": "int"}, - } - - def __init__( - self, - *, - is_enabled_properties_is_enabled: Optional[bool] = None, - override_subscription_level_settings: Optional[bool] = None, - is_enabled_properties_sensitive_data_discovery_is_enabled: Optional[bool] = None, - scan_results_event_grid_topic_resource_id: Optional[str] = None, - is_enabled_properties_malware_scanning_on_upload_is_enabled: Optional[bool] = None, - cap_gb_per_month: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled_properties_is_enabled: Indicates whether Defender for Storage is enabled on - this storage account. - :paramtype is_enabled_properties_is_enabled: bool - :keyword override_subscription_level_settings: Indicates whether the settings defined for this - storage account should override the settings defined for the subscription. - :paramtype override_subscription_level_settings: bool - :keyword is_enabled_properties_sensitive_data_discovery_is_enabled: Indicates whether Sensitive - Data Discovery should be enabled. - :paramtype is_enabled_properties_sensitive_data_discovery_is_enabled: bool - :keyword scan_results_event_grid_topic_resource_id: Optional. Resource id of an Event Grid - Topic to send scan results to. - :paramtype scan_results_event_grid_topic_resource_id: str - :keyword is_enabled_properties_malware_scanning_on_upload_is_enabled: Indicates whether On - Upload malware scanning should be enabled. - :paramtype is_enabled_properties_malware_scanning_on_upload_is_enabled: bool - :keyword cap_gb_per_month: Defines the max GB to be scanned per Month. Set to -1 if no capping - is needed. - :paramtype cap_gb_per_month: int - """ - super().__init__(**kwargs) - self.is_enabled_properties_is_enabled = is_enabled_properties_is_enabled - self.override_subscription_level_settings = override_subscription_level_settings - self.is_enabled_properties_sensitive_data_discovery_is_enabled = ( - is_enabled_properties_sensitive_data_discovery_is_enabled - ) - self.operation_status_properties_sensitive_data_discovery_operation_status = None - self.scan_results_event_grid_topic_resource_id = scan_results_event_grid_topic_resource_id - self.operation_status_properties_malware_scanning_operation_status = None - self.is_enabled_properties_malware_scanning_on_upload_is_enabled = ( - is_enabled_properties_malware_scanning_on_upload_is_enabled - ) - self.cap_gb_per_month = cap_gb_per_month - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class OperationStatus(_serialization.Model): - """A status describing the success/failure of the enablement/disablement operation. - - :ivar code: The operation status code. - :vartype code: str - :ivar message: Additional information regarding the success/failure of the operation. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: The operation status code. - :paramtype code: str - :keyword message: Additional information regarding the success/failure of the operation. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_security_center_enums.py deleted file mode 100644 index f15592b91e90..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,17 +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 SettingName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SettingName.""" - - CURRENT = "current" - """Name of the Defender for Storage Settings name.""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/__init__.py deleted file mode 100644 index 70d5fc321c3b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._defender_for_storage_operations import DefenderForStorageOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DefenderForStorageOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_defender_for_storage_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_defender_for_storage_operations.py deleted file mode 100644 index 5278ac4c8957..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_defender_for_storage_operations.py +++ /dev/null @@ -1,311 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_id: str, setting_name: Union[str, _models.SettingName], **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", "2022-12-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}" - ) - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(resource_id: str, setting_name: Union[str, _models.SettingName], **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", "2022-12-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}" - ) - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "settingName": _SERIALIZER.url("setting_name", setting_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) - - -class DefenderForStorageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2022_12_01_preview.SecurityCenter`'s - :attr:`defender_for_storage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, resource_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any - ) -> _models.DefenderForStorageSetting: - """Gets the Defender for Storage settings for the specified storage account. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param setting_name: Defender for Storage setting name. "current" Required. - :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName - :return: DefenderForStorageSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-12-01-preview") - ) - cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - setting_name=setting_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - resource_id: str, - setting_name: Union[str, _models.SettingName], - defender_for_storage_setting: _models.DefenderForStorageSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DefenderForStorageSetting: - """Creates or updates the Defender for Storage settings on a specified storage account. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param setting_name: Defender for Storage setting name. "current" Required. - :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName - :param defender_for_storage_setting: Defender for Storage Settings. Required. - :type defender_for_storage_setting: - ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DefenderForStorageSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_id: str, - setting_name: Union[str, _models.SettingName], - defender_for_storage_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DefenderForStorageSetting: - """Creates or updates the Defender for Storage settings on a specified storage account. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param setting_name: Defender for Storage setting name. "current" Required. - :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName - :param defender_for_storage_setting: Defender for Storage Settings. Required. - :type defender_for_storage_setting: 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: DefenderForStorageSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_id: str, - setting_name: Union[str, _models.SettingName], - defender_for_storage_setting: Union[_models.DefenderForStorageSetting, IO[bytes]], - **kwargs: Any - ) -> _models.DefenderForStorageSetting: - """Creates or updates the Defender for Storage settings on a specified storage account. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param setting_name: Defender for Storage setting name. "current" Required. - :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName - :param defender_for_storage_setting: Defender for Storage Settings. Is either a - DefenderForStorageSetting type or a IO[bytes] type. Required. - :type defender_for_storage_setting: - ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting or IO[bytes] - :return: DefenderForStorageSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(defender_for_storage_setting, (IOBase, bytes)): - _content = defender_for_storage_setting - else: - _json = self._serialize.body(defender_for_storage_setting, "DefenderForStorageSetting") - - _request = build_create_request( - resource_id=resource_id, - setting_name=setting_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_configuration.py deleted file mode 100644 index 4efa41342de9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_metadata.json deleted file mode 100644 index daa8293ba44e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2023-01-01", - "total_api_version_list": ["2023-01-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "pricings": "PricingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_security_center.py deleted file mode 100644 index 10872f6c272f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_security_center.py +++ /dev/null @@ -1,107 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import PricingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.v2023_01_01.operations.PricingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2023-01-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_configuration.py deleted file mode 100644 index 29c64e686efa..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_security_center.py deleted file mode 100644 index db1a124056f4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_security_center.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import PricingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.v2023_01_01.aio.operations.PricingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2023-01-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/__init__.py deleted file mode 100644 index 3f34d5a48636..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._pricings_operations import PricingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PricingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_pricings_operations.py deleted file mode 100644 index ea064d4bf923..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_pricings_operations.py +++ /dev/null @@ -1,263 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._pricings_operations import build_get_request, build_list_request, build_update_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PricingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_01_01.aio.SecurityCenter`'s - :attr:`pricings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.PricingList: - """Lists Microsoft Defender for Cloud pricing configurations in the subscription. - - :return: PricingList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.PricingList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) - cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PricingList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: - """Gets a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - _request = build_get_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, pricing_name: str, pricing: _models.Pricing, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: ~azure.mgmt.security.v2023_01_01.models.Pricing - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, pricing_name: str, pricing: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: 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: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. - :type pricing: ~azure.mgmt.security.v2023_01_01.models.Pricing or IO[bytes] - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pricing, (IOBase, bytes)): - _content = pricing - else: - _json = self._serialize.body(pricing, "Pricing") - - _request = build_update_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/__init__.py deleted file mode 100644 index 5bedfabf8165..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/__init__.py +++ /dev/null @@ -1,37 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Extension -from ._models_py3 import OperationStatus -from ._models_py3 import Pricing -from ._models_py3 import PricingList -from ._models_py3 import Resource - -from ._security_center_enums import Code -from ._security_center_enums import IsEnabled -from ._security_center_enums import PricingTier -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "ErrorAdditionalInfo", - "Extension", - "OperationStatus", - "Pricing", - "PricingList", - "Resource", - "Code", - "IsEnabled", - "PricingTier", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/_models_py3.py deleted file mode 100644 index 6245cfa369ae..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/_models_py3.py +++ /dev/null @@ -1,350 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CloudErrorBody(_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.security.v2023_01_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2023_01_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class Extension(_serialization.Model): - """A plan's extension properties. - - 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 name: The extension name. Supported values are: :code:`
`:code:`
`\\ - **AgentlessDiscoveryForKubernetes** - API-based discovery of information about Kubernetes - cluster architecture, workload objects, and setup. Required for Kubernetes inventory, identity - and network exposure detection, attack path analysis and risk hunting as part of the cloud - security explorer. - Available for CloudPosture plan.:code:`
`:code:`
`\\ **OnUploadMalwareScanning** - - Limits the GB to be scanned per month for each storage account within the subscription. Once - this limit reached on a given storage account, Blobs won't be scanned during current calendar - month. - Available for StorageAccounts plan.:code:`
`:code:`
`\\ **SensitiveDataDiscovery** - - Sensitive data discovery identifies Blob storage container with sensitive data such as - credentials, credit cards, and more, to help prioritize and investigate security events. - Available for StorageAccounts and CloudPosture plans.:code:`
`:code:`
`\\ - **ContainerRegistriesVulnerabilityAssessments** - Provides vulnerability management for images - stored in your container registries. - Available for CloudPosture and Containers plans. Required. - :vartype name: str - :ivar is_enabled: Indicates whether the extension is enabled. Required. Known values are: - "True" and "False". - :vartype is_enabled: str or ~azure.mgmt.security.v2023_01_01.models.IsEnabled - :ivar additional_extension_properties: Property values associated with the extension. - :vartype additional_extension_properties: dict[str, any] - :ivar operation_status: Optional. A status describing the success/failure of the extension's - enablement/disablement operation. - :vartype operation_status: ~azure.mgmt.security.v2023_01_01.models.OperationStatus - """ - - _validation = { - "name": {"required": True}, - "is_enabled": {"required": True}, - "operation_status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "str"}, - "additional_extension_properties": {"key": "additionalExtensionProperties", "type": "{object}"}, - "operation_status": {"key": "operationStatus", "type": "OperationStatus"}, - } - - def __init__( - self, - *, - name: str, - is_enabled: Union[str, "_models.IsEnabled"], - additional_extension_properties: Optional[Dict[str, Any]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The extension name. Supported values are: :code:`
`:code:`
`\\ - **AgentlessDiscoveryForKubernetes** - API-based discovery of information about Kubernetes - cluster architecture, workload objects, and setup. Required for Kubernetes inventory, identity - and network exposure detection, attack path analysis and risk hunting as part of the cloud - security explorer. - Available for CloudPosture plan.:code:`
`:code:`
`\\ **OnUploadMalwareScanning** - - Limits the GB to be scanned per month for each storage account within the subscription. Once - this limit reached on a given storage account, Blobs won't be scanned during current calendar - month. - Available for StorageAccounts plan.:code:`
`:code:`
`\\ **SensitiveDataDiscovery** - - Sensitive data discovery identifies Blob storage container with sensitive data such as - credentials, credit cards, and more, to help prioritize and investigate security events. - Available for StorageAccounts and CloudPosture plans.:code:`
`:code:`
`\\ - **ContainerRegistriesVulnerabilityAssessments** - Provides vulnerability management for images - stored in your container registries. - Available for CloudPosture and Containers plans. Required. - :paramtype name: str - :keyword is_enabled: Indicates whether the extension is enabled. Required. Known values are: - "True" and "False". - :paramtype is_enabled: str or ~azure.mgmt.security.v2023_01_01.models.IsEnabled - :keyword additional_extension_properties: Property values associated with the extension. - :paramtype additional_extension_properties: dict[str, any] - """ - super().__init__(**kwargs) - self.name = name - self.is_enabled = is_enabled - self.additional_extension_properties = additional_extension_properties - self.operation_status = None - - -class OperationStatus(_serialization.Model): - """A status describing the success/failure of the extension's enablement/disablement operation. - - :ivar code: The operation status code. Known values are: "Succeeded" and "Failed". - :vartype code: str or ~azure.mgmt.security.v2023_01_01.models.Code - :ivar message: Additional information regarding the success/failure of the operation. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[Union[str, "_models.Code"]] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The operation status code. Known values are: "Succeeded" and "Failed". - :paramtype code: str or ~azure.mgmt.security.v2023_01_01.models.Code - :keyword message: Additional information regarding the success/failure of the operation. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Pricing(Resource): - """Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. The standard - tier offers advanced security capabilities, while the free tier offers basic security features. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar pricing_tier: The pricing tier value. Microsoft Defender for Cloud is provided in two - pricing tiers: free and standard. The standard tier offers advanced security capabilities, - while the free tier offers basic security features. Known values are: "Free" and "Standard". - :vartype pricing_tier: str or ~azure.mgmt.security.v2023_01_01.models.PricingTier - :ivar sub_plan: The sub-plan selected for a Standard pricing configuration, when more than one - sub-plan is available. Each sub-plan enables a set of security features. When not specified, - full plan is applied. - :vartype sub_plan: str - :ivar free_trial_remaining_time: The duration left for the subscriptions free trial period - in - ISO 8601 format (e.g. P3Y6M4DT12H30M5S). - :vartype free_trial_remaining_time: ~datetime.timedelta - :ivar enablement_time: Optional. If ``pricingTier`` is ``Standard`` then this property holds - the date of the last time the ``pricingTier`` was set to ``Standard``\\ , when available (e.g - 2023-03-01T12:42:42.1921106Z). - :vartype enablement_time: ~datetime.datetime - :ivar deprecated: Optional. True if the plan is deprecated. If there are replacing plans they - will appear in ``replacedBy`` property. - :vartype deprecated: bool - :ivar replaced_by: Optional. List of plans that replace this plan. This property exists only if - this plan is deprecated. - :vartype replaced_by: list[str] - :ivar extensions: Optional. List of extensions offered under a plan. - :vartype extensions: list[~azure.mgmt.security.v2023_01_01.models.Extension] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "free_trial_remaining_time": {"readonly": True}, - "enablement_time": {"readonly": True}, - "deprecated": {"readonly": True}, - "replaced_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "pricing_tier": {"key": "properties.pricingTier", "type": "str"}, - "sub_plan": {"key": "properties.subPlan", "type": "str"}, - "free_trial_remaining_time": {"key": "properties.freeTrialRemainingTime", "type": "duration"}, - "enablement_time": {"key": "properties.enablementTime", "type": "iso-8601"}, - "deprecated": {"key": "properties.deprecated", "type": "bool"}, - "replaced_by": {"key": "properties.replacedBy", "type": "[str]"}, - "extensions": {"key": "properties.extensions", "type": "[Extension]"}, - } - - def __init__( - self, - *, - pricing_tier: Optional[Union[str, "_models.PricingTier"]] = None, - sub_plan: Optional[str] = None, - extensions: Optional[List["_models.Extension"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword pricing_tier: The pricing tier value. Microsoft Defender for Cloud is provided in two - pricing tiers: free and standard. The standard tier offers advanced security capabilities, - while the free tier offers basic security features. Known values are: "Free" and "Standard". - :paramtype pricing_tier: str or ~azure.mgmt.security.v2023_01_01.models.PricingTier - :keyword sub_plan: The sub-plan selected for a Standard pricing configuration, when more than - one sub-plan is available. Each sub-plan enables a set of security features. When not - specified, full plan is applied. - :paramtype sub_plan: str - :keyword extensions: Optional. List of extensions offered under a plan. - :paramtype extensions: list[~azure.mgmt.security.v2023_01_01.models.Extension] - """ - super().__init__(**kwargs) - self.pricing_tier = pricing_tier - self.sub_plan = sub_plan - self.free_trial_remaining_time = None - self.enablement_time = None - self.deprecated = None - self.replaced_by = None - self.extensions = extensions - - -class PricingList(_serialization.Model): - """List of pricing configurations response. - - All required parameters must be populated in order to send to server. - - :ivar value: List of pricing configurations. Required. - :vartype value: list[~azure.mgmt.security.v2023_01_01.models.Pricing] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Pricing]"}, - } - - def __init__(self, *, value: List["_models.Pricing"], **kwargs: Any) -> None: - """ - :keyword value: List of pricing configurations. Required. - :paramtype value: list[~azure.mgmt.security.v2023_01_01.models.Pricing] - """ - super().__init__(**kwargs) - self.value = value diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/_security_center_enums.py deleted file mode 100644 index 3d5e2d3f1b2f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/models/_security_center_enums.py +++ /dev/null @@ -1,40 +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 Code(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operation status code.""" - - SUCCEEDED = "Succeeded" - """Extension was created/updated successfully.""" - FAILED = "Failed" - """Extension was not created/updated successfully. See operation status message for more details.""" - - -class IsEnabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates whether the extension is enabled.""" - - TRUE = "True" - """Indicates the extension is enabled""" - FALSE = "False" - """Indicates the extension is disabled""" - - -class PricingTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The pricing tier value. Microsoft Defender for Cloud is provided in two pricing tiers: free and - standard. The standard tier offers advanced security capabilities, while the free tier offers - basic security features. - """ - - FREE = "Free" - """Get free Microsoft Defender for Cloud experience with basic security features""" - STANDARD = "Standard" - """Get the standard Microsoft Defender for Cloud experience with advanced security features""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/__init__.py deleted file mode 100644 index 3f34d5a48636..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._pricings_operations import PricingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PricingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_pricings_operations.py deleted file mode 100644 index a2538bf85db1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_pricings_operations.py +++ /dev/null @@ -1,351 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_get_request(pricing_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url("pricing_name", pricing_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_update_request(pricing_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/providers/Microsoft.Security/pricings/{pricingName}" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url("pricing_name", pricing_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) - - -class PricingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_01_01.SecurityCenter`'s - :attr:`pricings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> _models.PricingList: - """Lists Microsoft Defender for Cloud pricing configurations in the subscription. - - :return: PricingList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.PricingList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) - cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PricingList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: - """Gets a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - _request = build_get_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, pricing_name: str, pricing: _models.Pricing, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: ~azure.mgmt.security.v2023_01_01.models.Pricing - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, pricing_name: str, pricing: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: 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: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. - :type pricing: ~azure.mgmt.security.v2023_01_01.models.Pricing or IO[bytes] - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pricing, (IOBase, bytes)): - _content = pricing - else: - _json = self._serialize.body(pricing, "Pricing") - - _request = build_update_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_configuration.py deleted file mode 100644 index 12f8fb070321..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-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", "2023-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_metadata.json deleted file mode 100644 index 732fa39eeafe..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2023-01-01-preview", - "total_api_version_list": ["2023-01-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "security_operators": "SecurityOperatorsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_security_center.py deleted file mode 100644 index f095eba55d83..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_security_center.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityOperatorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_operators: SecurityOperatorsOperations operations - :vartype security_operators: - azure.mgmt.security.v2023_01_01_preview.operations.SecurityOperatorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_operators = SecurityOperatorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-01-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_configuration.py deleted file mode 100644 index 08dd72cb44de..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-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", "2023-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_security_center.py deleted file mode 100644 index 59160bc51594..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_security_center.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityOperatorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_operators: SecurityOperatorsOperations operations - :vartype security_operators: - azure.mgmt.security.v2023_01_01_preview.aio.operations.SecurityOperatorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_operators = SecurityOperatorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-01-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/__init__.py deleted file mode 100644 index ae5a75c1f973..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_operators_operations import SecurityOperatorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityOperatorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_security_operators_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_security_operators_operations.py deleted file mode 100644 index 33d6ca6e79a5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_security_operators_operations.py +++ /dev/null @@ -1,287 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_operators_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityOperatorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_01_01_preview.aio.SecurityCenter`'s - :attr:`security_operators` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list(self, pricing_name: str, **kwargs: Any) -> _models.SecurityOperatorList: - """Lists Microsoft Defender for Cloud securityOperators in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: SecurityOperatorList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01_preview.models.SecurityOperatorList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") - ) - cls: ClsType[_models.SecurityOperatorList] = kwargs.pop("cls", None) - - _request = build_list_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityOperatorList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, pricing_name: str, security_operator_name: str, **kwargs: Any) -> _models.SecurityOperator: - """Get a specific security operator for the requested scope. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param security_operator_name: name of the securityOperator. Required. - :type security_operator_name: str - :return: SecurityOperator or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01_preview.models.SecurityOperator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") - ) - cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) - - _request = build_get_request( - pricing_name=pricing_name, - security_operator_name=security_operator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityOperator", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def create_or_update( - self, pricing_name: str, security_operator_name: str, **kwargs: Any - ) -> _models.SecurityOperator: - """Creates Microsoft Defender for Cloud security operator on the given scope. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param security_operator_name: name of the securityOperator. Required. - :type security_operator_name: str - :return: SecurityOperator or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01_preview.models.SecurityOperator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") - ) - cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) - - _request = build_create_or_update_request( - pricing_name=pricing_name, - security_operator_name=security_operator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityOperator", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, pricing_name: str, security_operator_name: str, **kwargs: Any - ) -> None: - """Delete Microsoft Defender for Cloud securityOperator in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param security_operator_name: name of the securityOperator. Required. - :type security_operator_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - pricing_name=pricing_name, - security_operator_name=security_operator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/models/__init__.py deleted file mode 100644 index 12741b1df5dd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/models/__init__.py +++ /dev/null @@ -1,28 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Identity -from ._models_py3 import Resource -from ._models_py3 import SecurityOperator -from ._models_py3 import SecurityOperatorList -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "ErrorAdditionalInfo", - "Identity", - "Resource", - "SecurityOperator", - "SecurityOperatorList", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/models/_models_py3.py deleted file mode 100644 index dd8d1860f93f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/models/_models_py3.py +++ /dev/null @@ -1,219 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Literal, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CloudErrorBody(_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.security.v2023_01_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2023_01_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class Identity(_serialization.Model): - """Identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :ivar type: The identity type. Default value is "SystemAssigned". - :vartype type: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The identity type. Default value is "SystemAssigned". - :paramtype type: str - """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = type - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class SecurityOperator(Resource): - """Security operator under a given subscription and pricing. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.security.v2023_01_01_preview.models.Identity - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "identity": {"key": "identity", "type": "Identity"}, - } - - def __init__(self, *, identity: Optional["_models.Identity"] = None, **kwargs: Any) -> None: - """ - :keyword identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.security.v2023_01_01_preview.models.Identity - """ - super().__init__(**kwargs) - self.identity = identity - - -class SecurityOperatorList(_serialization.Model): - """List of SecurityOperator response. - - All required parameters must be populated in order to send to server. - - :ivar value: List of SecurityOperator configurations. Required. - :vartype value: list[~azure.mgmt.security.v2023_01_01_preview.models.SecurityOperator] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityOperator]"}, - } - - def __init__(self, *, value: List["_models.SecurityOperator"], **kwargs: Any) -> None: - """ - :keyword value: List of SecurityOperator configurations. Required. - :paramtype value: list[~azure.mgmt.security.v2023_01_01_preview.models.SecurityOperator] - """ - super().__init__(**kwargs) - self.value = value diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/__init__.py deleted file mode 100644 index ae5a75c1f973..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_operators_operations import SecurityOperatorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityOperatorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_security_operators_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_security_operators_operations.py deleted file mode 100644 index eed31c2d85a4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_security_operators_operations.py +++ /dev/null @@ -1,443 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(pricing_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}/securityOperators", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url( - "pricing_name", pricing_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z][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_get_request( - pricing_name: str, security_operator_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}/securityOperators/{securityOperatorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url( - "pricing_name", pricing_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z][a-zA-Z0-9_]+$" - ), - "securityOperatorName": _SERIALIZER.url( - "security_operator_name", - security_operator_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][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( - pricing_name: str, security_operator_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}/securityOperators/{securityOperatorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url( - "pricing_name", pricing_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z][a-zA-Z0-9_]+$" - ), - "securityOperatorName": _SERIALIZER.url( - "security_operator_name", - security_operator_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - pricing_name: str, security_operator_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}/securityOperators/{securityOperatorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "pricingName": _SERIALIZER.url( - "pricing_name", pricing_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z][a-zA-Z0-9_]+$" - ), - "securityOperatorName": _SERIALIZER.url( - "security_operator_name", - security_operator_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][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 SecurityOperatorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_01_01_preview.SecurityCenter`'s - :attr:`security_operators` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, pricing_name: str, **kwargs: Any) -> _models.SecurityOperatorList: - """Lists Microsoft Defender for Cloud securityOperators in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: SecurityOperatorList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01_preview.models.SecurityOperatorList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") - ) - cls: ClsType[_models.SecurityOperatorList] = kwargs.pop("cls", None) - - _request = build_list_request( - pricing_name=pricing_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityOperatorList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, pricing_name: str, security_operator_name: str, **kwargs: Any) -> _models.SecurityOperator: - """Get a specific security operator for the requested scope. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param security_operator_name: name of the securityOperator. Required. - :type security_operator_name: str - :return: SecurityOperator or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01_preview.models.SecurityOperator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") - ) - cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) - - _request = build_get_request( - pricing_name=pricing_name, - security_operator_name=security_operator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityOperator", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def create_or_update( - self, pricing_name: str, security_operator_name: str, **kwargs: Any - ) -> _models.SecurityOperator: - """Creates Microsoft Defender for Cloud security operator on the given scope. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param security_operator_name: name of the securityOperator. Required. - :type security_operator_name: str - :return: SecurityOperator or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_01_01_preview.models.SecurityOperator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") - ) - cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) - - _request = build_create_or_update_request( - pricing_name=pricing_name, - security_operator_name=security_operator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityOperator", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, pricing_name: str, security_operator_name: str, **kwargs: Any - ) -> None: - """Delete Microsoft Defender for Cloud securityOperator in the subscription. - - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param security_operator_name: name of the securityOperator. Required. - :type security_operator_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - pricing_name=pricing_name, - security_operator_name=security_operator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_configuration.py deleted file mode 100644 index 32b71a015a22..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2023-02-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-02-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_metadata.json deleted file mode 100644 index 8e0b861846e7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_metadata.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "chosen_version": "2023-02-01-preview", - "total_api_version_list": ["2023-02-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "health_reports": "HealthReportsOperations", - "health_report": "HealthReportOperations", - "sql_vulnerability_assessment_baseline_rules": "SqlVulnerabilityAssessmentBaselineRulesOperations", - "sql_vulnerability_assessment_scans": "SqlVulnerabilityAssessmentScansOperations", - "sql_vulnerability_assessment_scan_results": "SqlVulnerabilityAssessmentScanResultsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_security_center.py deleted file mode 100644 index 18450b68915a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_security_center.py +++ /dev/null @@ -1,136 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - HealthReportOperations, - HealthReportsOperations, - SqlVulnerabilityAssessmentBaselineRulesOperations, - SqlVulnerabilityAssessmentScanResultsOperations, - SqlVulnerabilityAssessmentScansOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar health_reports: HealthReportsOperations operations - :vartype health_reports: - azure.mgmt.security.v2023_02_01_preview.operations.HealthReportsOperations - :ivar health_report: HealthReportOperations operations - :vartype health_report: - azure.mgmt.security.v2023_02_01_preview.operations.HealthReportOperations - :ivar sql_vulnerability_assessment_baseline_rules: - SqlVulnerabilityAssessmentBaselineRulesOperations operations - :vartype sql_vulnerability_assessment_baseline_rules: - azure.mgmt.security.v2023_02_01_preview.operations.SqlVulnerabilityAssessmentBaselineRulesOperations - :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations - :vartype sql_vulnerability_assessment_scans: - azure.mgmt.security.v2023_02_01_preview.operations.SqlVulnerabilityAssessmentScansOperations - :ivar sql_vulnerability_assessment_scan_results: - SqlVulnerabilityAssessmentScanResultsOperations operations - :vartype sql_vulnerability_assessment_scan_results: - azure.mgmt.security.v2023_02_01_preview.operations.SqlVulnerabilityAssessmentScanResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-02-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.health_reports = HealthReportsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - self.health_report = HealthReportOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_configuration.py deleted file mode 100644 index 48e36a69ecde..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2023-02-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-02-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_security_center.py deleted file mode 100644 index 6ae9c2b1c554..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_security_center.py +++ /dev/null @@ -1,138 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - HealthReportOperations, - HealthReportsOperations, - SqlVulnerabilityAssessmentBaselineRulesOperations, - SqlVulnerabilityAssessmentScanResultsOperations, - SqlVulnerabilityAssessmentScansOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar health_reports: HealthReportsOperations operations - :vartype health_reports: - azure.mgmt.security.v2023_02_01_preview.aio.operations.HealthReportsOperations - :ivar health_report: HealthReportOperations operations - :vartype health_report: - azure.mgmt.security.v2023_02_01_preview.aio.operations.HealthReportOperations - :ivar sql_vulnerability_assessment_baseline_rules: - SqlVulnerabilityAssessmentBaselineRulesOperations operations - :vartype sql_vulnerability_assessment_baseline_rules: - azure.mgmt.security.v2023_02_01_preview.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations - :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations - :vartype sql_vulnerability_assessment_scans: - azure.mgmt.security.v2023_02_01_preview.aio.operations.SqlVulnerabilityAssessmentScansOperations - :ivar sql_vulnerability_assessment_scan_results: - SqlVulnerabilityAssessmentScanResultsOperations operations - :vartype sql_vulnerability_assessment_scan_results: - azure.mgmt.security.v2023_02_01_preview.aio.operations.SqlVulnerabilityAssessmentScanResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-02-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.health_reports = HealthReportsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - self.health_report = HealthReportOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/__init__.py deleted file mode 100644 index b3d96b461304..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,27 +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 ._health_reports_operations import HealthReportsOperations -from ._health_report_operations import HealthReportOperations -from ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations -from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations -from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "HealthReportsOperations", - "HealthReportOperations", - "SqlVulnerabilityAssessmentBaselineRulesOperations", - "SqlVulnerabilityAssessmentScansOperations", - "SqlVulnerabilityAssessmentScanResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_report_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_report_operations.py deleted file mode 100644 index 50cde43370aa..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_report_operations.py +++ /dev/null @@ -1,115 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._health_report_operations import build_get_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HealthReportOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.aio.SecurityCenter`'s - :attr:`health_report` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, resource_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: - """Get health report of resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param health_report_name: The health report Key - Unique key for the health report type. - Required. - :type health_report_name: str - :return: HealthReport or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.HealthReport - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - health_report_name=health_report_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("HealthReport", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_reports_operations.py deleted file mode 100644 index 3792e7b908a4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_reports_operations.py +++ /dev/null @@ -1,143 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._health_reports_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HealthReportsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.aio.SecurityCenter`'s - :attr:`health_reports` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.HealthReport"]: - """Get a list of all health reports inside a scope. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - - :param scope: The scope at which the operation is performed. Required. - :type scope: str - :return: An iterator like instance of either HealthReport or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_02_01_preview.models.HealthReport] - :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._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.HealthReportsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("HealthReportsList", 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) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py deleted file mode 100644 index 170e41db5fb8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ /dev/null @@ -1,528 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._sql_vulnerability_assessment_baseline_rules_operations import ( - build_add_request, - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SqlVulnerabilityAssessmentBaselineRulesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.aio.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_baseline_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[_models.RuleResultsInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. Default value is None. - :type body: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResultsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. 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: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[Union[_models.RuleResultsInput, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. Is either a RuleResultsInput type or a - IO[bytes] type. Default value is None. - :type body: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResultsInput or IO[bytes] - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RuleResultsInput") - else: - _json = None - - _request = build_create_or_update_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RuleResults: - """Gets the results for a given rule in the Baseline. - - Gets the results for a given rule in the Baseline. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) - - _request = build_get_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any - ) -> None: - """Deletes a rule from the Baseline of a given database. - - Deletes a rule from the Baseline of a given database. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RulesResults: - """Gets the results for all rules in the Baseline. - - Gets the results for all rules in the Baseline. - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RulesResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[_models.RulesResultsInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. Default value is None. - :type body: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResultsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. 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: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[Union[_models.RulesResultsInput, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. Is either a RulesResultsInput type or a IO[bytes] type. - Default value is None. - :type body: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResultsInput or IO[bytes] - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RulesResultsInput") - else: - _json = None - - _request = build_add_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RulesResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py deleted file mode 100644 index 3eee82f318ba..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py +++ /dev/null @@ -1,186 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._sql_vulnerability_assessment_scan_results_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SqlVulnerabilityAssessmentScanResultsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.aio.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_scan_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, scan_id: str, scan_result_id: str, workspace_id: str, resource_id: str, **kwargs: Any - ) -> _models.ScanResult: - """Gets the scan results of a single rule in a scan record. - - Gets the scan results of a single rule in a scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. - Required. - :type scan_id: str - :param scan_result_id: The rule Id of the results. Required. - :type scan_result_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: ScanResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.ScanResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) - - _request = build_get_request( - scan_id=scan_id, - scan_result_id=scan_result_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScanResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.ScanResults: - """Gets a list of scan results for a single scan record. - - Gets a list of scan results for a single scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. - Required. - :type scan_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: ScanResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.ScanResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) - - _request = build_list_request( - scan_id=scan_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScanResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py deleted file mode 100644 index a87f3d49fddb..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,177 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._sql_vulnerability_assessment_scans_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.aio.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: - """Gets the scan details of a single scan record. - - Gets the scan details of a single scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan record for the latest scan. - Required. - :type scan_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: Scan or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.Scan - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.Scan] = kwargs.pop("cls", None) - - _request = build_get_request( - scan_id=scan_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Scan", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scans: - """Gets a list of scan records. - - Gets a list of scan records. - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: Scans or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.Scans - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.Scans] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Scans", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/__init__.py deleted file mode 100644 index e9ffba511fbc..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/__init__.py +++ /dev/null @@ -1,91 +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 ._models_py3 import Baseline -from ._models_py3 import BaselineAdjustedResult -from ._models_py3 import BenchmarkReference -from ._models_py3 import CloudErrorBody -from ._models_py3 import EnvironmentDetails -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import HealthDataClassification -from ._models_py3 import HealthReport -from ._models_py3 import HealthReportsList -from ._models_py3 import Issue -from ._models_py3 import QueryCheck -from ._models_py3 import Remediation -from ._models_py3 import Resource -from ._models_py3 import ResourceDetails -from ._models_py3 import RuleResults -from ._models_py3 import RuleResultsInput -from ._models_py3 import RuleResultsProperties -from ._models_py3 import RulesResults -from ._models_py3 import RulesResultsInput -from ._models_py3 import Scan -from ._models_py3 import ScanProperties -from ._models_py3 import ScanResult -from ._models_py3 import ScanResultProperties -from ._models_py3 import ScanResults -from ._models_py3 import Scans -from ._models_py3 import Status -from ._models_py3 import VaRule - -from ._security_center_enums import RuleSeverity -from ._security_center_enums import RuleStatus -from ._security_center_enums import RuleType -from ._security_center_enums import ScanState -from ._security_center_enums import ScanTriggerType -from ._security_center_enums import ScopeName -from ._security_center_enums import Source -from ._security_center_enums import StatusName -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Baseline", - "BaselineAdjustedResult", - "BenchmarkReference", - "CloudErrorBody", - "EnvironmentDetails", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "HealthDataClassification", - "HealthReport", - "HealthReportsList", - "Issue", - "QueryCheck", - "Remediation", - "Resource", - "ResourceDetails", - "RuleResults", - "RuleResultsInput", - "RuleResultsProperties", - "RulesResults", - "RulesResultsInput", - "Scan", - "ScanProperties", - "ScanResult", - "ScanResultProperties", - "ScanResults", - "Scans", - "Status", - "VaRule", - "RuleSeverity", - "RuleStatus", - "RuleType", - "ScanState", - "ScanTriggerType", - "ScopeName", - "Source", - "StatusName", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/_models_py3.py deleted file mode 100644 index b407b24b0c75..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/_models_py3.py +++ /dev/null @@ -1,1277 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Baseline(_serialization.Model): - """Baseline details. - - :ivar expected_results: Expected results. - :vartype expected_results: list[list[str]] - :ivar updated_time: Baseline update time (UTC). - :vartype updated_time: ~datetime.datetime - """ - - _attribute_map = { - "expected_results": {"key": "expectedResults", "type": "[[str]]"}, - "updated_time": {"key": "updatedTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - expected_results: Optional[List[List[str]]] = None, - updated_time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword expected_results: Expected results. - :paramtype expected_results: list[list[str]] - :keyword updated_time: Baseline update time (UTC). - :paramtype updated_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.expected_results = expected_results - self.updated_time = updated_time - - -class BaselineAdjustedResult(_serialization.Model): - """The rule result adjusted with baseline. - - :ivar baseline: Baseline details. - :vartype baseline: ~azure.mgmt.security.v2023_02_01_preview.models.Baseline - :ivar status: The rule result status. Known values are: "NonFinding", "Finding", and - "InternalError". - :vartype status: str or ~azure.mgmt.security.v2023_02_01_preview.models.RuleStatus - :ivar results_not_in_baseline: Results the are not in baseline. - :vartype results_not_in_baseline: list[list[str]] - :ivar results_only_in_baseline: Results the are in baseline. - :vartype results_only_in_baseline: list[list[str]] - """ - - _attribute_map = { - "baseline": {"key": "baseline", "type": "Baseline"}, - "status": {"key": "status", "type": "str"}, - "results_not_in_baseline": {"key": "resultsNotInBaseline", "type": "[[str]]"}, - "results_only_in_baseline": {"key": "resultsOnlyInBaseline", "type": "[[str]]"}, - } - - def __init__( - self, - *, - baseline: Optional["_models.Baseline"] = None, - status: Optional[Union[str, "_models.RuleStatus"]] = None, - results_not_in_baseline: Optional[List[List[str]]] = None, - results_only_in_baseline: Optional[List[List[str]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword baseline: Baseline details. - :paramtype baseline: ~azure.mgmt.security.v2023_02_01_preview.models.Baseline - :keyword status: The rule result status. Known values are: "NonFinding", "Finding", and - "InternalError". - :paramtype status: str or ~azure.mgmt.security.v2023_02_01_preview.models.RuleStatus - :keyword results_not_in_baseline: Results the are not in baseline. - :paramtype results_not_in_baseline: list[list[str]] - :keyword results_only_in_baseline: Results the are in baseline. - :paramtype results_only_in_baseline: list[list[str]] - """ - super().__init__(**kwargs) - self.baseline = baseline - self.status = status - self.results_not_in_baseline = results_not_in_baseline - self.results_only_in_baseline = results_only_in_baseline - - -class BenchmarkReference(_serialization.Model): - """The benchmark references. - - :ivar benchmark: The benchmark name. - :vartype benchmark: str - :ivar reference: The benchmark reference. - :vartype reference: str - """ - - _attribute_map = { - "benchmark": {"key": "benchmark", "type": "str"}, - "reference": {"key": "reference", "type": "str"}, - } - - def __init__(self, *, benchmark: Optional[str] = None, reference: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword benchmark: The benchmark name. - :paramtype benchmark: str - :keyword reference: The benchmark reference. - :paramtype reference: str - """ - super().__init__(**kwargs) - self.benchmark = benchmark - self.reference = reference - - -class CloudErrorBody(_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.security.v2023_02_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2023_02_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class EnvironmentDetails(_serialization.Model): - """The environment details of the resource. - - :ivar native_resource_id: The native resource id of the resource (in case of Azure - the - resource Id, in case of MC - the native resource id). - :vartype native_resource_id: str - :ivar environment_hierarchy_id: The hierarchy id of the connector (in case of Azure - the - subscription Id, in case of MC - the hierarchyId id). - :vartype environment_hierarchy_id: str - :ivar organizational_hierarchy_id: The organizational hierarchy id of the connector (in case of - Azure - the subscription Id, in case of MC - the organizational hierarchyId id). - :vartype organizational_hierarchy_id: str - :ivar subscription_id: The subscription Id. - :vartype subscription_id: str - :ivar tenant_id: The tenant Id. - :vartype tenant_id: str - """ - - _attribute_map = { - "native_resource_id": {"key": "nativeResourceId", "type": "str"}, - "environment_hierarchy_id": {"key": "environmentHierarchyId", "type": "str"}, - "organizational_hierarchy_id": {"key": "organizationalHierarchyId", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - native_resource_id: Optional[str] = None, - environment_hierarchy_id: Optional[str] = None, - organizational_hierarchy_id: Optional[str] = None, - subscription_id: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_resource_id: The native resource id of the resource (in case of Azure - the - resource Id, in case of MC - the native resource id). - :paramtype native_resource_id: str - :keyword environment_hierarchy_id: The hierarchy id of the connector (in case of Azure - the - subscription Id, in case of MC - the hierarchyId id). - :paramtype environment_hierarchy_id: str - :keyword organizational_hierarchy_id: The organizational hierarchy id of the connector (in case - of Azure - the subscription Id, in case of MC - the organizational hierarchyId id). - :paramtype organizational_hierarchy_id: str - :keyword subscription_id: The subscription Id. - :paramtype subscription_id: str - :keyword tenant_id: The tenant Id. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.native_resource_id = native_resource_id - self.environment_hierarchy_id = environment_hierarchy_id - self.organizational_hierarchy_id = organizational_hierarchy_id - self.subscription_id = subscription_id - self.tenant_id = tenant_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 = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.security.v2023_02_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2023_02_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.security.v2023_02_01_preview.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.security.v2023_02_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class HealthDataClassification(_serialization.Model): - """The classification of the health report. - - :ivar component: The component describes the name of the agent/service that scans the issue. - :vartype component: str - :ivar scenario: The scenario describes the health scenario issue of the component. - :vartype scenario: str - :ivar scope: The resource scope of the health report. Known values are: "Connectors", - "Clusters", "VirtualMachines", and "Unknown". - :vartype scope: str or ~azure.mgmt.security.v2023_02_01_preview.models.ScopeName - """ - - _attribute_map = { - "component": {"key": "component", "type": "str"}, - "scenario": {"key": "scenario", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - } - - def __init__( - self, - *, - component: Optional[str] = None, - scenario: Optional[str] = None, - scope: Optional[Union[str, "_models.ScopeName"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword component: The component describes the name of the agent/service that scans the issue. - :paramtype component: str - :keyword scenario: The scenario describes the health scenario issue of the component. - :paramtype scenario: str - :keyword scope: The resource scope of the health report. Known values are: "Connectors", - "Clusters", "VirtualMachines", and "Unknown". - :paramtype scope: str or ~azure.mgmt.security.v2023_02_01_preview.models.ScopeName - """ - super().__init__(**kwargs) - self.component = component - self.scenario = scenario - self.scope = scope - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class HealthReport(Resource): - """The health report resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar resource_details: The resource details of the health report. - :vartype resource_details: ~azure.mgmt.security.v2023_02_01_preview.models.ResourceDetails - :ivar environment_details: The environment details of the resource. - :vartype environment_details: - ~azure.mgmt.security.v2023_02_01_preview.models.EnvironmentDetails - :ivar health_data_classification: The classification of the health report. - :vartype health_data_classification: - ~azure.mgmt.security.v2023_02_01_preview.models.HealthDataClassification - :ivar status: The status of the health report. - :vartype status: ~azure.mgmt.security.v2023_02_01_preview.models.Status - :ivar affected_defenders_plans: The affected defenders plans by unhealthy report. - :vartype affected_defenders_plans: list[str] - :ivar issues: A collection of the issues in the report. - :vartype issues: list[~azure.mgmt.security.v2023_02_01_preview.models.Issue] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, - "environment_details": {"key": "properties.environmentDetails", "type": "EnvironmentDetails"}, - "health_data_classification": { - "key": "properties.healthDataClassification", - "type": "HealthDataClassification", - }, - "status": {"key": "properties.status", "type": "Status"}, - "affected_defenders_plans": {"key": "properties.affectedDefendersPlans", "type": "[str]"}, - "issues": {"key": "properties.issues", "type": "[Issue]"}, - } - - def __init__( - self, - *, - resource_details: Optional["_models.ResourceDetails"] = None, - environment_details: Optional["_models.EnvironmentDetails"] = None, - health_data_classification: Optional["_models.HealthDataClassification"] = None, - status: Optional["_models.Status"] = None, - affected_defenders_plans: Optional[List[str]] = None, - issues: Optional[List["_models.Issue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_details: The resource details of the health report. - :paramtype resource_details: ~azure.mgmt.security.v2023_02_01_preview.models.ResourceDetails - :keyword environment_details: The environment details of the resource. - :paramtype environment_details: - ~azure.mgmt.security.v2023_02_01_preview.models.EnvironmentDetails - :keyword health_data_classification: The classification of the health report. - :paramtype health_data_classification: - ~azure.mgmt.security.v2023_02_01_preview.models.HealthDataClassification - :keyword status: The status of the health report. - :paramtype status: ~azure.mgmt.security.v2023_02_01_preview.models.Status - :keyword affected_defenders_plans: The affected defenders plans by unhealthy report. - :paramtype affected_defenders_plans: list[str] - :keyword issues: A collection of the issues in the report. - :paramtype issues: list[~azure.mgmt.security.v2023_02_01_preview.models.Issue] - """ - super().__init__(**kwargs) - self.resource_details = resource_details - self.environment_details = environment_details - self.health_data_classification = health_data_classification - self.status = status - self.affected_defenders_plans = affected_defenders_plans - self.issues = issues - - -class HealthReportsList(_serialization.Model): - """Page of health reports list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of health reports in this page. - :vartype value: list[~azure.mgmt.security.v2023_02_01_preview.models.HealthReport] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[HealthReport]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class Issue(_serialization.Model): - """The issue that caused the resource to by unhealthy. - - All required parameters must be populated in order to send to server. - - :ivar issue_key: The unique issue key. Required. - :vartype issue_key: str - :ivar issue_name: The issue name. - :vartype issue_name: str - :ivar security_values: The affected security values that MDC offers that will be affected by - the issue, for example: recommendations, alerts, etc. - :vartype security_values: list[str] - :ivar issue_description: The issue description. - :vartype issue_description: str - :ivar remediation_steps: Human readable description of what you should do to mitigate this - health issue. - :vartype remediation_steps: str - :ivar remediation_script: The remediation script to solve this issue. - :vartype remediation_script: str - :ivar issue_additional_data: Additional data for the given issue. The additional data depends - on the issue type. - :vartype issue_additional_data: dict[str, str] - """ - - _validation = { - "issue_key": {"required": True}, - } - - _attribute_map = { - "issue_key": {"key": "issueKey", "type": "str"}, - "issue_name": {"key": "issueName", "type": "str"}, - "security_values": {"key": "securityValues", "type": "[str]"}, - "issue_description": {"key": "issueDescription", "type": "str"}, - "remediation_steps": {"key": "remediationSteps", "type": "str"}, - "remediation_script": {"key": "remediationScript", "type": "str"}, - "issue_additional_data": {"key": "issueAdditionalData", "type": "{str}"}, - } - - def __init__( - self, - *, - issue_key: str, - issue_name: Optional[str] = None, - security_values: Optional[List[str]] = None, - issue_description: Optional[str] = None, - remediation_steps: Optional[str] = None, - remediation_script: Optional[str] = None, - issue_additional_data: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword issue_key: The unique issue key. Required. - :paramtype issue_key: str - :keyword issue_name: The issue name. - :paramtype issue_name: str - :keyword security_values: The affected security values that MDC offers that will be affected by - the issue, for example: recommendations, alerts, etc. - :paramtype security_values: list[str] - :keyword issue_description: The issue description. - :paramtype issue_description: str - :keyword remediation_steps: Human readable description of what you should do to mitigate this - health issue. - :paramtype remediation_steps: str - :keyword remediation_script: The remediation script to solve this issue. - :paramtype remediation_script: str - :keyword issue_additional_data: Additional data for the given issue. The additional data - depends on the issue type. - :paramtype issue_additional_data: dict[str, str] - """ - super().__init__(**kwargs) - self.issue_key = issue_key - self.issue_name = issue_name - self.security_values = security_values - self.issue_description = issue_description - self.remediation_steps = remediation_steps - self.remediation_script = remediation_script - self.issue_additional_data = issue_additional_data - - -class QueryCheck(_serialization.Model): - """The rule query details. - - :ivar query: The rule query. - :vartype query: str - :ivar expected_result: Expected result. - :vartype expected_result: list[list[str]] - :ivar column_names: Column names of expected result. - :vartype column_names: list[str] - """ - - _attribute_map = { - "query": {"key": "query", "type": "str"}, - "expected_result": {"key": "expectedResult", "type": "[[str]]"}, - "column_names": {"key": "columnNames", "type": "[str]"}, - } - - def __init__( - self, - *, - query: Optional[str] = None, - expected_result: Optional[List[List[str]]] = None, - column_names: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword query: The rule query. - :paramtype query: str - :keyword expected_result: Expected result. - :paramtype expected_result: list[list[str]] - :keyword column_names: Column names of expected result. - :paramtype column_names: list[str] - """ - super().__init__(**kwargs) - self.query = query - self.expected_result = expected_result - self.column_names = column_names - - -class Remediation(_serialization.Model): - """Remediation details. - - :ivar description: Remediation description. - :vartype description: str - :ivar scripts: Remediation script. - :vartype scripts: list[str] - :ivar automated: Is remediation automated. - :vartype automated: bool - :ivar portal_link: Optional link to remediate in Azure Portal. - :vartype portal_link: str - """ - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "scripts": {"key": "scripts", "type": "[str]"}, - "automated": {"key": "automated", "type": "bool"}, - "portal_link": {"key": "portalLink", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - scripts: Optional[List[str]] = None, - automated: Optional[bool] = None, - portal_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Remediation description. - :paramtype description: str - :keyword scripts: Remediation script. - :paramtype scripts: list[str] - :keyword automated: Is remediation automated. - :paramtype automated: bool - :keyword portal_link: Optional link to remediate in Azure Portal. - :paramtype portal_link: str - """ - super().__init__(**kwargs) - self.description = description - self.scripts = scripts - self.automated = automated - self.portal_link = portal_link - - -class ResourceDetails(_serialization.Model): - """The resource details of the health report. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar source: The status of the health report. Known values are: "Aws", "Gcp", and "Azure". - :vartype source: str or ~azure.mgmt.security.v2023_02_01_preview.models.Source - :ivar id: The azure id of the resource. - :vartype id: str - :ivar connector_id: The id of the connector. - :vartype connector_id: str - """ - - _validation = { - "id": {"readonly": True}, - "connector_id": {"readonly": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "connector_id": {"key": "connectorId", "type": "str"}, - } - - def __init__(self, *, source: Optional[Union[str, "_models.Source"]] = None, **kwargs: Any) -> None: - """ - :keyword source: The status of the health report. Known values are: "Aws", "Gcp", and "Azure". - :paramtype source: str or ~azure.mgmt.security.v2023_02_01_preview.models.Source - """ - super().__init__(**kwargs) - self.source = source - self.id = None - self.connector_id = None - - -class RuleResults(Resource): - """Rule results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: Rule results properties. - :vartype properties: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResultsProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "RuleResultsProperties"}, - } - - def __init__(self, *, properties: Optional["_models.RuleResultsProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Rule results properties. - :paramtype properties: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResultsProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class RuleResultsInput(_serialization.Model): - """Rule results input. - - :ivar latest_scan: Take results from latest scan. - :vartype latest_scan: bool - :ivar results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :vartype results: list[list[str]] - """ - - _attribute_map = { - "latest_scan": {"key": "latestScan", "type": "bool"}, - "results": {"key": "results", "type": "[[str]]"}, - } - - def __init__( - self, *, latest_scan: Optional[bool] = None, results: Optional[List[List[str]]] = None, **kwargs: Any - ) -> None: - """ - :keyword latest_scan: Take results from latest scan. - :paramtype latest_scan: bool - :keyword results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :paramtype results: list[list[str]] - """ - super().__init__(**kwargs) - self.latest_scan = latest_scan - self.results = results - - -class RuleResultsProperties(_serialization.Model): - """Rule results properties. - - :ivar results: Expected results in the baseline. - :vartype results: list[list[str]] - """ - - _attribute_map = { - "results": {"key": "results", "type": "[[str]]"}, - } - - def __init__(self, *, results: Optional[List[List[str]]] = None, **kwargs: Any) -> None: - """ - :keyword results: Expected results in the baseline. - :paramtype results: list[list[str]] - """ - super().__init__(**kwargs) - self.results = results - - -class RulesResults(_serialization.Model): - """A list of rules results. - - :ivar value: List of rule results. - :vartype value: list[~azure.mgmt.security.v2023_02_01_preview.models.RuleResults] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RuleResults]"}, - } - - def __init__(self, *, value: Optional[List["_models.RuleResults"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of rule results. - :paramtype value: list[~azure.mgmt.security.v2023_02_01_preview.models.RuleResults] - """ - super().__init__(**kwargs) - self.value = value - - -class RulesResultsInput(_serialization.Model): - """Rules results input. - - :ivar latest_scan: Take results from latest scan. - :vartype latest_scan: bool - :ivar results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :vartype results: dict[str, list[list[str]]] - """ - - _attribute_map = { - "latest_scan": {"key": "latestScan", "type": "bool"}, - "results": {"key": "results", "type": "{[[str]]}"}, - } - - def __init__( - self, *, latest_scan: Optional[bool] = None, results: Optional[Dict[str, List[List[str]]]] = None, **kwargs: Any - ) -> None: - """ - :keyword latest_scan: Take results from latest scan. - :paramtype latest_scan: bool - :keyword results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :paramtype results: dict[str, list[list[str]]] - """ - super().__init__(**kwargs) - self.latest_scan = latest_scan - self.results = results - - -class Scan(Resource): - """A vulnerability assessment scan record. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: A vulnerability assessment scan record properties. - :vartype properties: ~azure.mgmt.security.v2023_02_01_preview.models.ScanProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "ScanProperties"}, - } - - def __init__(self, *, properties: Optional["_models.ScanProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: A vulnerability assessment scan record properties. - :paramtype properties: ~azure.mgmt.security.v2023_02_01_preview.models.ScanProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class ScanProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """A vulnerability assessment scan record properties. - - :ivar trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". - :vartype trigger_type: str or ~azure.mgmt.security.v2023_02_01_preview.models.ScanTriggerType - :ivar state: The scan status. Known values are: "Failed", "FailedToRun", "InProgress", and - "Passed". - :vartype state: str or ~azure.mgmt.security.v2023_02_01_preview.models.ScanState - :ivar server: The server name. - :vartype server: str - :ivar database: The database name. - :vartype database: str - :ivar sql_version: The SQL version. - :vartype sql_version: str - :ivar start_time: The scan start time (UTC). - :vartype start_time: ~datetime.datetime - :ivar end_time: Scan results are valid until end time (UTC). - :vartype end_time: ~datetime.datetime - :ivar high_severity_failed_rules_count: The number of failed rules with high severity. - :vartype high_severity_failed_rules_count: int - :ivar medium_severity_failed_rules_count: The number of failed rules with medium severity. - :vartype medium_severity_failed_rules_count: int - :ivar low_severity_failed_rules_count: The number of failed rules with low severity. - :vartype low_severity_failed_rules_count: int - :ivar total_passed_rules_count: The number of total passed rules. - :vartype total_passed_rules_count: int - :ivar total_failed_rules_count: The number of total failed rules. - :vartype total_failed_rules_count: int - :ivar total_rules_count: The number of total rules assessed. - :vartype total_rules_count: int - :ivar is_baseline_applied: Baseline created for this database, and has one or more rules. - :vartype is_baseline_applied: bool - :ivar last_scan_time: Last scan time. - :vartype last_scan_time: ~datetime.datetime - """ - - _attribute_map = { - "trigger_type": {"key": "triggerType", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "server": {"key": "server", "type": "str"}, - "database": {"key": "database", "type": "str"}, - "sql_version": {"key": "sqlVersion", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "high_severity_failed_rules_count": {"key": "highSeverityFailedRulesCount", "type": "int"}, - "medium_severity_failed_rules_count": {"key": "mediumSeverityFailedRulesCount", "type": "int"}, - "low_severity_failed_rules_count": {"key": "lowSeverityFailedRulesCount", "type": "int"}, - "total_passed_rules_count": {"key": "totalPassedRulesCount", "type": "int"}, - "total_failed_rules_count": {"key": "totalFailedRulesCount", "type": "int"}, - "total_rules_count": {"key": "totalRulesCount", "type": "int"}, - "is_baseline_applied": {"key": "isBaselineApplied", "type": "bool"}, - "last_scan_time": {"key": "lastScanTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - trigger_type: Optional[Union[str, "_models.ScanTriggerType"]] = None, - state: Optional[Union[str, "_models.ScanState"]] = None, - server: Optional[str] = None, - database: Optional[str] = None, - sql_version: Optional[str] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - high_severity_failed_rules_count: Optional[int] = None, - medium_severity_failed_rules_count: Optional[int] = None, - low_severity_failed_rules_count: Optional[int] = None, - total_passed_rules_count: Optional[int] = None, - total_failed_rules_count: Optional[int] = None, - total_rules_count: Optional[int] = None, - is_baseline_applied: Optional[bool] = None, - last_scan_time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". - :paramtype trigger_type: str or ~azure.mgmt.security.v2023_02_01_preview.models.ScanTriggerType - :keyword state: The scan status. Known values are: "Failed", "FailedToRun", "InProgress", and - "Passed". - :paramtype state: str or ~azure.mgmt.security.v2023_02_01_preview.models.ScanState - :keyword server: The server name. - :paramtype server: str - :keyword database: The database name. - :paramtype database: str - :keyword sql_version: The SQL version. - :paramtype sql_version: str - :keyword start_time: The scan start time (UTC). - :paramtype start_time: ~datetime.datetime - :keyword end_time: Scan results are valid until end time (UTC). - :paramtype end_time: ~datetime.datetime - :keyword high_severity_failed_rules_count: The number of failed rules with high severity. - :paramtype high_severity_failed_rules_count: int - :keyword medium_severity_failed_rules_count: The number of failed rules with medium severity. - :paramtype medium_severity_failed_rules_count: int - :keyword low_severity_failed_rules_count: The number of failed rules with low severity. - :paramtype low_severity_failed_rules_count: int - :keyword total_passed_rules_count: The number of total passed rules. - :paramtype total_passed_rules_count: int - :keyword total_failed_rules_count: The number of total failed rules. - :paramtype total_failed_rules_count: int - :keyword total_rules_count: The number of total rules assessed. - :paramtype total_rules_count: int - :keyword is_baseline_applied: Baseline created for this database, and has one or more rules. - :paramtype is_baseline_applied: bool - :keyword last_scan_time: Last scan time. - :paramtype last_scan_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.trigger_type = trigger_type - self.state = state - self.server = server - self.database = database - self.sql_version = sql_version - self.start_time = start_time - self.end_time = end_time - self.high_severity_failed_rules_count = high_severity_failed_rules_count - self.medium_severity_failed_rules_count = medium_severity_failed_rules_count - self.low_severity_failed_rules_count = low_severity_failed_rules_count - self.total_passed_rules_count = total_passed_rules_count - self.total_failed_rules_count = total_failed_rules_count - self.total_rules_count = total_rules_count - self.is_baseline_applied = is_baseline_applied - self.last_scan_time = last_scan_time - - -class ScanResult(Resource): - """A vulnerability assessment scan result for a single rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: A vulnerability assessment scan result properties for a single rule. - :vartype properties: ~azure.mgmt.security.v2023_02_01_preview.models.ScanResultProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "ScanResultProperties"}, - } - - def __init__(self, *, properties: Optional["_models.ScanResultProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: A vulnerability assessment scan result properties for a single rule. - :paramtype properties: ~azure.mgmt.security.v2023_02_01_preview.models.ScanResultProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class ScanResultProperties(_serialization.Model): - """A vulnerability assessment scan result properties for a single rule. - - :ivar rule_id: The rule Id. - :vartype rule_id: str - :ivar status: The rule result status. Known values are: "NonFinding", "Finding", and - "InternalError". - :vartype status: str or ~azure.mgmt.security.v2023_02_01_preview.models.RuleStatus - :ivar is_trimmed: Indicated whether the results specified here are trimmed. - :vartype is_trimmed: bool - :ivar query_results: The results of the query that was run. - :vartype query_results: list[list[str]] - :ivar remediation: Remediation details. - :vartype remediation: ~azure.mgmt.security.v2023_02_01_preview.models.Remediation - :ivar baseline_adjusted_result: The rule result adjusted with baseline. - :vartype baseline_adjusted_result: - ~azure.mgmt.security.v2023_02_01_preview.models.BaselineAdjustedResult - :ivar rule_metadata: vulnerability assessment rule metadata details. - :vartype rule_metadata: ~azure.mgmt.security.v2023_02_01_preview.models.VaRule - """ - - _attribute_map = { - "rule_id": {"key": "ruleId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "is_trimmed": {"key": "isTrimmed", "type": "bool"}, - "query_results": {"key": "queryResults", "type": "[[str]]"}, - "remediation": {"key": "remediation", "type": "Remediation"}, - "baseline_adjusted_result": {"key": "baselineAdjustedResult", "type": "BaselineAdjustedResult"}, - "rule_metadata": {"key": "ruleMetadata", "type": "VaRule"}, - } - - def __init__( - self, - *, - rule_id: Optional[str] = None, - status: Optional[Union[str, "_models.RuleStatus"]] = None, - is_trimmed: Optional[bool] = None, - query_results: Optional[List[List[str]]] = None, - remediation: Optional["_models.Remediation"] = None, - baseline_adjusted_result: Optional["_models.BaselineAdjustedResult"] = None, - rule_metadata: Optional["_models.VaRule"] = None, - **kwargs: Any - ) -> None: - """ - :keyword rule_id: The rule Id. - :paramtype rule_id: str - :keyword status: The rule result status. Known values are: "NonFinding", "Finding", and - "InternalError". - :paramtype status: str or ~azure.mgmt.security.v2023_02_01_preview.models.RuleStatus - :keyword is_trimmed: Indicated whether the results specified here are trimmed. - :paramtype is_trimmed: bool - :keyword query_results: The results of the query that was run. - :paramtype query_results: list[list[str]] - :keyword remediation: Remediation details. - :paramtype remediation: ~azure.mgmt.security.v2023_02_01_preview.models.Remediation - :keyword baseline_adjusted_result: The rule result adjusted with baseline. - :paramtype baseline_adjusted_result: - ~azure.mgmt.security.v2023_02_01_preview.models.BaselineAdjustedResult - :keyword rule_metadata: vulnerability assessment rule metadata details. - :paramtype rule_metadata: ~azure.mgmt.security.v2023_02_01_preview.models.VaRule - """ - super().__init__(**kwargs) - self.rule_id = rule_id - self.status = status - self.is_trimmed = is_trimmed - self.query_results = query_results - self.remediation = remediation - self.baseline_adjusted_result = baseline_adjusted_result - self.rule_metadata = rule_metadata - - -class ScanResults(_serialization.Model): - """A list of vulnerability assessment scan results. - - :ivar value: List of vulnerability assessment scan results. - :vartype value: list[~azure.mgmt.security.v2023_02_01_preview.models.ScanResult] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ScanResult]"}, - } - - def __init__(self, *, value: Optional[List["_models.ScanResult"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of vulnerability assessment scan results. - :paramtype value: list[~azure.mgmt.security.v2023_02_01_preview.models.ScanResult] - """ - super().__init__(**kwargs) - self.value = value - - -class Scans(_serialization.Model): - """A list of vulnerability assessment scan records. - - :ivar value: List of vulnerability assessment scan records. - :vartype value: list[~azure.mgmt.security.v2023_02_01_preview.models.Scan] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Scan]"}, - } - - def __init__(self, *, value: Optional[List["_models.Scan"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of vulnerability assessment scan records. - :paramtype value: list[~azure.mgmt.security.v2023_02_01_preview.models.Scan] - """ - super().__init__(**kwargs) - self.value = value - - -class Status(_serialization.Model): - """The status of the health report. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The status of the health report. Known values are: "Healthy", "NotHealthy", and - "NotApplicable". - :vartype code: str or ~azure.mgmt.security.v2023_02_01_preview.models.StatusName - :ivar status_change_date: The date of when the status of the health report was changed in the - last time. - :vartype status_change_date: ~datetime.datetime - :ivar first_evaluation_date: The date of when the resource of the health report was scanned in - the first time. - :vartype first_evaluation_date: ~datetime.datetime - """ - - _validation = { - "status_change_date": {"readonly": True}, - "first_evaluation_date": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "status_change_date": {"key": "statusChangeDate", "type": "iso-8601"}, - "first_evaluation_date": {"key": "firstEvaluationDate", "type": "iso-8601"}, - } - - def __init__(self, *, code: Optional[Union[str, "_models.StatusName"]] = None, **kwargs: Any) -> None: - """ - :keyword code: The status of the health report. Known values are: "Healthy", "NotHealthy", and - "NotApplicable". - :paramtype code: str or ~azure.mgmt.security.v2023_02_01_preview.models.StatusName - """ - super().__init__(**kwargs) - self.code = code - self.status_change_date = None - self.first_evaluation_date = None - - -class VaRule(_serialization.Model): - """vulnerability assessment rule metadata details. - - :ivar rule_id: The rule Id. - :vartype rule_id: str - :ivar severity: The rule severity. Known values are: "High", "Medium", "Low", "Informational", - and "Obsolete". - :vartype severity: str or ~azure.mgmt.security.v2023_02_01_preview.models.RuleSeverity - :ivar category: The rule category. - :vartype category: str - :ivar rule_type: The rule type. Known values are: "Binary", "BaselineExpected", "PositiveList", - and "NegativeList". - :vartype rule_type: str or ~azure.mgmt.security.v2023_02_01_preview.models.RuleType - :ivar title: The rule title. - :vartype title: str - :ivar description: The rule description. - :vartype description: str - :ivar rationale: The rule rationale. - :vartype rationale: str - :ivar query_check: The rule query details. - :vartype query_check: ~azure.mgmt.security.v2023_02_01_preview.models.QueryCheck - :ivar benchmark_references: The benchmark references. - :vartype benchmark_references: - list[~azure.mgmt.security.v2023_02_01_preview.models.BenchmarkReference] - """ - - _attribute_map = { - "rule_id": {"key": "ruleId", "type": "str"}, - "severity": {"key": "severity", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "rationale": {"key": "rationale", "type": "str"}, - "query_check": {"key": "queryCheck", "type": "QueryCheck"}, - "benchmark_references": {"key": "benchmarkReferences", "type": "[BenchmarkReference]"}, - } - - def __init__( - self, - *, - rule_id: Optional[str] = None, - severity: Optional[Union[str, "_models.RuleSeverity"]] = None, - category: Optional[str] = None, - rule_type: Optional[Union[str, "_models.RuleType"]] = None, - title: Optional[str] = None, - description: Optional[str] = None, - rationale: Optional[str] = None, - query_check: Optional["_models.QueryCheck"] = None, - benchmark_references: Optional[List["_models.BenchmarkReference"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword rule_id: The rule Id. - :paramtype rule_id: str - :keyword severity: The rule severity. Known values are: "High", "Medium", "Low", - "Informational", and "Obsolete". - :paramtype severity: str or ~azure.mgmt.security.v2023_02_01_preview.models.RuleSeverity - :keyword category: The rule category. - :paramtype category: str - :keyword rule_type: The rule type. Known values are: "Binary", "BaselineExpected", - "PositiveList", and "NegativeList". - :paramtype rule_type: str or ~azure.mgmt.security.v2023_02_01_preview.models.RuleType - :keyword title: The rule title. - :paramtype title: str - :keyword description: The rule description. - :paramtype description: str - :keyword rationale: The rule rationale. - :paramtype rationale: str - :keyword query_check: The rule query details. - :paramtype query_check: ~azure.mgmt.security.v2023_02_01_preview.models.QueryCheck - :keyword benchmark_references: The benchmark references. - :paramtype benchmark_references: - list[~azure.mgmt.security.v2023_02_01_preview.models.BenchmarkReference] - """ - super().__init__(**kwargs) - self.rule_id = rule_id - self.severity = severity - self.category = category - self.rule_type = rule_type - self.title = title - self.description = description - self.rationale = rationale - self.query_check = query_check - self.benchmark_references = benchmark_references diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/_security_center_enums.py deleted file mode 100644 index fc16589ddce5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,96 +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 RuleSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rule severity.""" - - HIGH = "High" - """High""" - MEDIUM = "Medium" - """Medium""" - LOW = "Low" - """Low""" - INFORMATIONAL = "Informational" - """Informational""" - OBSOLETE = "Obsolete" - """Obsolete""" - - -class RuleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rule result status.""" - - NON_FINDING = "NonFinding" - """NonFinding""" - FINDING = "Finding" - """Finding""" - INTERNAL_ERROR = "InternalError" - """InternalError""" - - -class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rule type.""" - - BINARY = "Binary" - """Binary""" - BASELINE_EXPECTED = "BaselineExpected" - """BaselineExpected""" - POSITIVE_LIST = "PositiveList" - """PositiveList""" - NEGATIVE_LIST = "NegativeList" - """NegativeList""" - - -class ScanState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scan status.""" - - FAILED = "Failed" - """Failed""" - FAILED_TO_RUN = "FailedToRun" - """FailedToRun""" - IN_PROGRESS = "InProgress" - """InProgress""" - PASSED = "Passed" - """Passed""" - - -class ScanTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scan trigger type.""" - - ON_DEMAND = "OnDemand" - """OnDemand""" - RECURRING = "Recurring" - """Recurring""" - - -class ScopeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource scope of the health report.""" - - CONNECTORS = "Connectors" - CLUSTERS = "Clusters" - VIRTUAL_MACHINES = "VirtualMachines" - UNKNOWN = "Unknown" - - -class Source(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the health report.""" - - AWS = "Aws" - GCP = "Gcp" - AZURE = "Azure" - - -class StatusName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the health report.""" - - HEALTHY = "Healthy" - NOT_HEALTHY = "NotHealthy" - NOT_APPLICABLE = "NotApplicable" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/__init__.py deleted file mode 100644 index b3d96b461304..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/__init__.py +++ /dev/null @@ -1,27 +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 ._health_reports_operations import HealthReportsOperations -from ._health_report_operations import HealthReportOperations -from ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations -from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations -from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "HealthReportsOperations", - "HealthReportOperations", - "SqlVulnerabilityAssessmentBaselineRulesOperations", - "SqlVulnerabilityAssessmentScansOperations", - "SqlVulnerabilityAssessmentScanResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_report_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_report_operations.py deleted file mode 100644 index 06b9958e3a9b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_report_operations.py +++ /dev/null @@ -1,148 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_id: str, health_report_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/healthReports/{healthReportName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "healthReportName": _SERIALIZER.url( - "health_report_name", - health_report_name, - "str", - pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{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) - - -class HealthReportOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.SecurityCenter`'s - :attr:`health_report` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, resource_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: - """Get health report of resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param health_report_name: The health report Key - Unique key for the health report type. - Required. - :type health_report_name: str - :return: HealthReport or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.HealthReport - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - health_report_name=health_report_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("HealthReport", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_reports_operations.py deleted file mode 100644 index 3d02f6894d92..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_reports_operations.py +++ /dev/null @@ -1,170 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/healthReports") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True, 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 HealthReportsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.SecurityCenter`'s - :attr:`health_reports` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> Iterable["_models.HealthReport"]: - """Get a list of all health reports inside a scope. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - - :param scope: The scope at which the operation is performed. Required. - :type scope: str - :return: An iterator like instance of either HealthReport or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_02_01_preview.models.HealthReport] - :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._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.HealthReportsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("HealthReportsList", 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) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py deleted file mode 100644 index 771e6fc8b643..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ /dev/null @@ -1,672 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request(rule_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(rule_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(rule_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _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_add_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class SqlVulnerabilityAssessmentBaselineRulesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_baseline_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[_models.RuleResultsInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. Default value is None. - :type body: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResultsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. 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: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional[Union[_models.RuleResultsInput, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.RuleResults: - """Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline results for this rule. Is either a RuleResultsInput type or a - IO[bytes] type. Default value is None. - :type body: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResultsInput or IO[bytes] - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RuleResultsInput") - else: - _json = None - - _request = build_create_or_update_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RuleResults: - """Gets the results for a given rule in the Baseline. - - Gets the results for a given rule in the Baseline. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: RuleResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RuleResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) - - _request = build_get_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any - ) -> None: - """Deletes a rule from the Baseline of a given database. - - Deletes a rule from the Baseline of a given database. - - :param rule_id: The rule Id. Required. - :type rule_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - rule_id=rule_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.RulesResults: - """Gets the results for all rules in the Baseline. - - Gets the results for all rules in the Baseline. - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RulesResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[_models.RulesResultsInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. Default value is None. - :type body: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResultsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. 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: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def add( - self, - workspace_id: str, - resource_id: str, - body: Optional[Union[_models.RulesResultsInput, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.RulesResults: - """Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param body: The baseline rules. Is either a RulesResultsInput type or a IO[bytes] type. - Default value is None. - :type body: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResultsInput or IO[bytes] - :return: RulesResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.RulesResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RulesResultsInput") - else: - _json = None - - _request = build_add_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RulesResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py deleted file mode 100644 index 3833610cf451..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py +++ /dev/null @@ -1,250 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - scan_id: str, scan_result_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults/{scanResultId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "scanResultId": _SERIALIZER.url("scan_result_id", scan_result_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(scan_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _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 SqlVulnerabilityAssessmentScanResultsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_scan_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, scan_id: str, scan_result_id: str, workspace_id: str, resource_id: str, **kwargs: Any - ) -> _models.ScanResult: - """Gets the scan results of a single rule in a scan record. - - Gets the scan results of a single rule in a scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. - Required. - :type scan_id: str - :param scan_result_id: The rule Id of the results. Required. - :type scan_result_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: ScanResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.ScanResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) - - _request = build_get_request( - scan_id=scan_id, - scan_result_id=scan_result_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScanResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.ScanResults: - """Gets a list of scan results for a single scan record. - - Gets a list of scan results for a single scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan results for the latest scan. - Required. - :type scan_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: ScanResults or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.ScanResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) - - _request = build_list_request( - scan_id=scan_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScanResults", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py deleted file mode 100644 index 62d8085b48b6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,235 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(scan_id: str, resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans" - ) - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") - _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 SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_01_preview.SecurityCenter`'s - :attr:`sql_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: - """Gets the scan details of a single scan record. - - Gets the scan details of a single scan record. - - :param scan_id: The scan Id. Type 'latest' to get the scan record for the latest scan. - Required. - :type scan_id: str - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: Scan or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.Scan - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.Scan] = kwargs.pop("cls", None) - - _request = build_get_request( - scan_id=scan_id, - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Scan", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scans: - """Gets a list of scan records. - - Gets a list of scan records. - - :param workspace_id: The workspace Id. Required. - :type workspace_id: str - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :return: Scans or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_01_preview.models.Scans - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") - ) - cls: ClsType[_models.Scans] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_id=resource_id, - workspace_id=workspace_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Scans", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_configuration.py deleted file mode 100644 index 1a9cd3d81377..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2023-02-15-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-02-15-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_metadata.json deleted file mode 100644 index d85af68fc873..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2023-02-15-preview", - "total_api_version_list": ["2023-02-15-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "sensitivity_settings": "SensitivitySettingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_security_center.py deleted file mode 100644 index 3d050c7ce348..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_security_center.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SensitivitySettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar sensitivity_settings: SensitivitySettingsOperations operations - :vartype sensitivity_settings: - azure.mgmt.security.v2023_02_15_preview.operations.SensitivitySettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-02-15-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.sensitivity_settings = SensitivitySettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-15-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_configuration.py deleted file mode 100644 index 07fa2bc6217c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2023-02-15-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-02-15-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_security_center.py deleted file mode 100644 index 38f2eeaaa0da..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_security_center.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SensitivitySettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar sensitivity_settings: SensitivitySettingsOperations operations - :vartype sensitivity_settings: - azure.mgmt.security.v2023_02_15_preview.aio.operations.SensitivitySettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-02-15-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.sensitivity_settings = SensitivitySettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-02-15-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/__init__.py deleted file mode 100644 index 0330da5bf6fe..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._sensitivity_settings_operations import SensitivitySettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SensitivitySettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_sensitivity_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_sensitivity_settings_operations.py deleted file mode 100644 index 9d7fe5cb313a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_sensitivity_settings_operations.py +++ /dev/null @@ -1,267 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._sensitivity_settings_operations import ( - build_create_or_update_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SensitivitySettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_15_preview.aio.SecurityCenter`'s - :attr:`sensitivity_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create_or_update( - self, - sensitivity_settings: _models.UpdateSensitivitySettingsRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GetSensitivitySettingsResponse: - """Create or update data sensitivity settings for sensitive data discovery. - - :param sensitivity_settings: The data sensitivity settings to update. Required. - :type sensitivity_settings: - ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GetSensitivitySettingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, sensitivity_settings: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.GetSensitivitySettingsResponse: - """Create or update data sensitivity settings for sensitive data discovery. - - :param sensitivity_settings: The data sensitivity settings to update. Required. - :type sensitivity_settings: 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: GetSensitivitySettingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO[bytes]], **kwargs: Any - ) -> _models.GetSensitivitySettingsResponse: - """Create or update data sensitivity settings for sensitive data discovery. - - :param sensitivity_settings: The data sensitivity settings to update. Is either a - UpdateSensitivitySettingsRequest type or a IO[bytes] type. Required. - :type sensitivity_settings: - ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest or IO[bytes] - :return: GetSensitivitySettingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-15-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(sensitivity_settings, (IOBase, bytes)): - _content = sensitivity_settings - else: - _json = self._serialize.body(sensitivity_settings, "UpdateSensitivitySettingsRequest") - - _request = build_create_or_update_request( - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, **kwargs: Any) -> _models.GetSensitivitySettingsResponse: - """Gets data sensitivity settings for sensitive data discovery. - - :return: GetSensitivitySettingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-15-preview") - ) - cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.GetSensitivitySettingsListResponse: - """Gets a list with a single sensitivity settings resource. - - :return: GetSensitivitySettingsListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-15-preview") - ) - cls: ClsType[_models.GetSensitivitySettingsListResponse] = kwargs.pop("cls", None) - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GetSensitivitySettingsListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/__init__.py deleted file mode 100644 index d4485df65317..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/__init__.py +++ /dev/null @@ -1,39 +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 ._models_py3 import BuiltInInfoType -from ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import GetSensitivitySettingsListResponse -from ._models_py3 import GetSensitivitySettingsResponse -from ._models_py3 import GetSensitivitySettingsResponseProperties -from ._models_py3 import GetSensitivitySettingsResponsePropertiesMipInformation -from ._models_py3 import InfoType -from ._models_py3 import Label -from ._models_py3 import UpdateSensitivitySettingsRequest - -from ._security_center_enums import MipIntegrationStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "BuiltInInfoType", - "CloudErrorBody", - "ErrorAdditionalInfo", - "GetSensitivitySettingsListResponse", - "GetSensitivitySettingsResponse", - "GetSensitivitySettingsResponseProperties", - "GetSensitivitySettingsResponsePropertiesMipInformation", - "InfoType", - "Label", - "UpdateSensitivitySettingsRequest", - "MipIntegrationStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_models_py3.py deleted file mode 100644 index c6d3f6436c0c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_models_py3.py +++ /dev/null @@ -1,435 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class BuiltInInfoType(_serialization.Model): - """Pre-configured sensitive information type. - - :ivar name: Display name of the info type. - :vartype name: str - :ivar id: Id of the info type. - :vartype id: str - :ivar type: Category of the built-in info type. - :vartype type: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Display name of the info type. - :paramtype name: str - :keyword id: Id of the info type. - :paramtype id: str - :keyword type: Category of the built-in info type. - :paramtype type: str - """ - super().__init__(**kwargs) - self.name = name - self.id = id - self.type = type - - -class CloudErrorBody(_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.security.v2023_02_15_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2023_02_15_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class GetSensitivitySettingsListResponse(_serialization.Model): - """A list with a single sensitivity settings resource. - - :ivar value: - :vartype value: - list[~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GetSensitivitySettingsResponse]"}, - } - - def __init__( - self, *, value: Optional[List["_models.GetSensitivitySettingsResponse"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: - :paramtype value: - list[~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse] - """ - super().__init__(**kwargs) - self.value = value - - -class GetSensitivitySettingsResponse(_serialization.Model): - """Data sensitivity settings for sensitive data discovery. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ID of the sensitivity settings. - :vartype id: str - :ivar type: The type of the sensitivity settings. - :vartype type: str - :ivar name: The name of the sensitivity settings. - :vartype name: str - :ivar properties: The sensitivity settings properties. - :vartype properties: - ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponseProperties - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "GetSensitivitySettingsResponseProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.GetSensitivitySettingsResponseProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: The sensitivity settings properties. - :paramtype properties: - ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponseProperties - """ - super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.properties = properties - - -class GetSensitivitySettingsResponseProperties(_serialization.Model): - """The sensitivity settings properties. - - :ivar sensitive_info_types_ids: List of selected sensitive info types' IDs. - :vartype sensitive_info_types_ids: list[str] - :ivar sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any - label at or above this order will be considered sensitive. If set to -1, sensitivity by labels - is turned off. - :vartype sensitivity_threshold_label_order: float - :ivar sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label at - or above this rank will be considered sensitive. - :vartype sensitivity_threshold_label_id: str - :ivar mip_information: Microsoft information protection built-in and custom information types, - labels, and integration status. - :vartype mip_information: - ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponsePropertiesMipInformation - """ - - _attribute_map = { - "sensitive_info_types_ids": {"key": "sensitiveInfoTypesIds", "type": "[str]"}, - "sensitivity_threshold_label_order": {"key": "sensitivityThresholdLabelOrder", "type": "float"}, - "sensitivity_threshold_label_id": {"key": "sensitivityThresholdLabelId", "type": "str"}, - "mip_information": {"key": "mipInformation", "type": "GetSensitivitySettingsResponsePropertiesMipInformation"}, - } - - def __init__( - self, - *, - sensitive_info_types_ids: Optional[List[str]] = None, - sensitivity_threshold_label_order: Optional[float] = None, - sensitivity_threshold_label_id: Optional[str] = None, - mip_information: Optional["_models.GetSensitivitySettingsResponsePropertiesMipInformation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword sensitive_info_types_ids: List of selected sensitive info types' IDs. - :paramtype sensitive_info_types_ids: list[str] - :keyword sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any - label at or above this order will be considered sensitive. If set to -1, sensitivity by labels - is turned off. - :paramtype sensitivity_threshold_label_order: float - :keyword sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label - at or above this rank will be considered sensitive. - :paramtype sensitivity_threshold_label_id: str - :keyword mip_information: Microsoft information protection built-in and custom information - types, labels, and integration status. - :paramtype mip_information: - ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponsePropertiesMipInformation - """ - super().__init__(**kwargs) - self.sensitive_info_types_ids = sensitive_info_types_ids - self.sensitivity_threshold_label_order = sensitivity_threshold_label_order - self.sensitivity_threshold_label_id = sensitivity_threshold_label_id - self.mip_information = mip_information - - -class GetSensitivitySettingsResponsePropertiesMipInformation(_serialization.Model): # pylint: disable=name-too-long - """Microsoft information protection built-in and custom information types, labels, and integration - status. - - :ivar mip_integration_status: Microsoft information protection integration status. Known values - are: "Ok", "noConsent", "noAutoLabelingRules", and "noMipLabels". - :vartype mip_integration_status: str or - ~azure.mgmt.security.v2023_02_15_preview.models.MipIntegrationStatus - :ivar labels: List of Microsoft information protection sensitivity labels. - :vartype labels: list[~azure.mgmt.security.v2023_02_15_preview.models.Label] - :ivar custom_info_types: List of custom user-defined information types. - :vartype custom_info_types: list[~azure.mgmt.security.v2023_02_15_preview.models.InfoType] - :ivar built_in_info_types: List of pre-configured sensitive information types. - :vartype built_in_info_types: - list[~azure.mgmt.security.v2023_02_15_preview.models.BuiltInInfoType] - """ - - _attribute_map = { - "mip_integration_status": {"key": "mipIntegrationStatus", "type": "str"}, - "labels": {"key": "labels", "type": "[Label]"}, - "custom_info_types": {"key": "customInfoTypes", "type": "[InfoType]"}, - "built_in_info_types": {"key": "builtInInfoTypes", "type": "[BuiltInInfoType]"}, - } - - def __init__( - self, - *, - mip_integration_status: Optional[Union[str, "_models.MipIntegrationStatus"]] = None, - labels: Optional[List["_models.Label"]] = None, - custom_info_types: Optional[List["_models.InfoType"]] = None, - built_in_info_types: Optional[List["_models.BuiltInInfoType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword mip_integration_status: Microsoft information protection integration status. Known - values are: "Ok", "noConsent", "noAutoLabelingRules", and "noMipLabels". - :paramtype mip_integration_status: str or - ~azure.mgmt.security.v2023_02_15_preview.models.MipIntegrationStatus - :keyword labels: List of Microsoft information protection sensitivity labels. - :paramtype labels: list[~azure.mgmt.security.v2023_02_15_preview.models.Label] - :keyword custom_info_types: List of custom user-defined information types. - :paramtype custom_info_types: list[~azure.mgmt.security.v2023_02_15_preview.models.InfoType] - :keyword built_in_info_types: List of pre-configured sensitive information types. - :paramtype built_in_info_types: - list[~azure.mgmt.security.v2023_02_15_preview.models.BuiltInInfoType] - """ - super().__init__(**kwargs) - self.mip_integration_status = mip_integration_status - self.labels = labels - self.custom_info_types = custom_info_types - self.built_in_info_types = built_in_info_types - - -class InfoType(_serialization.Model): - """Custom user-defined information type. - - :ivar name: Display name of the info type. - :vartype name: str - :ivar id: Id of the info type. - :vartype id: str - :ivar description: Description of the info type. - :vartype description: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Display name of the info type. - :paramtype name: str - :keyword id: Id of the info type. - :paramtype id: str - :keyword description: Description of the info type. - :paramtype description: str - """ - super().__init__(**kwargs) - self.name = name - self.id = id - self.description = description - - -class Label(_serialization.Model): - """Microsoft information protection sensitivity label. - - :ivar name: The display name of the label. - :vartype name: str - :ivar id: The ID of the label. - :vartype id: str - :ivar order: Labels are ordered by sensitivity level. The higher the order of the label, the - more sensitive it is. - :vartype order: float - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "order": {"key": "order", "type": "float"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - order: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The display name of the label. - :paramtype name: str - :keyword id: The ID of the label. - :paramtype id: str - :keyword order: Labels are ordered by sensitivity level. The higher the order of the label, the - more sensitive it is. - :paramtype order: float - """ - super().__init__(**kwargs) - self.name = name - self.id = id - self.order = order - - -class UpdateSensitivitySettingsRequest(_serialization.Model): - """Request to update data sensitivity settings for sensitive data discovery. - - All required parameters must be populated in order to send to server. - - :ivar sensitive_info_types_ids: List of selected sensitive info types' IDs. Required. - :vartype sensitive_info_types_ids: list[str] - :ivar sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any - label at or above this order will be considered sensitive. If set to -1, sensitivity by labels - is turned off. - :vartype sensitivity_threshold_label_order: float - :ivar sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label at - or above this rank will be considered sensitive. - :vartype sensitivity_threshold_label_id: str - """ - - _validation = { - "sensitive_info_types_ids": {"required": True}, - } - - _attribute_map = { - "sensitive_info_types_ids": {"key": "sensitiveInfoTypesIds", "type": "[str]"}, - "sensitivity_threshold_label_order": {"key": "sensitivityThresholdLabelOrder", "type": "float"}, - "sensitivity_threshold_label_id": {"key": "sensitivityThresholdLabelId", "type": "str"}, - } - - def __init__( - self, - *, - sensitive_info_types_ids: List[str], - sensitivity_threshold_label_order: Optional[float] = None, - sensitivity_threshold_label_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword sensitive_info_types_ids: List of selected sensitive info types' IDs. Required. - :paramtype sensitive_info_types_ids: list[str] - :keyword sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any - label at or above this order will be considered sensitive. If set to -1, sensitivity by labels - is turned off. - :paramtype sensitivity_threshold_label_order: float - :keyword sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label - at or above this rank will be considered sensitive. - :paramtype sensitivity_threshold_label_id: str - """ - super().__init__(**kwargs) - self.sensitive_info_types_ids = sensitive_info_types_ids - self.sensitivity_threshold_label_order = sensitivity_threshold_label_order - self.sensitivity_threshold_label_id = sensitivity_threshold_label_id diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_security_center_enums.py deleted file mode 100644 index 88712d8f4277..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_security_center_enums.py +++ /dev/null @@ -1,19 +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 MipIntegrationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Microsoft information protection integration status.""" - - OK = "Ok" - NO_CONSENT = "noConsent" - NO_AUTO_LABELING_RULES = "noAutoLabelingRules" - NO_MIP_LABELS = "noMipLabels" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/__init__.py deleted file mode 100644 index 0330da5bf6fe..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._sensitivity_settings_operations import SensitivitySettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SensitivitySettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_sensitivity_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_sensitivity_settings_operations.py deleted file mode 100644 index 77529d42ed0f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_sensitivity_settings_operations.py +++ /dev/null @@ -1,326 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-15-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Security/sensitivitySettings/current") - - # 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_get_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Security/sensitivitySettings/current") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Security/sensitivitySettings") - - # 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 SensitivitySettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_02_15_preview.SecurityCenter`'s - :attr:`sensitivity_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - sensitivity_settings: _models.UpdateSensitivitySettingsRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GetSensitivitySettingsResponse: - """Create or update data sensitivity settings for sensitive data discovery. - - :param sensitivity_settings: The data sensitivity settings to update. Required. - :type sensitivity_settings: - ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GetSensitivitySettingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, sensitivity_settings: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.GetSensitivitySettingsResponse: - """Create or update data sensitivity settings for sensitive data discovery. - - :param sensitivity_settings: The data sensitivity settings to update. Required. - :type sensitivity_settings: 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: GetSensitivitySettingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO[bytes]], **kwargs: Any - ) -> _models.GetSensitivitySettingsResponse: - """Create or update data sensitivity settings for sensitive data discovery. - - :param sensitivity_settings: The data sensitivity settings to update. Is either a - UpdateSensitivitySettingsRequest type or a IO[bytes] type. Required. - :type sensitivity_settings: - ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest or IO[bytes] - :return: GetSensitivitySettingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-15-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(sensitivity_settings, (IOBase, bytes)): - _content = sensitivity_settings - else: - _json = self._serialize.body(sensitivity_settings, "UpdateSensitivitySettingsRequest") - - _request = build_create_or_update_request( - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, **kwargs: Any) -> _models.GetSensitivitySettingsResponse: - """Gets data sensitivity settings for sensitive data discovery. - - :return: GetSensitivitySettingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-15-preview") - ) - cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> _models.GetSensitivitySettingsListResponse: - """Gets a list with a single sensitivity settings resource. - - :return: GetSensitivitySettingsListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-02-15-preview") - ) - cls: ClsType[_models.GetSensitivitySettingsListResponse] = kwargs.pop("cls", None) - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GetSensitivitySettingsListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_configuration.py deleted file mode 100644 index aa16214ce1cb..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-03-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", "2023-03-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_metadata.json deleted file mode 100644 index 7fad30edecb6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2023-03-01-preview", - "total_api_version_list": ["2023-03-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "security_connectors": "SecurityConnectorsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_security_center.py deleted file mode 100644 index 632f7ebb548f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_security_center.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityConnectorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2023_03_01_preview.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-03-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-03-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_configuration.py deleted file mode 100644 index 670481c0b88d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-03-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", "2023-03-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_security_center.py deleted file mode 100644 index 4c748c5cb268..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_security_center.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityConnectorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2023_03_01_preview.aio.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-03-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-03-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/__init__.py deleted file mode 100644 index 8e4ac6c4f04e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_security_connectors_operations.py deleted file mode 100644 index 553600bf374f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_security_connectors_operations.py +++ /dev/null @@ -1,625 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_connectors_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_03_01_preview.aio.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector] - :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._api_version or "2023-03-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector] - :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._api_version or "2023-03-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/__init__.py deleted file mode 100644 index 77b391583009..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/__init__.py +++ /dev/null @@ -1,197 +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 ._models_py3 import AwsEnvironmentData -from ._models_py3 import AwsOrganizationalData -from ._models_py3 import AwsOrganizationalDataMaster -from ._models_py3 import AwsOrganizationalDataMember -from ._models_py3 import AzureDevOpsScopeEnvironmentData -from ._models_py3 import AzureTrackedResourceLocation -from ._models_py3 import CloudErrorBody -from ._models_py3 import CloudOffering -from ._models_py3 import CspmMonitorAwsOffering -from ._models_py3 import CspmMonitorAwsOfferingNativeCloudConnection -from ._models_py3 import CspmMonitorAzureDevOpsOffering -from ._models_py3 import CspmMonitorGcpOffering -from ._models_py3 import CspmMonitorGcpOfferingNativeCloudConnection -from ._models_py3 import CspmMonitorGitLabOffering -from ._models_py3 import CspmMonitorGithubOffering -from ._models_py3 import DefenderCspmAwsOffering -from ._models_py3 import DefenderCspmAwsOfferingDataSensitivityDiscovery -from ._models_py3 import DefenderCspmAwsOfferingDatabasesDspm -from ._models_py3 import DefenderCspmAwsOfferingVmScanners -from ._models_py3 import DefenderCspmAwsOfferingVmScannersConfiguration -from ._models_py3 import DefenderCspmGcpOffering -from ._models_py3 import DefenderFoDatabasesAwsOffering -from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioning -from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderFoDatabasesAwsOfferingDatabasesDspm -from ._models_py3 import DefenderFoDatabasesAwsOfferingRds -from ._models_py3 import DefenderForContainersAwsOffering -from ._models_py3 import DefenderForContainersAwsOfferingCloudWatchToKinesis -from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessment -from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask -from ._models_py3 import DefenderForContainersAwsOfferingKinesisToS3 -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesScubaReader -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesService -from ._models_py3 import DefenderForContainersGcpOffering -from ._models_py3 import DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection -from ._models_py3 import DefenderForContainersGcpOfferingNativeCloudConnection -from ._models_py3 import DefenderForDatabasesGcpOffering -from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioning -from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning -from ._models_py3 import DefenderForDevOpsAzureDevOpsOffering -from ._models_py3 import DefenderForDevOpsGitLabOffering -from ._models_py3 import DefenderForDevOpsGithubOffering -from ._models_py3 import DefenderForServersAwsOffering -from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersAwsOfferingDefenderForServers -from ._models_py3 import DefenderForServersAwsOfferingMdeAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingSubPlan -from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersAwsOfferingVmScanners -from ._models_py3 import DefenderForServersAwsOfferingVmScannersConfiguration -from ._models_py3 import DefenderForServersGcpOffering -from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersGcpOfferingDefenderForServers -from ._models_py3 import DefenderForServersGcpOfferingMdeAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingSubPlan -from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersGcpOfferingVmScanners -from ._models_py3 import DefenderForServersGcpOfferingVmScannersConfiguration -from ._models_py3 import ETag -from ._models_py3 import EnvironmentData -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import GcpOrganizationalData -from ._models_py3 import GcpOrganizationalDataMember -from ._models_py3 import GcpOrganizationalDataOrganization -from ._models_py3 import GcpProjectDetails -from ._models_py3 import GcpProjectEnvironmentData -from ._models_py3 import GithubScopeEnvironmentData -from ._models_py3 import GitlabScopeEnvironmentData -from ._models_py3 import InformationProtectionAwsOffering -from ._models_py3 import InformationProtectionAwsOfferingInformationProtection -from ._models_py3 import Kind -from ._models_py3 import Resource -from ._models_py3 import SecurityConnector -from ._models_py3 import SecurityConnectorsList -from ._models_py3 import SystemData -from ._models_py3 import Tags -from ._models_py3 import TrackedResource - -from ._security_center_enums import CloudName -from ._security_center_enums import CreatedByType -from ._security_center_enums import EnvironmentType -from ._security_center_enums import OfferingType -from ._security_center_enums import OrganizationMembershipType -from ._security_center_enums import ScanningMode -from ._security_center_enums import SubPlan -from ._security_center_enums import Type -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AwsEnvironmentData", - "AwsOrganizationalData", - "AwsOrganizationalDataMaster", - "AwsOrganizationalDataMember", - "AzureDevOpsScopeEnvironmentData", - "AzureTrackedResourceLocation", - "CloudErrorBody", - "CloudOffering", - "CspmMonitorAwsOffering", - "CspmMonitorAwsOfferingNativeCloudConnection", - "CspmMonitorAzureDevOpsOffering", - "CspmMonitorGcpOffering", - "CspmMonitorGcpOfferingNativeCloudConnection", - "CspmMonitorGitLabOffering", - "CspmMonitorGithubOffering", - "DefenderCspmAwsOffering", - "DefenderCspmAwsOfferingDataSensitivityDiscovery", - "DefenderCspmAwsOfferingDatabasesDspm", - "DefenderCspmAwsOfferingVmScanners", - "DefenderCspmAwsOfferingVmScannersConfiguration", - "DefenderCspmGcpOffering", - "DefenderFoDatabasesAwsOffering", - "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", - "DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration", - "DefenderFoDatabasesAwsOfferingDatabasesDspm", - "DefenderFoDatabasesAwsOfferingRds", - "DefenderForContainersAwsOffering", - "DefenderForContainersAwsOfferingCloudWatchToKinesis", - "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", - "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", - "DefenderForContainersAwsOfferingKinesisToS3", - "DefenderForContainersAwsOfferingKubernetesScubaReader", - "DefenderForContainersAwsOfferingKubernetesService", - "DefenderForContainersGcpOffering", - "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", - "DefenderForContainersGcpOfferingNativeCloudConnection", - "DefenderForDatabasesGcpOffering", - "DefenderForDatabasesGcpOfferingArcAutoProvisioning", - "DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration", - "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", - "DefenderForDevOpsAzureDevOpsOffering", - "DefenderForDevOpsGitLabOffering", - "DefenderForDevOpsGithubOffering", - "DefenderForServersAwsOffering", - "DefenderForServersAwsOfferingArcAutoProvisioning", - "DefenderForServersAwsOfferingArcAutoProvisioningConfiguration", - "DefenderForServersAwsOfferingDefenderForServers", - "DefenderForServersAwsOfferingMdeAutoProvisioning", - "DefenderForServersAwsOfferingSubPlan", - "DefenderForServersAwsOfferingVaAutoProvisioning", - "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", - "DefenderForServersAwsOfferingVmScanners", - "DefenderForServersAwsOfferingVmScannersConfiguration", - "DefenderForServersGcpOffering", - "DefenderForServersGcpOfferingArcAutoProvisioning", - "DefenderForServersGcpOfferingArcAutoProvisioningConfiguration", - "DefenderForServersGcpOfferingDefenderForServers", - "DefenderForServersGcpOfferingMdeAutoProvisioning", - "DefenderForServersGcpOfferingSubPlan", - "DefenderForServersGcpOfferingVaAutoProvisioning", - "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", - "DefenderForServersGcpOfferingVmScanners", - "DefenderForServersGcpOfferingVmScannersConfiguration", - "ETag", - "EnvironmentData", - "ErrorAdditionalInfo", - "GcpOrganizationalData", - "GcpOrganizationalDataMember", - "GcpOrganizationalDataOrganization", - "GcpProjectDetails", - "GcpProjectEnvironmentData", - "GithubScopeEnvironmentData", - "GitlabScopeEnvironmentData", - "InformationProtectionAwsOffering", - "InformationProtectionAwsOfferingInformationProtection", - "Kind", - "Resource", - "SecurityConnector", - "SecurityConnectorsList", - "SystemData", - "Tags", - "TrackedResource", - "CloudName", - "CreatedByType", - "EnvironmentType", - "OfferingType", - "OrganizationMembershipType", - "ScanningMode", - "SubPlan", - "Type", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/_models_py3.py deleted file mode 100644 index b2e5e170c1ae..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/_models_py3.py +++ /dev/null @@ -1,3285 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class EnvironmentData(_serialization.Model): - """The security connector environment data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AwsEnvironmentData, AzureDevOpsScopeEnvironmentData, GcpProjectEnvironmentData, - GithubScopeEnvironmentData, GitlabScopeEnvironmentData - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - _subtype_map = { - "environment_type": { - "AwsAccount": "AwsEnvironmentData", - "AzureDevOpsScope": "AzureDevOpsScopeEnvironmentData", - "GcpProject": "GcpProjectEnvironmentData", - "GithubScope": "GithubScopeEnvironmentData", - "GitlabScope": "GitlabScopeEnvironmentData", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: Optional[str] = None - - -class AwsEnvironmentData(EnvironmentData): - """The AWS connector environment data. - - 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 environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.EnvironmentType - :ivar organizational_data: The AWS account's organizational data. - :vartype organizational_data: - ~azure.mgmt.security.v2023_03_01_preview.models.AwsOrganizationalData - :ivar regions: list of regions to scan. - :vartype regions: list[str] - :ivar account_name: The AWS account name. - :vartype account_name: str - """ - - _validation = { - "environment_type": {"required": True}, - "account_name": {"readonly": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - "organizational_data": {"key": "organizationalData", "type": "AwsOrganizationalData"}, - "regions": {"key": "regions", "type": "[str]"}, - "account_name": {"key": "accountName", "type": "str"}, - } - - def __init__( - self, - *, - organizational_data: Optional["_models.AwsOrganizationalData"] = None, - regions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword organizational_data: The AWS account's organizational data. - :paramtype organizational_data: - ~azure.mgmt.security.v2023_03_01_preview.models.AwsOrganizationalData - :keyword regions: list of regions to scan. - :paramtype regions: list[str] - """ - super().__init__(**kwargs) - self.environment_type: str = "AwsAccount" - self.organizational_data = organizational_data - self.regions = regions - self.account_name = None - - -class AwsOrganizationalData(_serialization.Model): - """The AWS organization data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AwsOrganizationalDataMember, AwsOrganizationalDataMaster - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.OrganizationMembershipType - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - } - - _subtype_map = { - "organization_membership_type": { - "Member": "AwsOrganizationalDataMember", - "Organization": "AwsOrganizationalDataMaster", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.organization_membership_type: Optional[str] = None - - -class AwsOrganizationalDataMaster(AwsOrganizationalData): - """The AWS organization data for the master account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.OrganizationMembershipType - :ivar stackset_name: If the multi cloud account is of membership type organization, this will - be the name of the onboarding stackset. - :vartype stackset_name: str - :ivar excluded_account_ids: If the multi cloud account is of membership type organization, list - of accounts excluded from offering. - :vartype excluded_account_ids: list[str] - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "stackset_name": {"key": "stacksetName", "type": "str"}, - "excluded_account_ids": {"key": "excludedAccountIds", "type": "[str]"}, - } - - def __init__( - self, *, stackset_name: Optional[str] = None, excluded_account_ids: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword stackset_name: If the multi cloud account is of membership type organization, this - will be the name of the onboarding stackset. - :paramtype stackset_name: str - :keyword excluded_account_ids: If the multi cloud account is of membership type organization, - list of accounts excluded from offering. - :paramtype excluded_account_ids: list[str] - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Organization" - self.stackset_name = stackset_name - self.excluded_account_ids = excluded_account_ids - - -class AwsOrganizationalDataMember(AwsOrganizationalData): - """The AWS organization data for the member account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.OrganizationMembershipType - :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, - this will be the ID of the account's parent. - :vartype parent_hierarchy_id: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, - } - - def __init__(self, *, parent_hierarchy_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword parent_hierarchy_id: If the multi cloud account is not of membership type - organization, this will be the ID of the account's parent. - :paramtype parent_hierarchy_id: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Member" - self.parent_hierarchy_id = parent_hierarchy_id - - -class AzureDevOpsScopeEnvironmentData(EnvironmentData): - """The AzureDevOps scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "AzureDevOpsScope" - - -class AzureTrackedResourceLocation(_serialization.Model): - """Describes an Azure resource with location. - - :ivar location: Location where the resource is stored. - :vartype location: str - """ - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - - -class CloudErrorBody(_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.security.v2023_03_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2023_03_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class CloudOffering(_serialization.Model): - """The security offering details. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - CspmMonitorAwsOffering, CspmMonitorAzureDevOpsOffering, CspmMonitorGcpOffering, - CspmMonitorGitLabOffering, CspmMonitorGithubOffering, DefenderCspmAwsOffering, - DefenderCspmGcpOffering, DefenderForContainersAwsOffering, DefenderForContainersGcpOffering, - DefenderFoDatabasesAwsOffering, DefenderForDatabasesGcpOffering, - DefenderForDevOpsAzureDevOpsOffering, DefenderForDevOpsGitLabOffering, - DefenderForDevOpsGithubOffering, DefenderForServersAwsOffering, DefenderForServersGcpOffering, - InformationProtectionAwsOffering - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - _subtype_map = { - "offering_type": { - "CspmMonitorAws": "CspmMonitorAwsOffering", - "CspmMonitorAzureDevOps": "CspmMonitorAzureDevOpsOffering", - "CspmMonitorGcp": "CspmMonitorGcpOffering", - "CspmMonitorGitLab": "CspmMonitorGitLabOffering", - "CspmMonitorGithub": "CspmMonitorGithubOffering", - "DefenderCspmAws": "DefenderCspmAwsOffering", - "DefenderCspmGcp": "DefenderCspmGcpOffering", - "DefenderForContainersAws": "DefenderForContainersAwsOffering", - "DefenderForContainersGcp": "DefenderForContainersGcpOffering", - "DefenderForDatabasesAws": "DefenderFoDatabasesAwsOffering", - "DefenderForDatabasesGcp": "DefenderForDatabasesGcpOffering", - "DefenderForDevOpsAzureDevOps": "DefenderForDevOpsAzureDevOpsOffering", - "DefenderForDevOpsGitLab": "DefenderForDevOpsGitLabOffering", - "DefenderForDevOpsGithub": "DefenderForDevOpsGithubOffering", - "DefenderForServersAws": "DefenderForServersAwsOffering", - "DefenderForServersGcp": "DefenderForServersGcpOffering", - "InformationProtectionAws": "InformationProtectionAwsOffering", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: Optional[str] = None - self.description = None - - -class CspmMonitorAwsOffering(CloudOffering): - """The CSPM monitoring for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2023_03_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "CspmMonitorAwsOfferingNativeCloudConnection", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.CspmMonitorAwsOfferingNativeCloudConnection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2023_03_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorAws" - self.native_cloud_connection = native_cloud_connection - - -class CspmMonitorAwsOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class CspmMonitorAzureDevOpsOffering(CloudOffering): - """The CSPM monitoring for AzureDevOps offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorAzureDevOps" - - -class CspmMonitorGcpOffering(CloudOffering): - """The CSPM monitoring for GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2023_03_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "CspmMonitorGcpOfferingNativeCloudConnection", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.CspmMonitorGcpOfferingNativeCloudConnection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2023_03_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection - """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGcp" - self.native_cloud_connection = native_cloud_connection - - -class CspmMonitorGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar workload_identity_provider_id: The GCP workload identity provider id for the offering. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword workload_identity_provider_id: The GCP workload identity provider id for the offering. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class CspmMonitorGithubOffering(CloudOffering): - """The CSPM monitoring for github offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGithub" - - -class CspmMonitorGitLabOffering(CloudOffering): - """The CSPM (Cloud security posture management) monitoring for gitlab offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGitLab" - - -class DefenderCspmAwsOffering(CloudOffering): - """The CSPM P1 for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderCspmAwsOfferingVmScanners - :ivar data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery - configuration. - :vartype data_sensitivity_discovery: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderCspmAwsOfferingDataSensitivityDiscovery - :ivar databases_dspm: The databases DSPM configuration. - :vartype databases_dspm: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderCspmAwsOfferingDatabasesDspm - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderCspmAwsOfferingVmScanners"}, - "data_sensitivity_discovery": { - "key": "dataSensitivityDiscovery", - "type": "DefenderCspmAwsOfferingDataSensitivityDiscovery", - }, - "databases_dspm": {"key": "databasesDspm", "type": "DefenderCspmAwsOfferingDatabasesDspm"}, - } - - def __init__( - self, - *, - vm_scanners: Optional["_models.DefenderCspmAwsOfferingVmScanners"] = None, - data_sensitivity_discovery: Optional["_models.DefenderCspmAwsOfferingDataSensitivityDiscovery"] = None, - databases_dspm: Optional["_models.DefenderCspmAwsOfferingDatabasesDspm"] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderCspmAwsOfferingVmScanners - :keyword data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery - configuration. - :paramtype data_sensitivity_discovery: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderCspmAwsOfferingDataSensitivityDiscovery - :keyword databases_dspm: The databases DSPM configuration. - :paramtype databases_dspm: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderCspmAwsOfferingDatabasesDspm - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderCspmAws" - self.vm_scanners = vm_scanners - self.data_sensitivity_discovery = data_sensitivity_discovery - self.databases_dspm = databases_dspm - - -class DefenderCspmAwsOfferingDatabasesDspm(_serialization.Model): - """The databases DSPM configuration. - - :ivar enabled: Is databases DSPM protection enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is databases DSPM protection enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderCspmAwsOfferingDataSensitivityDiscovery(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender Data Sensitivity discovery configuration. - - :ivar enabled: Is Microsoft Defender Data Sensitivity discovery enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender Data Sensitivity discovery enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderCspmAwsOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderCspmAwsOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderCspmAwsOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderCspmAwsOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar scanning_mode: The scanning mode for the VM scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2023_03_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. - :vartype exclusion_tags: dict[str, str] - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, - } - - def __init__( - self, - *, - cloud_role_arn: Optional[str] = None, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword scanning_mode: The scanning mode for the VM scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_03_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. - :paramtype exclusion_tags: dict[str, str] - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class DefenderCspmGcpOffering(CloudOffering): - """The CSPM P1 for GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderCspmGcp" - - -class DefenderFoDatabasesAwsOffering(CloudOffering): - """The Defender for Databases AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning - :ivar rds: The RDS configuration. - :vartype rds: ~azure.mgmt.security.v2023_03_01_preview.models.DefenderFoDatabasesAwsOfferingRds - :ivar databases_dspm: The databases data security posture management (DSPM) configuration. - :vartype databases_dspm: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderFoDatabasesAwsOfferingDatabasesDspm - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", - }, - "rds": {"key": "rds", "type": "DefenderFoDatabasesAwsOfferingRds"}, - "databases_dspm": {"key": "databasesDspm", "type": "DefenderFoDatabasesAwsOfferingDatabasesDspm"}, - } - - def __init__( - self, - *, - arc_auto_provisioning: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning"] = None, - rds: Optional["_models.DefenderFoDatabasesAwsOfferingRds"] = None, - databases_dspm: Optional["_models.DefenderFoDatabasesAwsOfferingDatabasesDspm"] = None, - **kwargs: Any - ) -> None: - """ - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning - :keyword rds: The RDS configuration. - :paramtype rds: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderFoDatabasesAwsOfferingRds - :keyword databases_dspm: The databases data security posture management (DSPM) configuration. - :paramtype databases_dspm: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderFoDatabasesAwsOfferingDatabasesDspm - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDatabasesAws" - self.arc_auto_provisioning = arc_auto_provisioning - self.rds = rds - self.databases_dspm = databases_dspm - - -class DefenderFoDatabasesAwsOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar configuration: Configuration for servers Arc auto provisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "configuration": { - "key": "configuration", - "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - cloud_role_arn: Optional[str] = None, - configuration: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword configuration: Configuration for servers Arc auto provisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - self.configuration = configuration - - -class DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for servers Arc auto provisioning. - - :ivar proxy: Optional http proxy endpoint to use for the Arc agent. - :vartype proxy: str - :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :vartype private_link_scope: str - """ - - _attribute_map = { - "proxy": {"key": "proxy", "type": "str"}, - "private_link_scope": {"key": "privateLinkScope", "type": "str"}, - } - - def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword proxy: Optional http proxy endpoint to use for the Arc agent. - :paramtype proxy: str - :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :paramtype private_link_scope: str - """ - super().__init__(**kwargs) - self.proxy = proxy - self.private_link_scope = private_link_scope - - -class DefenderFoDatabasesAwsOfferingDatabasesDspm(_serialization.Model): # pylint: disable=name-too-long - """The databases data security posture management (DSPM) configuration. - - :ivar enabled: Is databases data security posture management (DSPM) protection enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is databases data security posture management (DSPM) protection enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderFoDatabasesAwsOfferingRds(_serialization.Model): - """The RDS configuration. - - :ivar enabled: Is RDS protection enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is RDS protection enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOffering(CloudOffering): # pylint: disable=too-many-instance-attributes - """The Defender for Containers AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar kubernetes_service: The kubernetes service connection configuration. - :vartype kubernetes_service: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :ivar kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :vartype kubernetes_scuba_reader: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :ivar cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :vartype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :ivar kinesis_to_s3: The kinesis to s3 connection configuration. - :vartype kinesis_to_s3: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - :ivar container_vulnerability_assessment: The container vulnerability assessment configuration. - :vartype container_vulnerability_assessment: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment - :ivar container_vulnerability_assessment_task: The container vulnerability assessment task - configuration. - :vartype container_vulnerability_assessment_task: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask # pylint: disable=line-too-long - :ivar enable_container_vulnerability_assessment: Enable container vulnerability assessment - feature. - :vartype enable_container_vulnerability_assessment: bool - :ivar auto_provisioning: Is audit logs pipeline auto provisioning enabled. - :vartype auto_provisioning: bool - :ivar kube_audit_retention_time: The retention time in days of kube audit logs set on the - CloudWatch log group. - :vartype kube_audit_retention_time: int - :ivar scuba_external_id: The externalId used by the data reader to prevent the confused deputy - attack. - :vartype scuba_external_id: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "kubernetes_service": {"key": "kubernetesService", "type": "DefenderForContainersAwsOfferingKubernetesService"}, - "kubernetes_scuba_reader": { - "key": "kubernetesScubaReader", - "type": "DefenderForContainersAwsOfferingKubernetesScubaReader", - }, - "cloud_watch_to_kinesis": { - "key": "cloudWatchToKinesis", - "type": "DefenderForContainersAwsOfferingCloudWatchToKinesis", - }, - "kinesis_to_s3": {"key": "kinesisToS3", "type": "DefenderForContainersAwsOfferingKinesisToS3"}, - "container_vulnerability_assessment": { - "key": "containerVulnerabilityAssessment", - "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", - }, - "container_vulnerability_assessment_task": { - "key": "containerVulnerabilityAssessmentTask", - "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", - }, - "enable_container_vulnerability_assessment": {"key": "enableContainerVulnerabilityAssessment", "type": "bool"}, - "auto_provisioning": {"key": "autoProvisioning", "type": "bool"}, - "kube_audit_retention_time": {"key": "kubeAuditRetentionTime", "type": "int"}, - "scuba_external_id": {"key": "scubaExternalId", "type": "str"}, - } - - def __init__( - self, - *, - kubernetes_service: Optional["_models.DefenderForContainersAwsOfferingKubernetesService"] = None, - kubernetes_scuba_reader: Optional["_models.DefenderForContainersAwsOfferingKubernetesScubaReader"] = None, - cloud_watch_to_kinesis: Optional["_models.DefenderForContainersAwsOfferingCloudWatchToKinesis"] = None, - kinesis_to_s3: Optional["_models.DefenderForContainersAwsOfferingKinesisToS3"] = None, - container_vulnerability_assessment: Optional[ - "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment" - ] = None, - container_vulnerability_assessment_task: Optional[ - "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask" - ] = None, - enable_container_vulnerability_assessment: Optional[bool] = None, - auto_provisioning: Optional[bool] = None, - kube_audit_retention_time: Optional[int] = None, - scuba_external_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword kubernetes_service: The kubernetes service connection configuration. - :paramtype kubernetes_service: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :keyword kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :paramtype kubernetes_scuba_reader: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :keyword cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :paramtype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :keyword kinesis_to_s3: The kinesis to s3 connection configuration. - :paramtype kinesis_to_s3: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - :keyword container_vulnerability_assessment: The container vulnerability assessment - configuration. - :paramtype container_vulnerability_assessment: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment # pylint: disable=line-too-long - :keyword container_vulnerability_assessment_task: The container vulnerability assessment task - configuration. - :paramtype container_vulnerability_assessment_task: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask # pylint: disable=line-too-long - :keyword enable_container_vulnerability_assessment: Enable container vulnerability assessment - feature. - :paramtype enable_container_vulnerability_assessment: bool - :keyword auto_provisioning: Is audit logs pipeline auto provisioning enabled. - :paramtype auto_provisioning: bool - :keyword kube_audit_retention_time: The retention time in days of kube audit logs set on the - CloudWatch log group. - :paramtype kube_audit_retention_time: int - :keyword scuba_external_id: The externalId used by the data reader to prevent the confused - deputy attack. - :paramtype scuba_external_id: str - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForContainersAws" - self.kubernetes_service = kubernetes_service - self.kubernetes_scuba_reader = kubernetes_scuba_reader - self.cloud_watch_to_kinesis = cloud_watch_to_kinesis - self.kinesis_to_s3 = kinesis_to_s3 - self.container_vulnerability_assessment = container_vulnerability_assessment - self.container_vulnerability_assessment_task = container_vulnerability_assessment_task - self.enable_container_vulnerability_assessment = enable_container_vulnerability_assessment - self.auto_provisioning = auto_provisioning - self.kube_audit_retention_time = kube_audit_retention_time - self.scuba_external_id = scuba_external_id - - -class DefenderForContainersAwsOfferingCloudWatchToKinesis(_serialization.Model): # pylint: disable=name-too-long - """The cloudwatch to kinesis connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into - Kinesis. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into - Kinesis. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingContainerVulnerabilityAssessment( - _serialization.Model -): # pylint: disable=name-too-long - """The container vulnerability assessment configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask( - _serialization.Model -): # pylint: disable=name-too-long - """The container vulnerability assessment task configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKinesisToS3(_serialization.Model): # pylint: disable=name-too-long - """The kinesis to s3 connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesScubaReader(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes to scuba connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesService(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes service connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning - resources. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning - resources. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersGcpOffering(CloudOffering): - """The containers GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection - :ivar data_pipeline_native_cloud_connection: The native cloud connection configuration. - :vartype data_pipeline_native_cloud_connection: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection - :ivar audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. - :vartype audit_logs_auto_provisioning_flag: bool - :ivar defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes agent - auto provisioning enabled. - :vartype defender_agent_auto_provisioning_flag: bool - :ivar policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning - enabled. - :vartype policy_agent_auto_provisioning_flag: bool - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "DefenderForContainersGcpOfferingNativeCloudConnection", - }, - "data_pipeline_native_cloud_connection": { - "key": "dataPipelineNativeCloudConnection", - "type": "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", - }, - "audit_logs_auto_provisioning_flag": {"key": "auditLogsAutoProvisioningFlag", "type": "bool"}, - "defender_agent_auto_provisioning_flag": {"key": "defenderAgentAutoProvisioningFlag", "type": "bool"}, - "policy_agent_auto_provisioning_flag": {"key": "policyAgentAutoProvisioningFlag", "type": "bool"}, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.DefenderForContainersGcpOfferingNativeCloudConnection"] = None, - data_pipeline_native_cloud_connection: Optional[ - "_models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection" - ] = None, - audit_logs_auto_provisioning_flag: Optional[bool] = None, - defender_agent_auto_provisioning_flag: Optional[bool] = None, - policy_agent_auto_provisioning_flag: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection - :keyword data_pipeline_native_cloud_connection: The native cloud connection configuration. - :paramtype data_pipeline_native_cloud_connection: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection # pylint: disable=line-too-long - :keyword audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. - :paramtype audit_logs_auto_provisioning_flag: bool - :keyword defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes - agent auto provisioning enabled. - :paramtype defender_agent_auto_provisioning_flag: bool - :keyword policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning - enabled. - :paramtype policy_agent_auto_provisioning_flag: bool - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForContainersGcp" - self.native_cloud_connection = native_cloud_connection - self.data_pipeline_native_cloud_connection = data_pipeline_native_cloud_connection - self.audit_logs_auto_provisioning_flag = audit_logs_auto_provisioning_flag - self.defender_agent_auto_provisioning_flag = defender_agent_auto_provisioning_flag - self.policy_agent_auto_provisioning_flag = policy_agent_auto_provisioning_flag - - -class DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection( - _serialization.Model -): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The data collection service account email address in GCP - for this offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The data collection GCP workload identity provider id for - this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The data collection service account email address in - GCP for this offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The data collection GCP workload identity provider id - for this offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForContainersGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id for this - offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForDatabasesGcpOffering(CloudOffering): - """The Defender for Databases GCP offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning - :ivar defender_for_databases_arc_auto_provisioning: The native cloud connection configuration. - :vartype defender_for_databases_arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning # pylint: disable=line-too-long - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioning", - }, - "defender_for_databases_arc_auto_provisioning": { - "key": "defenderForDatabasesArcAutoProvisioning", - "type": "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", - }, - } - - def __init__( - self, - *, - arc_auto_provisioning: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioning"] = None, - defender_for_databases_arc_auto_provisioning: Optional[ - "_models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning - :keyword defender_for_databases_arc_auto_provisioning: The native cloud connection - configuration. - :paramtype defender_for_databases_arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDatabasesGcp" - self.arc_auto_provisioning = arc_auto_provisioning - self.defender_for_databases_arc_auto_provisioning = defender_for_databases_arc_auto_provisioning - - -class DefenderForDatabasesGcpOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: Configuration for servers Arc auto provisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: Configuration for servers Arc auto provisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for servers Arc auto provisioning. - - :ivar proxy: Optional http proxy endpoint to use for the Arc agent. - :vartype proxy: str - :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :vartype private_link_scope: str - """ - - _attribute_map = { - "proxy": {"key": "proxy", "type": "str"}, - "private_link_scope": {"key": "privateLinkScope", "type": "str"}, - } - - def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword proxy: Optional http proxy endpoint to use for the Arc agent. - :paramtype proxy: str - :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :paramtype private_link_scope: str - """ - super().__init__(**kwargs) - self.proxy = proxy - self.private_link_scope = private_link_scope - - -class DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning( - _serialization.Model -): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id for this - offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForDevOpsAzureDevOpsOffering(CloudOffering): - """The Defender for DevOps for Azure DevOps offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDevOpsAzureDevOps" - - -class DefenderForDevOpsGithubOffering(CloudOffering): - """The Defender for DevOps for Github offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDevOpsGithub" - - -class DefenderForDevOpsGitLabOffering(CloudOffering): - """The Defender for DevOps for Gitlab offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDevOpsGitLab" - - -class DefenderForServersAwsOffering(CloudOffering): - """The Defender for Servers AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar defender_for_servers: The Defender for servers connection configuration. - :vartype defender_for_servers: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :vartype va_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning - :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :vartype mde_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning - :ivar sub_plan: configuration for the servers offering subPlan. - :vartype sub_plan: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingSubPlan - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingVmScanners - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "defender_for_servers": { - "key": "defenderForServers", - "type": "DefenderForServersAwsOfferingDefenderForServers", - }, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForServersAwsOfferingArcAutoProvisioning", - }, - "va_auto_provisioning": { - "key": "vaAutoProvisioning", - "type": "DefenderForServersAwsOfferingVaAutoProvisioning", - }, - "mde_auto_provisioning": { - "key": "mdeAutoProvisioning", - "type": "DefenderForServersAwsOfferingMdeAutoProvisioning", - }, - "sub_plan": {"key": "subPlan", "type": "DefenderForServersAwsOfferingSubPlan"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersAwsOfferingVmScanners"}, - } - - def __init__( - self, - *, - defender_for_servers: Optional["_models.DefenderForServersAwsOfferingDefenderForServers"] = None, - arc_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioning"] = None, - va_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioning"] = None, - mde_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingMdeAutoProvisioning"] = None, - sub_plan: Optional["_models.DefenderForServersAwsOfferingSubPlan"] = None, - vm_scanners: Optional["_models.DefenderForServersAwsOfferingVmScanners"] = None, - **kwargs: Any - ) -> None: - """ - :keyword defender_for_servers: The Defender for servers connection configuration. - :paramtype defender_for_servers: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :paramtype va_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning - :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :paramtype mde_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning - :keyword sub_plan: configuration for the servers offering subPlan. - :paramtype sub_plan: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingSubPlan - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingVmScanners - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForServersAws" - self.defender_for_servers = defender_for_servers - self.arc_auto_provisioning = arc_auto_provisioning - self.va_auto_provisioning = va_auto_provisioning - self.mde_auto_provisioning = mde_auto_provisioning - self.sub_plan = sub_plan - self.vm_scanners = vm_scanners - - -class DefenderForServersAwsOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar configuration: Configuration for servers Arc auto provisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersAwsOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - cloud_role_arn: Optional[str] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword configuration: Configuration for servers Arc auto provisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - self.configuration = configuration - - -class DefenderForServersAwsOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for servers Arc auto provisioning. - - :ivar proxy: Optional HTTP proxy endpoint to use for the Arc agent. - :vartype proxy: str - :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :vartype private_link_scope: str - """ - - _attribute_map = { - "proxy": {"key": "proxy", "type": "str"}, - "private_link_scope": {"key": "privateLinkScope", "type": "str"}, - } - - def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword proxy: Optional HTTP proxy endpoint to use for the Arc agent. - :paramtype proxy: str - :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :paramtype private_link_scope: str - """ - super().__init__(**kwargs) - self.proxy = proxy - self.private_link_scope = private_link_scope - - -class DefenderForServersAwsOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long - """The Defender for servers connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForServersAwsOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender for Endpoint autoprovisioning configuration. - - :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :vartype configuration: JSON - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "object"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :paramtype configuration: JSON - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingSubPlan(_serialization.Model): - """configuration for the servers offering subPlan. - - :ivar type: The available sub plans. Known values are: "P1" and "P2". - :vartype type: str or ~azure.mgmt.security.v2023_03_01_preview.models.SubPlan - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The available sub plans. Known values are: "P1" and "P2". - :paramtype type: str or ~azure.mgmt.security.v2023_03_01_preview.models.SubPlan - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersAwsOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Vulnerability Assessment autoprovisioning configuration. - - :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingVaAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """configuration for Vulnerability Assessment autoprovisioning. - - :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :vartype type: str or ~azure.mgmt.security.v2023_03_01_preview.models.Type - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :paramtype type: str or ~azure.mgmt.security.v2023_03_01_preview.models.Type - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersAwsOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderForServersAwsOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar scanning_mode: The scanning mode for the VM scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2023_03_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. - :vartype exclusion_tags: dict[str, str] - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, - } - - def __init__( - self, - *, - cloud_role_arn: Optional[str] = None, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword scanning_mode: The scanning mode for the VM scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_03_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. - :paramtype exclusion_tags: dict[str, str] - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class DefenderForServersGcpOffering(CloudOffering): - """The Defender for Servers GCP offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar defender_for_servers: The Defender for servers connection configuration. - :vartype defender_for_servers: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingDefenderForServers - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning - :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :vartype va_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning - :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :vartype mde_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning - :ivar sub_plan: configuration for the servers offering subPlan. - :vartype sub_plan: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingSubPlan - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingVmScanners - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "defender_for_servers": { - "key": "defenderForServers", - "type": "DefenderForServersGcpOfferingDefenderForServers", - }, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForServersGcpOfferingArcAutoProvisioning", - }, - "va_auto_provisioning": { - "key": "vaAutoProvisioning", - "type": "DefenderForServersGcpOfferingVaAutoProvisioning", - }, - "mde_auto_provisioning": { - "key": "mdeAutoProvisioning", - "type": "DefenderForServersGcpOfferingMdeAutoProvisioning", - }, - "sub_plan": {"key": "subPlan", "type": "DefenderForServersGcpOfferingSubPlan"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersGcpOfferingVmScanners"}, - } - - def __init__( - self, - *, - defender_for_servers: Optional["_models.DefenderForServersGcpOfferingDefenderForServers"] = None, - arc_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioning"] = None, - va_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioning"] = None, - mde_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingMdeAutoProvisioning"] = None, - sub_plan: Optional["_models.DefenderForServersGcpOfferingSubPlan"] = None, - vm_scanners: Optional["_models.DefenderForServersGcpOfferingVmScanners"] = None, - **kwargs: Any - ) -> None: - """ - :keyword defender_for_servers: The Defender for servers connection configuration. - :paramtype defender_for_servers: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingDefenderForServers - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning - :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :paramtype va_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning - :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :paramtype mde_auto_provisioning: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning - :keyword sub_plan: configuration for the servers offering subPlan. - :paramtype sub_plan: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingSubPlan - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingVmScanners - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForServersGcp" - self.defender_for_servers = defender_for_servers - self.arc_auto_provisioning = arc_auto_provisioning - self.va_auto_provisioning = va_auto_provisioning - self.mde_auto_provisioning = mde_auto_provisioning - self.sub_plan = sub_plan - self.vm_scanners = vm_scanners - - -class DefenderForServersGcpOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: Configuration for servers Arc auto provisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersGcpOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: Configuration for servers Arc auto provisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for servers Arc auto provisioning. - - :ivar proxy: Optional HTTP proxy endpoint to use for the Arc agent. - :vartype proxy: str - :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :vartype private_link_scope: str - """ - - _attribute_map = { - "proxy": {"key": "proxy", "type": "str"}, - "private_link_scope": {"key": "privateLinkScope", "type": "str"}, - } - - def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword proxy: Optional HTTP proxy endpoint to use for the Arc agent. - :paramtype proxy: str - :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :paramtype private_link_scope: str - """ - super().__init__(**kwargs) - self.proxy = proxy - self.private_link_scope = private_link_scope - - -class DefenderForServersGcpOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long - """The Defender for servers connection configuration. - - :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this feature. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword workload_identity_provider_id: The workload identity provider id in GCP for this - feature. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - feature. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class DefenderForServersGcpOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender for Endpoint autoprovisioning configuration. - - :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :vartype configuration: JSON - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "object"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :paramtype configuration: JSON - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingSubPlan(_serialization.Model): - """configuration for the servers offering subPlan. - - :ivar type: The available sub plans. Known values are: "P1" and "P2". - :vartype type: str or ~azure.mgmt.security.v2023_03_01_preview.models.SubPlan - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The available sub plans. Known values are: "P1" and "P2". - :paramtype type: str or ~azure.mgmt.security.v2023_03_01_preview.models.SubPlan - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersGcpOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Vulnerability Assessment autoprovisioning configuration. - - :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingVaAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """configuration for Vulnerability Assessment autoprovisioning. - - :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :vartype type: str or ~azure.mgmt.security.v2023_03_01_preview.models.Type - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :paramtype type: str or ~azure.mgmt.security.v2023_03_01_preview.models.Type - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersGcpOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderForServersGcpOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersGcpOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2023_03_01_preview.models.DefenderForServersGcpOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar scanning_mode: The scanning mode for the VM scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2023_03_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicate that VM should not be scanned. - :vartype exclusion_tags: dict[str, str] - """ - - _attribute_map = { - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, - } - - def __init__( - self, - *, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword scanning_mode: The scanning mode for the VM scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_03_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicate that VM should not be scanned. - :paramtype exclusion_tags: dict[str, str] - """ - super().__init__(**kwargs) - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ETag(_serialization.Model): - """Entity tag is used for comparing two or more entities from the same requested resource. - - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - """ - - _attribute_map = { - "etag": {"key": "etag", "type": "str"}, - } - - def __init__(self, *, etag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - """ - super().__init__(**kwargs) - self.etag = etag - - -class GcpOrganizationalData(_serialization.Model): - """The gcpOrganization data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - GcpOrganizationalDataMember, GcpOrganizationalDataOrganization - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.OrganizationMembershipType - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - } - - _subtype_map = { - "organization_membership_type": { - "Member": "GcpOrganizationalDataMember", - "Organization": "GcpOrganizationalDataOrganization", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.organization_membership_type: Optional[str] = None - - -class GcpOrganizationalDataMember(GcpOrganizationalData): - """The gcpOrganization data for the member account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.OrganizationMembershipType - :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, - this will be the ID of the project's parent. - :vartype parent_hierarchy_id: str - :ivar management_project_number: The GCP management project number from organizational - onboarding. - :vartype management_project_number: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, - "management_project_number": {"key": "managementProjectNumber", "type": "str"}, - } - - def __init__( - self, - *, - parent_hierarchy_id: Optional[str] = None, - management_project_number: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword parent_hierarchy_id: If the multi cloud account is not of membership type - organization, this will be the ID of the project's parent. - :paramtype parent_hierarchy_id: str - :keyword management_project_number: The GCP management project number from organizational - onboarding. - :paramtype management_project_number: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Member" - self.parent_hierarchy_id = parent_hierarchy_id - self.management_project_number = management_project_number - - -class GcpOrganizationalDataOrganization(GcpOrganizationalData): - """The gcpOrganization data for the parent account. - - 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 organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.OrganizationMembershipType - :ivar excluded_project_numbers: If the multi cloud account is of membership type organization, - list of accounts excluded from offering. - :vartype excluded_project_numbers: list[str] - :ivar service_account_email_address: The service account email address which represents the - organization level permissions container. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id which represents the - permissions required to auto provision security connectors. - :vartype workload_identity_provider_id: str - :ivar organization_name: GCP organization name. - :vartype organization_name: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - "organization_name": {"readonly": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "excluded_project_numbers": {"key": "excludedProjectNumbers", "type": "[str]"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "organization_name": {"key": "organizationName", "type": "str"}, - } - - def __init__( - self, - *, - excluded_project_numbers: Optional[List[str]] = None, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword excluded_project_numbers: If the multi cloud account is of membership type - organization, list of accounts excluded from offering. - :paramtype excluded_project_numbers: list[str] - :keyword service_account_email_address: The service account email address which represents the - organization level permissions container. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id which represents - the permissions required to auto provision security connectors. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Organization" - self.excluded_project_numbers = excluded_project_numbers - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - self.organization_name = None - - -class GcpProjectDetails(_serialization.Model): - """The details about the project represented by the security connector. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar project_number: The unique GCP Project number. - :vartype project_number: str - :ivar project_id: The GCP Project id. - :vartype project_id: str - :ivar workload_identity_pool_id: The GCP workload identity federation pool id. - :vartype workload_identity_pool_id: str - :ivar project_name: GCP project name. - :vartype project_name: str - """ - - _validation = { - "workload_identity_pool_id": {"readonly": True}, - "project_name": {"readonly": True}, - } - - _attribute_map = { - "project_number": {"key": "projectNumber", "type": "str"}, - "project_id": {"key": "projectId", "type": "str"}, - "workload_identity_pool_id": {"key": "workloadIdentityPoolId", "type": "str"}, - "project_name": {"key": "projectName", "type": "str"}, - } - - def __init__( - self, *, project_number: Optional[str] = None, project_id: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword project_number: The unique GCP Project number. - :paramtype project_number: str - :keyword project_id: The GCP Project id. - :paramtype project_id: str - """ - super().__init__(**kwargs) - self.project_number = project_number - self.project_id = project_id - self.workload_identity_pool_id = None - self.project_name = None - - -class GcpProjectEnvironmentData(EnvironmentData): - """The GCP project connector environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.EnvironmentType - :ivar organizational_data: The Gcp project's organizational data. - :vartype organizational_data: - ~azure.mgmt.security.v2023_03_01_preview.models.GcpOrganizationalData - :ivar project_details: The Gcp project's details. - :vartype project_details: ~azure.mgmt.security.v2023_03_01_preview.models.GcpProjectDetails - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - "organizational_data": {"key": "organizationalData", "type": "GcpOrganizationalData"}, - "project_details": {"key": "projectDetails", "type": "GcpProjectDetails"}, - } - - def __init__( - self, - *, - organizational_data: Optional["_models.GcpOrganizationalData"] = None, - project_details: Optional["_models.GcpProjectDetails"] = None, - **kwargs: Any - ) -> None: - """ - :keyword organizational_data: The Gcp project's organizational data. - :paramtype organizational_data: - ~azure.mgmt.security.v2023_03_01_preview.models.GcpOrganizationalData - :keyword project_details: The Gcp project's details. - :paramtype project_details: ~azure.mgmt.security.v2023_03_01_preview.models.GcpProjectDetails - """ - super().__init__(**kwargs) - self.environment_type: str = "GcpProject" - self.organizational_data = organizational_data - self.project_details = project_details - - -class GithubScopeEnvironmentData(EnvironmentData): - """The github scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "GithubScope" - - -class GitlabScopeEnvironmentData(EnvironmentData): - """The GitLab scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_03_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "GitlabScope" - - -class InformationProtectionAwsOffering(CloudOffering): - """The information protection for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_03_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar information_protection: The native cloud connection configuration. - :vartype information_protection: - ~azure.mgmt.security.v2023_03_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "information_protection": { - "key": "informationProtection", - "type": "InformationProtectionAwsOfferingInformationProtection", - }, - } - - def __init__( - self, - *, - information_protection: Optional["_models.InformationProtectionAwsOfferingInformationProtection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword information_protection: The native cloud connection configuration. - :paramtype information_protection: - ~azure.mgmt.security.v2023_03_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - super().__init__(**kwargs) - self.offering_type: str = "InformationProtectionAws" - self.information_protection = information_protection - - -class InformationProtectionAwsOfferingInformationProtection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class Kind(_serialization.Model): - """Describes an Azure resource with kind. - - :ivar kind: Kind of the resource. - :vartype kind: str - """ - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__(self, *, kind: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword kind: Kind of the resource. - :paramtype kind: str - """ - super().__init__(**kwargs) - self.kind = kind - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Tags(_serialization.Model): - """A list of key value pairs that describe the resource. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class TrackedResource(Resource, AzureTrackedResourceLocation, Kind, ETag, Tags): - """Describes an Azure tracked resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) - self.tags = tags - self.etag = etag - self.kind = kind - self.location = location - self.id = None - self.name = None - self.type = None - - -class SecurityConnector(TrackedResource): # pylint: disable=too-many-instance-attributes - """The security connector resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2023_03_01_preview.models.SystemData - :ivar hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector, project number in case of GCP connector). - :vartype hierarchy_identifier: str - :ivar hierarchy_identifier_trial_end_date: The date on which the trial period will end, if - applicable. Trial period exists for 30 days after upgrading to payed offerings. - :vartype hierarchy_identifier_trial_end_date: ~datetime.datetime - :ivar environment_name: The multi cloud resource's cloud name. Known values are: "Azure", - "AWS", "GCP", "Github", "AzureDevOps", and "GitLab". - :vartype environment_name: str or ~azure.mgmt.security.v2023_03_01_preview.models.CloudName - :ivar offerings: A collection of offerings for the security connector. - :vartype offerings: list[~azure.mgmt.security.v2023_03_01_preview.models.CloudOffering] - :ivar environment_data: The security connector environment data. - :vartype environment_data: ~azure.mgmt.security.v2023_03_01_preview.models.EnvironmentData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "hierarchy_identifier_trial_end_date": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "hierarchy_identifier": {"key": "properties.hierarchyIdentifier", "type": "str"}, - "hierarchy_identifier_trial_end_date": { - "key": "properties.hierarchyIdentifierTrialEndDate", - "type": "iso-8601", - }, - "environment_name": {"key": "properties.environmentName", "type": "str"}, - "offerings": {"key": "properties.offerings", "type": "[CloudOffering]"}, - "environment_data": {"key": "properties.environmentData", "type": "EnvironmentData"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - hierarchy_identifier: Optional[str] = None, - environment_name: Optional[Union[str, "_models.CloudName"]] = None, - offerings: Optional[List["_models.CloudOffering"]] = None, - environment_data: Optional["_models.EnvironmentData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - :keyword hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector, project number in case of GCP connector). - :paramtype hierarchy_identifier: str - :keyword environment_name: The multi cloud resource's cloud name. Known values are: "Azure", - "AWS", "GCP", "Github", "AzureDevOps", and "GitLab". - :paramtype environment_name: str or ~azure.mgmt.security.v2023_03_01_preview.models.CloudName - :keyword offerings: A collection of offerings for the security connector. - :paramtype offerings: list[~azure.mgmt.security.v2023_03_01_preview.models.CloudOffering] - :keyword environment_data: The security connector environment data. - :paramtype environment_data: ~azure.mgmt.security.v2023_03_01_preview.models.EnvironmentData - """ - super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) - self.system_data = None - self.hierarchy_identifier = hierarchy_identifier - self.hierarchy_identifier_trial_end_date = None - self.environment_name = environment_name - self.offerings = offerings - self.environment_data = environment_data - - -class SecurityConnectorsList(_serialization.Model): - """List of security connectors response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of security connectors under the given scope. Required. - :vartype value: list[~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityConnector]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.SecurityConnector"], **kwargs: Any) -> None: - """ - :keyword value: The list of security connectors under the given scope. Required. - :paramtype value: list[~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = 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.security.v2023_03_01_preview.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.security.v2023_03_01_preview.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.security.v2023_03_01_preview.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.security.v2023_03_01_preview.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 diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/_security_center_enums.py deleted file mode 100644 index d93bbb6e8d04..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,89 +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 CloudName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud resource's cloud name.""" - - AZURE = "Azure" - AWS = "AWS" - GCP = "GCP" - GITHUB = "Github" - AZURE_DEV_OPS = "AzureDevOps" - GIT_LAB = "GitLab" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class EnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the environment data.""" - - AWS_ACCOUNT = "AwsAccount" - GCP_PROJECT = "GcpProject" - GITHUB_SCOPE = "GithubScope" - AZURE_DEV_OPS_SCOPE = "AzureDevOpsScope" - GITLAB_SCOPE = "GitlabScope" - - -class OfferingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the security offering.""" - - CSPM_MONITOR_AWS = "CspmMonitorAws" - DEFENDER_FOR_CONTAINERS_AWS = "DefenderForContainersAws" - DEFENDER_FOR_SERVERS_AWS = "DefenderForServersAws" - DEFENDER_FOR_DATABASES_AWS = "DefenderForDatabasesAws" - INFORMATION_PROTECTION_AWS = "InformationProtectionAws" - CSPM_MONITOR_GCP = "CspmMonitorGcp" - CSPM_MONITOR_GITHUB = "CspmMonitorGithub" - CSPM_MONITOR_AZURE_DEV_OPS = "CspmMonitorAzureDevOps" - DEFENDER_FOR_SERVERS_GCP = "DefenderForServersGcp" - DEFENDER_FOR_CONTAINERS_GCP = "DefenderForContainersGcp" - DEFENDER_FOR_DATABASES_GCP = "DefenderForDatabasesGcp" - DEFENDER_CSPM_AWS = "DefenderCspmAws" - DEFENDER_CSPM_GCP = "DefenderCspmGcp" - DEFENDER_FOR_DEV_OPS_GITHUB = "DefenderForDevOpsGithub" - DEFENDER_FOR_DEV_OPS_AZURE_DEV_OPS = "DefenderForDevOpsAzureDevOps" - CSPM_MONITOR_GIT_LAB = "CspmMonitorGitLab" - DEFENDER_FOR_DEV_OPS_GIT_LAB = "DefenderForDevOpsGitLab" - - -class OrganizationMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud account's membership type in the organization.""" - - MEMBER = "Member" - ORGANIZATION = "Organization" - - -class ScanningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scanning mode for the VM scan.""" - - DEFAULT = "Default" - - -class SubPlan(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The available sub plans.""" - - P1 = "P1" - P2 = "P2" - - -class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or 'Qualys'.""" - - QUALYS = "Qualys" - TVM = "TVM" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/__init__.py deleted file mode 100644 index 8e4ac6c4f04e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_security_connectors_operations.py deleted file mode 100644 index 6d18a559e4aa..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_security_connectors_operations.py +++ /dev/null @@ -1,820 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_03_01_preview.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector] - :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._api_version or "2023-03-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector] - :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._api_version or "2023-03-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_03_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_configuration.py deleted file mode 100644 index be8fcd6972e2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :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 "2023-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-05-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_metadata.json deleted file mode 100644 index 9ab7d0642c76..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2023-05-01", - "total_api_version_list": ["2023-05-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. The value must be an UUID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. The value must be an UUID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "server_vulnerability_assessments_settings": "ServerVulnerabilityAssessmentsSettingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_security_center.py deleted file mode 100644 index e79e8380b7e8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_security_center.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ServerVulnerabilityAssessmentsSettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar server_vulnerability_assessments_settings: - ServerVulnerabilityAssessmentsSettingsOperations operations - :vartype server_vulnerability_assessments_settings: - azure.mgmt.security.v2023_05_01.operations.ServerVulnerabilityAssessmentsSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.server_vulnerability_assessments_settings = ServerVulnerabilityAssessmentsSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-05-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_configuration.py deleted file mode 100644 index ceea672b40a2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :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 "2023-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-05-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_security_center.py deleted file mode 100644 index b24aaa44bed8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_security_center.py +++ /dev/null @@ -1,113 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ServerVulnerabilityAssessmentsSettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar server_vulnerability_assessments_settings: - ServerVulnerabilityAssessmentsSettingsOperations operations - :vartype server_vulnerability_assessments_settings: - azure.mgmt.security.v2023_05_01.aio.operations.ServerVulnerabilityAssessmentsSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.server_vulnerability_assessments_settings = ServerVulnerabilityAssessmentsSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-05-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/__init__.py deleted file mode 100644 index 72407abb3340..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._server_vulnerability_assessments_settings_operations import ServerVulnerabilityAssessmentsSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ServerVulnerabilityAssessmentsSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_server_vulnerability_assessments_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_server_vulnerability_assessments_settings_operations.py deleted file mode 100644 index 1481bc38259a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_server_vulnerability_assessments_settings_operations.py +++ /dev/null @@ -1,397 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._server_vulnerability_assessments_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_subscription_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ServerVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_05_01.aio.SecurityCenter`'s - :attr:`server_vulnerability_assessments_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServerVulnerabilityAssessmentsSetting"]: - """Get a list of all the server vulnerability assessments settings over a subscription level - scope. - - :return: An iterator like instance of either ServerVulnerabilityAssessmentsSetting or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting] - :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._api_version or "2023-05-01")) - cls: ClsType[_models.ServerVulnerabilityAssessmentsSettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerVulnerabilityAssessmentsSettingsList", 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, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsSetting: - """Get a server vulnerability assessments setting of the requested kind, that is set on the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) - cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_kind=setting_kind, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], - server_vulnerability_assessments_setting: _models.ServerVulnerabilityAssessmentsSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsSetting: - """Create or update a server vulnerability assessments setting of the requested kind on the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :param server_vulnerability_assessments_setting: A server vulnerability assessments setting - over a predefined scope. Required. - :type server_vulnerability_assessments_setting: - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], - server_vulnerability_assessments_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsSetting: - """Create or update a server vulnerability assessments setting of the requested kind on the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :param server_vulnerability_assessments_setting: A server vulnerability assessments setting - over a predefined scope. Required. - :type server_vulnerability_assessments_setting: 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: ServerVulnerabilityAssessmentsSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], - server_vulnerability_assessments_setting: Union[_models.ServerVulnerabilityAssessmentsSetting, IO[bytes]], - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsSetting: - """Create or update a server vulnerability assessments setting of the requested kind on the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :param server_vulnerability_assessments_setting: A server vulnerability assessments setting - over a predefined scope. Is either a ServerVulnerabilityAssessmentsSetting type or a IO[bytes] - type. Required. - :type server_vulnerability_assessments_setting: - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting or IO[bytes] - :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(server_vulnerability_assessments_setting, (IOBase, bytes)): - _content = server_vulnerability_assessments_setting - else: - _json = self._serialize.body( - server_vulnerability_assessments_setting, "ServerVulnerabilityAssessmentsSetting" - ) - - _request = build_create_or_update_request( - setting_kind=setting_kind, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any - ) -> None: - """Delete the server vulnerability assessments setting of the requested kind from the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - setting_kind=setting_kind, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/__init__.py deleted file mode 100644 index 835b2d97d7e9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/__init__.py +++ /dev/null @@ -1,41 +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 ._models_py3 import AzureServersSetting -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Resource -from ._models_py3 import ServerVulnerabilityAssessmentsSetting -from ._models_py3 import ServerVulnerabilityAssessmentsSettingsList -from ._models_py3 import SystemData - -from ._security_center_enums import CreatedByType -from ._security_center_enums import ServerVulnerabilityAssessmentsAzureSettingSelectedProvider -from ._security_center_enums import ServerVulnerabilityAssessmentsSettingKind -from ._security_center_enums import ServerVulnerabilityAssessmentsSettingKindName -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureServersSetting", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Resource", - "ServerVulnerabilityAssessmentsSetting", - "ServerVulnerabilityAssessmentsSettingsList", - "SystemData", - "CreatedByType", - "ServerVulnerabilityAssessmentsAzureSettingSelectedProvider", - "ServerVulnerabilityAssessmentsSettingKind", - "ServerVulnerabilityAssessmentsSettingKindName", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_models_py3.py deleted file mode 100644 index 85eaac815b16..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_models_py3.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -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}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2023_05_01.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class ServerVulnerabilityAssessmentsSetting(Resource): - """A base vulnerability assessments setting on servers in the defined scope. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureServersSetting - - 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}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2023_05_01.models.SystemData - :ivar kind: The kind of the server vulnerability assessments setting. Required. - "AzureServersSetting" - :vartype kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKind - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "kind": {"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"}, - "kind": {"key": "kind", "type": "str"}, - } - - _subtype_map = {"kind": {"AzureServersSetting": "AzureServersSetting"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - - -class AzureServersSetting(ServerVulnerabilityAssessmentsSetting): - """A vulnerability assessments setting on Azure servers in the defined scope. - - 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}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2023_05_01.models.SystemData - :ivar kind: The kind of the server vulnerability assessments setting. Required. - "AzureServersSetting" - :vartype kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKind - :ivar selected_provider: The selected vulnerability assessments provider on Azure servers in - the defined scope. "MdeTvm" - :vartype selected_provider: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "kind": {"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"}, - "kind": {"key": "kind", "type": "str"}, - "selected_provider": {"key": "properties.selectedProvider", "type": "str"}, - } - - def __init__( - self, - *, - selected_provider: Optional[ - Union[str, "_models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword selected_provider: The selected vulnerability assessments provider on Azure servers in - the defined scope. "MdeTvm" - :paramtype selected_provider: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider - """ - super().__init__(**kwargs) - self.kind: str = "AzureServersSetting" - self.selected_provider = selected_provider - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.security.v2023_05_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2023_05_01.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.security.v2023_05_01.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.security.v2023_05_01.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class ServerVulnerabilityAssessmentsSettingsList(_serialization.Model): # pylint: disable=name-too-long - """A page of a server vulnerability assessments settings list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: A collection of server vulnerability assessments settings in this page. - :vartype value: - list[~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerVulnerabilityAssessmentsSetting]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = 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.security.v2023_05_01.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.security.v2023_05_01.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.security.v2023_05_01.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.security.v2023_05_01.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 diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_security_center_enums.py deleted file mode 100644 index 7118988347bd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_security_center_enums.py +++ /dev/null @@ -1,38 +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 CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class ServerVulnerabilityAssessmentsAzureSettingSelectedProvider(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The selected vulnerability assessments provider on Azure servers in the defined scope.""" - - MDE_TVM = "MdeTvm" - """Microsoft Defender for Endpoints threat and vulnerability management.""" - - -class ServerVulnerabilityAssessmentsSettingKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the server vulnerability assessments setting.""" - - AZURE_SERVERS_SETTING = "AzureServersSetting" - - -class ServerVulnerabilityAssessmentsSettingKindName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ServerVulnerabilityAssessmentsSettingKindName.""" - - AZURE_SERVERS_SETTING = "azureServersSetting" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/__init__.py deleted file mode 100644 index 72407abb3340..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._server_vulnerability_assessments_settings_operations import ServerVulnerabilityAssessmentsSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ServerVulnerabilityAssessmentsSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_server_vulnerability_assessments_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_server_vulnerability_assessments_settings_operations.py deleted file mode 100644 index a23fa3c69574..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_server_vulnerability_assessments_settings_operations.py +++ /dev/null @@ -1,514 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "settingKind": _SERIALIZER.url("setting_kind", setting_kind, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-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}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "settingKind": _SERIALIZER.url("setting_kind", setting_kind, "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_delete_request( - setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "settingKind": _SERIALIZER.url("setting_kind", setting_kind, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_05_01.SecurityCenter`'s - :attr:`server_vulnerability_assessments_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServerVulnerabilityAssessmentsSetting"]: - """Get a list of all the server vulnerability assessments settings over a subscription level - scope. - - :return: An iterator like instance of either ServerVulnerabilityAssessmentsSetting or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting] - :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._api_version or "2023-05-01")) - cls: ClsType[_models.ServerVulnerabilityAssessmentsSettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerVulnerabilityAssessmentsSettingsList", 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, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsSetting: - """Get a server vulnerability assessments setting of the requested kind, that is set on the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) - cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) - - _request = build_get_request( - setting_kind=setting_kind, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], - server_vulnerability_assessments_setting: _models.ServerVulnerabilityAssessmentsSetting, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsSetting: - """Create or update a server vulnerability assessments setting of the requested kind on the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :param server_vulnerability_assessments_setting: A server vulnerability assessments setting - over a predefined scope. Required. - :type server_vulnerability_assessments_setting: - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], - server_vulnerability_assessments_setting: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsSetting: - """Create or update a server vulnerability assessments setting of the requested kind on the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :param server_vulnerability_assessments_setting: A server vulnerability assessments setting - over a predefined scope. Required. - :type server_vulnerability_assessments_setting: 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: ServerVulnerabilityAssessmentsSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], - server_vulnerability_assessments_setting: Union[_models.ServerVulnerabilityAssessmentsSetting, IO[bytes]], - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessmentsSetting: - """Create or update a server vulnerability assessments setting of the requested kind on the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :param server_vulnerability_assessments_setting: A server vulnerability assessments setting - over a predefined scope. Is either a ServerVulnerabilityAssessmentsSetting type or a IO[bytes] - type. Required. - :type server_vulnerability_assessments_setting: - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting or IO[bytes] - :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(server_vulnerability_assessments_setting, (IOBase, bytes)): - _content = server_vulnerability_assessments_setting - else: - _json = self._serialize.body( - server_vulnerability_assessments_setting, "ServerVulnerabilityAssessmentsSetting" - ) - - _request = build_create_or_update_request( - setting_kind=setting_kind, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any - ) -> None: - """Delete the server vulnerability assessments setting of the requested kind from the - subscription. - - :param setting_kind: The kind of the server vulnerability assessments setting. - "azureServersSetting" Required. - :type setting_kind: str or - ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - setting_kind=setting_kind, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_configuration.py deleted file mode 100644 index 90069cdd21cb..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_metadata.json deleted file mode 100644 index f1512482a57c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2023-05-01-preview", - "total_api_version_list": ["2023-05-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "health_reports": "HealthReportsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_security_center.py deleted file mode 100644 index 6d56369c69e8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_security_center.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import HealthReportsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar health_reports: HealthReportsOperations operations - :vartype health_reports: - azure.mgmt.security.v2023_05_01_preview.operations.HealthReportsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.health_reports = HealthReportsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-05-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_configuration.py deleted file mode 100644 index 9f624d75301c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_security_center.py deleted file mode 100644 index 6d070f704f18..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_security_center.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import HealthReportsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar health_reports: HealthReportsOperations operations - :vartype health_reports: - azure.mgmt.security.v2023_05_01_preview.aio.operations.HealthReportsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.health_reports = HealthReportsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-05-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/__init__.py deleted file mode 100644 index f9b535e20872..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._health_reports_operations import HealthReportsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "HealthReportsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_health_reports_operations.py deleted file mode 100644 index 64d93a759030..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_health_reports_operations.py +++ /dev/null @@ -1,202 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._health_reports_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HealthReportsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_05_01_preview.aio.SecurityCenter`'s - :attr:`health_reports` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.HealthReport"]: - """Get a list of all health reports inside a scope. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - - :param scope: The scope at which the operation is performed. Required. - :type scope: str - :return: An iterator like instance of either HealthReport or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_05_01_preview.models.HealthReport] - :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._api_version or "2023-05-01-preview") - ) - cls: ClsType[_models.HealthReportsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("HealthReportsList", 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_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: - """Get health report of resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param health_report_name: The health report Key - Unique key for the health report type. - Required. - :type health_report_name: str - :return: HealthReport or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01_preview.models.HealthReport - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-05-01-preview") - ) - cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - health_report_name=health_report_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("HealthReport", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/__init__.py deleted file mode 100644 index ddea02a9536c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/__init__.py +++ /dev/null @@ -1,43 +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 ._models_py3 import EnvironmentDetails -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import HealthDataClassification -from ._models_py3 import HealthReport -from ._models_py3 import HealthReportsList -from ._models_py3 import Issue -from ._models_py3 import Resource -from ._models_py3 import ResourceDetails -from ._models_py3 import Status - -from ._security_center_enums import Source -from ._security_center_enums import StatusName -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "EnvironmentDetails", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "HealthDataClassification", - "HealthReport", - "HealthReportsList", - "Issue", - "Resource", - "ResourceDetails", - "Status", - "Source", - "StatusName", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_models_py3.py deleted file mode 100644 index 8fd1566ad41e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_models_py3.py +++ /dev/null @@ -1,528 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class EnvironmentDetails(_serialization.Model): - """The environment details of the resource. - - :ivar native_resource_id: The native resource id of the resource (in case of Azure - the - resource Id, in case of MC - the native resource id). - :vartype native_resource_id: str - :ivar environment_hierarchy_id: The hierarchy id of the connector (in case of Azure - the - subscription Id, in case of MC - the hierarchyId id). - :vartype environment_hierarchy_id: str - :ivar organizational_hierarchy_id: The organizational hierarchy id of the connector (in case of - Azure - the subscription Id, in case of MC - the organizational hierarchyId id). - :vartype organizational_hierarchy_id: str - :ivar subscription_id: The subscription Id. - :vartype subscription_id: str - :ivar tenant_id: The tenant Id. - :vartype tenant_id: str - """ - - _attribute_map = { - "native_resource_id": {"key": "nativeResourceId", "type": "str"}, - "environment_hierarchy_id": {"key": "environmentHierarchyId", "type": "str"}, - "organizational_hierarchy_id": {"key": "organizationalHierarchyId", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - native_resource_id: Optional[str] = None, - environment_hierarchy_id: Optional[str] = None, - organizational_hierarchy_id: Optional[str] = None, - subscription_id: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_resource_id: The native resource id of the resource (in case of Azure - the - resource Id, in case of MC - the native resource id). - :paramtype native_resource_id: str - :keyword environment_hierarchy_id: The hierarchy id of the connector (in case of Azure - the - subscription Id, in case of MC - the hierarchyId id). - :paramtype environment_hierarchy_id: str - :keyword organizational_hierarchy_id: The organizational hierarchy id of the connector (in case - of Azure - the subscription Id, in case of MC - the organizational hierarchyId id). - :paramtype organizational_hierarchy_id: str - :keyword subscription_id: The subscription Id. - :paramtype subscription_id: str - :keyword tenant_id: The tenant Id. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.native_resource_id = native_resource_id - self.environment_hierarchy_id = environment_hierarchy_id - self.organizational_hierarchy_id = organizational_hierarchy_id - self.subscription_id = subscription_id - self.tenant_id = tenant_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 = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.security.v2023_05_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2023_05_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.security.v2023_05_01_preview.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.security.v2023_05_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class HealthDataClassification(_serialization.Model): - """The classification of the health report. - - :ivar component: The component describes the name of the agent/service that scans the issue. - :vartype component: str - :ivar scenario: The scenario describes the health scenario issue of the component. - :vartype scenario: str - :ivar scope: The resource scope of the health report. - :vartype scope: str - """ - - _attribute_map = { - "component": {"key": "component", "type": "str"}, - "scenario": {"key": "scenario", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - } - - def __init__( - self, - *, - component: Optional[str] = None, - scenario: Optional[str] = None, - scope: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword component: The component describes the name of the agent/service that scans the issue. - :paramtype component: str - :keyword scenario: The scenario describes the health scenario issue of the component. - :paramtype scenario: str - :keyword scope: The resource scope of the health report. - :paramtype scope: str - """ - super().__init__(**kwargs) - self.component = component - self.scenario = scenario - self.scope = scope - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class HealthReport(Resource): # pylint: disable=too-many-instance-attributes - """The health report resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar resource_details: The resource details of the health report. - :vartype resource_details: ~azure.mgmt.security.v2023_05_01_preview.models.ResourceDetails - :ivar environment_details: The environment details of the resource. - :vartype environment_details: - ~azure.mgmt.security.v2023_05_01_preview.models.EnvironmentDetails - :ivar health_data_classification: The classification of the health report. - :vartype health_data_classification: - ~azure.mgmt.security.v2023_05_01_preview.models.HealthDataClassification - :ivar status: The status of the health report. - :vartype status: ~azure.mgmt.security.v2023_05_01_preview.models.Status - :ivar affected_defenders_plans: The affected defenders plans by unhealthy report. - :vartype affected_defenders_plans: list[str] - :ivar affected_defenders_sub_plans: The affected defenders sub plans by unhealthy report. - :vartype affected_defenders_sub_plans: list[str] - :ivar report_additional_data: Additional data for the given health report, this field can - include more details on the resource and the health scenario. - :vartype report_additional_data: dict[str, str] - :ivar issues: A collection of the issues in the report. - :vartype issues: list[~azure.mgmt.security.v2023_05_01_preview.models.Issue] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "report_additional_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, - "environment_details": {"key": "properties.environmentDetails", "type": "EnvironmentDetails"}, - "health_data_classification": { - "key": "properties.healthDataClassification", - "type": "HealthDataClassification", - }, - "status": {"key": "properties.status", "type": "Status"}, - "affected_defenders_plans": {"key": "properties.affectedDefendersPlans", "type": "[str]"}, - "affected_defenders_sub_plans": {"key": "properties.affectedDefendersSubPlans", "type": "[str]"}, - "report_additional_data": {"key": "properties.reportAdditionalData", "type": "{str}"}, - "issues": {"key": "properties.issues", "type": "[Issue]"}, - } - - def __init__( - self, - *, - resource_details: Optional["_models.ResourceDetails"] = None, - environment_details: Optional["_models.EnvironmentDetails"] = None, - health_data_classification: Optional["_models.HealthDataClassification"] = None, - status: Optional["_models.Status"] = None, - affected_defenders_plans: Optional[List[str]] = None, - affected_defenders_sub_plans: Optional[List[str]] = None, - issues: Optional[List["_models.Issue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_details: The resource details of the health report. - :paramtype resource_details: ~azure.mgmt.security.v2023_05_01_preview.models.ResourceDetails - :keyword environment_details: The environment details of the resource. - :paramtype environment_details: - ~azure.mgmt.security.v2023_05_01_preview.models.EnvironmentDetails - :keyword health_data_classification: The classification of the health report. - :paramtype health_data_classification: - ~azure.mgmt.security.v2023_05_01_preview.models.HealthDataClassification - :keyword status: The status of the health report. - :paramtype status: ~azure.mgmt.security.v2023_05_01_preview.models.Status - :keyword affected_defenders_plans: The affected defenders plans by unhealthy report. - :paramtype affected_defenders_plans: list[str] - :keyword affected_defenders_sub_plans: The affected defenders sub plans by unhealthy report. - :paramtype affected_defenders_sub_plans: list[str] - :keyword issues: A collection of the issues in the report. - :paramtype issues: list[~azure.mgmt.security.v2023_05_01_preview.models.Issue] - """ - super().__init__(**kwargs) - self.resource_details = resource_details - self.environment_details = environment_details - self.health_data_classification = health_data_classification - self.status = status - self.affected_defenders_plans = affected_defenders_plans - self.affected_defenders_sub_plans = affected_defenders_sub_plans - self.report_additional_data = None - self.issues = issues - - -class HealthReportsList(_serialization.Model): - """Page of health reports list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of health reports in this page. - :vartype value: list[~azure.mgmt.security.v2023_05_01_preview.models.HealthReport] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[HealthReport]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class Issue(_serialization.Model): - """The issue that caused the resource to by unhealthy. - - All required parameters must be populated in order to send to server. - - :ivar issue_key: The unique issue key. Required. - :vartype issue_key: str - :ivar issue_name: The issue name. - :vartype issue_name: str - :ivar security_values: The affected security values that MDC offers that will be affected by - the issue, for example: recommendations, alerts, etc. - :vartype security_values: list[str] - :ivar issue_description: The issue description. - :vartype issue_description: str - :ivar remediation_steps: Human readable description of what you should do to mitigate this - health issue. - :vartype remediation_steps: str - :ivar remediation_script: The remediation script to solve this issue. - :vartype remediation_script: str - :ivar issue_additional_data: Additional data for the given issue. The additional data depends - on the issue type. - :vartype issue_additional_data: dict[str, str] - """ - - _validation = { - "issue_key": {"required": True}, - } - - _attribute_map = { - "issue_key": {"key": "issueKey", "type": "str"}, - "issue_name": {"key": "issueName", "type": "str"}, - "security_values": {"key": "securityValues", "type": "[str]"}, - "issue_description": {"key": "issueDescription", "type": "str"}, - "remediation_steps": {"key": "remediationSteps", "type": "str"}, - "remediation_script": {"key": "remediationScript", "type": "str"}, - "issue_additional_data": {"key": "issueAdditionalData", "type": "{str}"}, - } - - def __init__( - self, - *, - issue_key: str, - issue_name: Optional[str] = None, - security_values: Optional[List[str]] = None, - issue_description: Optional[str] = None, - remediation_steps: Optional[str] = None, - remediation_script: Optional[str] = None, - issue_additional_data: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword issue_key: The unique issue key. Required. - :paramtype issue_key: str - :keyword issue_name: The issue name. - :paramtype issue_name: str - :keyword security_values: The affected security values that MDC offers that will be affected by - the issue, for example: recommendations, alerts, etc. - :paramtype security_values: list[str] - :keyword issue_description: The issue description. - :paramtype issue_description: str - :keyword remediation_steps: Human readable description of what you should do to mitigate this - health issue. - :paramtype remediation_steps: str - :keyword remediation_script: The remediation script to solve this issue. - :paramtype remediation_script: str - :keyword issue_additional_data: Additional data for the given issue. The additional data - depends on the issue type. - :paramtype issue_additional_data: dict[str, str] - """ - super().__init__(**kwargs) - self.issue_key = issue_key - self.issue_name = issue_name - self.security_values = security_values - self.issue_description = issue_description - self.remediation_steps = remediation_steps - self.remediation_script = remediation_script - self.issue_additional_data = issue_additional_data - - -class ResourceDetails(_serialization.Model): - """The resource details of the health report. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar source: The status of the health report. Known values are: "Aws", "Gcp", and "Azure". - :vartype source: str or ~azure.mgmt.security.v2023_05_01_preview.models.Source - :ivar id: The azure id of the resource. - :vartype id: str - :ivar connector_id: The id of the connector. - :vartype connector_id: str - """ - - _validation = { - "id": {"readonly": True}, - "connector_id": {"readonly": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "connector_id": {"key": "connectorId", "type": "str"}, - } - - def __init__(self, *, source: Optional[Union[str, "_models.Source"]] = None, **kwargs: Any) -> None: - """ - :keyword source: The status of the health report. Known values are: "Aws", "Gcp", and "Azure". - :paramtype source: str or ~azure.mgmt.security.v2023_05_01_preview.models.Source - """ - super().__init__(**kwargs) - self.source = source - self.id = None - self.connector_id = None - - -class Status(_serialization.Model): - """The status of the health report. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The status of the health report. Known values are: "Healthy", "NotHealthy", and - "NotApplicable". - :vartype code: str or ~azure.mgmt.security.v2023_05_01_preview.models.StatusName - :ivar reason: The reason of the given status. - :vartype reason: str - :ivar last_scanned_date: The date of when the resource was scanned in the last time. - :vartype last_scanned_date: ~datetime.datetime - :ivar status_change_date: The date of when the status of the health report was changed in the - last time. - :vartype status_change_date: ~datetime.datetime - :ivar first_evaluation_date: The date of when the resource of the health report was scanned in - the first time. - :vartype first_evaluation_date: ~datetime.datetime - """ - - _validation = { - "reason": {"readonly": True}, - "last_scanned_date": {"readonly": True}, - "status_change_date": {"readonly": True}, - "first_evaluation_date": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "last_scanned_date": {"key": "lastScannedDate", "type": "iso-8601"}, - "status_change_date": {"key": "statusChangeDate", "type": "iso-8601"}, - "first_evaluation_date": {"key": "firstEvaluationDate", "type": "iso-8601"}, - } - - def __init__(self, *, code: Optional[Union[str, "_models.StatusName"]] = None, **kwargs: Any) -> None: - """ - :keyword code: The status of the health report. Known values are: "Healthy", "NotHealthy", and - "NotApplicable". - :paramtype code: str or ~azure.mgmt.security.v2023_05_01_preview.models.StatusName - """ - super().__init__(**kwargs) - self.code = code - self.reason = None - self.last_scanned_date = None - self.status_change_date = None - self.first_evaluation_date = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_security_center_enums.py deleted file mode 100644 index a7cdf242d64f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,26 +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 Source(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the health report.""" - - AWS = "Aws" - GCP = "Gcp" - AZURE = "Azure" - - -class StatusName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the health report.""" - - HEALTHY = "Healthy" - NOT_HEALTHY = "NotHealthy" - NOT_APPLICABLE = "NotApplicable" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/__init__.py deleted file mode 100644 index f9b535e20872..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._health_reports_operations import HealthReportsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "HealthReportsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_health_reports_operations.py deleted file mode 100644 index 583de677380d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_health_reports_operations.py +++ /dev/null @@ -1,258 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/healthReports") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True, min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_id: str, health_report_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/healthReports/{healthReportName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "healthReportName": _SERIALIZER.url( - "health_report_name", - health_report_name, - "str", - pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{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) - - -class HealthReportsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_05_01_preview.SecurityCenter`'s - :attr:`health_reports` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, scope: str, **kwargs: Any) -> Iterable["_models.HealthReport"]: - """Get a list of all health reports inside a scope. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or security connector (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. - - :param scope: The scope at which the operation is performed. Required. - :type scope: str - :return: An iterator like instance of either HealthReport or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_05_01_preview.models.HealthReport] - :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._api_version or "2023-05-01-preview") - ) - cls: ClsType[_models.HealthReportsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - scope=scope, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("HealthReportsList", 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_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: - """Get health report of resource. - - :param resource_id: The identifier of the resource. Required. - :type resource_id: str - :param health_report_name: The health report Key - Unique key for the health report type. - Required. - :type health_report_name: str - :return: HealthReport or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_05_01_preview.models.HealthReport - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-05-01-preview") - ) - cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_id=resource_id, - health_report_name=health_report_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("HealthReport", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_configuration.py deleted file mode 100644 index 5859f702059b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-09-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", "2023-09-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_metadata.json deleted file mode 100644 index c0adf7caa4a5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_metadata.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "chosen_version": "2023-09-01-preview", - "total_api_version_list": ["2023-09-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "azure_dev_ops_orgs": "AzureDevOpsOrgsOperations", - "azure_dev_ops_projects": "AzureDevOpsProjectsOperations", - "azure_dev_ops_repos": "AzureDevOpsReposOperations", - "dev_ops_configurations": "DevOpsConfigurationsOperations", - "git_hub_owners": "GitHubOwnersOperations", - "git_hub_repos": "GitHubReposOperations", - "git_lab_groups": "GitLabGroupsOperations", - "git_lab_subgroups": "GitLabSubgroupsOperations", - "git_lab_projects": "GitLabProjectsOperations", - "dev_ops_operation_results": "DevOpsOperationResultsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_security_center.py deleted file mode 100644 index 2ef2daaa4473..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_security_center.py +++ /dev/null @@ -1,177 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AzureDevOpsOrgsOperations, - AzureDevOpsProjectsOperations, - AzureDevOpsReposOperations, - DevOpsConfigurationsOperations, - DevOpsOperationResultsOperations, - GitHubOwnersOperations, - GitHubReposOperations, - GitLabGroupsOperations, - GitLabProjectsOperations, - GitLabSubgroupsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar azure_dev_ops_orgs: AzureDevOpsOrgsOperations operations - :vartype azure_dev_ops_orgs: - azure.mgmt.security.v2023_09_01_preview.operations.AzureDevOpsOrgsOperations - :ivar azure_dev_ops_projects: AzureDevOpsProjectsOperations operations - :vartype azure_dev_ops_projects: - azure.mgmt.security.v2023_09_01_preview.operations.AzureDevOpsProjectsOperations - :ivar azure_dev_ops_repos: AzureDevOpsReposOperations operations - :vartype azure_dev_ops_repos: - azure.mgmt.security.v2023_09_01_preview.operations.AzureDevOpsReposOperations - :ivar dev_ops_configurations: DevOpsConfigurationsOperations operations - :vartype dev_ops_configurations: - azure.mgmt.security.v2023_09_01_preview.operations.DevOpsConfigurationsOperations - :ivar git_hub_owners: GitHubOwnersOperations operations - :vartype git_hub_owners: - azure.mgmt.security.v2023_09_01_preview.operations.GitHubOwnersOperations - :ivar git_hub_repos: GitHubReposOperations operations - :vartype git_hub_repos: - azure.mgmt.security.v2023_09_01_preview.operations.GitHubReposOperations - :ivar git_lab_groups: GitLabGroupsOperations operations - :vartype git_lab_groups: - azure.mgmt.security.v2023_09_01_preview.operations.GitLabGroupsOperations - :ivar git_lab_subgroups: GitLabSubgroupsOperations operations - :vartype git_lab_subgroups: - azure.mgmt.security.v2023_09_01_preview.operations.GitLabSubgroupsOperations - :ivar git_lab_projects: GitLabProjectsOperations operations - :vartype git_lab_projects: - azure.mgmt.security.v2023_09_01_preview.operations.GitLabProjectsOperations - :ivar dev_ops_operation_results: DevOpsOperationResultsOperations operations - :vartype dev_ops_operation_results: - azure.mgmt.security.v2023_09_01_preview.operations.DevOpsOperationResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-09-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: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.azure_dev_ops_orgs = AzureDevOpsOrgsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.azure_dev_ops_projects = AzureDevOpsProjectsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.azure_dev_ops_repos = AzureDevOpsReposOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.dev_ops_configurations = DevOpsConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_hub_owners = GitHubOwnersOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_hub_repos = GitHubReposOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_lab_groups = GitLabGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_lab_subgroups = GitLabSubgroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_lab_projects = GitLabProjectsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.dev_ops_operation_results = DevOpsOperationResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_configuration.py deleted file mode 100644 index f59b133c8843..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-09-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", "2023-09-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_security_center.py deleted file mode 100644 index adbd4a7b08ce..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_security_center.py +++ /dev/null @@ -1,179 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AzureDevOpsOrgsOperations, - AzureDevOpsProjectsOperations, - AzureDevOpsReposOperations, - DevOpsConfigurationsOperations, - DevOpsOperationResultsOperations, - GitHubOwnersOperations, - GitHubReposOperations, - GitLabGroupsOperations, - GitLabProjectsOperations, - GitLabSubgroupsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar azure_dev_ops_orgs: AzureDevOpsOrgsOperations operations - :vartype azure_dev_ops_orgs: - azure.mgmt.security.v2023_09_01_preview.aio.operations.AzureDevOpsOrgsOperations - :ivar azure_dev_ops_projects: AzureDevOpsProjectsOperations operations - :vartype azure_dev_ops_projects: - azure.mgmt.security.v2023_09_01_preview.aio.operations.AzureDevOpsProjectsOperations - :ivar azure_dev_ops_repos: AzureDevOpsReposOperations operations - :vartype azure_dev_ops_repos: - azure.mgmt.security.v2023_09_01_preview.aio.operations.AzureDevOpsReposOperations - :ivar dev_ops_configurations: DevOpsConfigurationsOperations operations - :vartype dev_ops_configurations: - azure.mgmt.security.v2023_09_01_preview.aio.operations.DevOpsConfigurationsOperations - :ivar git_hub_owners: GitHubOwnersOperations operations - :vartype git_hub_owners: - azure.mgmt.security.v2023_09_01_preview.aio.operations.GitHubOwnersOperations - :ivar git_hub_repos: GitHubReposOperations operations - :vartype git_hub_repos: - azure.mgmt.security.v2023_09_01_preview.aio.operations.GitHubReposOperations - :ivar git_lab_groups: GitLabGroupsOperations operations - :vartype git_lab_groups: - azure.mgmt.security.v2023_09_01_preview.aio.operations.GitLabGroupsOperations - :ivar git_lab_subgroups: GitLabSubgroupsOperations operations - :vartype git_lab_subgroups: - azure.mgmt.security.v2023_09_01_preview.aio.operations.GitLabSubgroupsOperations - :ivar git_lab_projects: GitLabProjectsOperations operations - :vartype git_lab_projects: - azure.mgmt.security.v2023_09_01_preview.aio.operations.GitLabProjectsOperations - :ivar dev_ops_operation_results: DevOpsOperationResultsOperations operations - :vartype dev_ops_operation_results: - azure.mgmt.security.v2023_09_01_preview.aio.operations.DevOpsOperationResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-09-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: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.azure_dev_ops_orgs = AzureDevOpsOrgsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.azure_dev_ops_projects = AzureDevOpsProjectsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.azure_dev_ops_repos = AzureDevOpsReposOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.dev_ops_configurations = DevOpsConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_hub_owners = GitHubOwnersOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_hub_repos = GitHubReposOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_lab_groups = GitLabGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_lab_subgroups = GitLabSubgroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.git_lab_projects = GitLabProjectsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - self.dev_ops_operation_results = DevOpsOperationResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/__init__.py deleted file mode 100644 index f7948e9fc6d4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,37 +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 ._azure_dev_ops_orgs_operations import AzureDevOpsOrgsOperations -from ._azure_dev_ops_projects_operations import AzureDevOpsProjectsOperations -from ._azure_dev_ops_repos_operations import AzureDevOpsReposOperations -from ._dev_ops_configurations_operations import DevOpsConfigurationsOperations -from ._git_hub_owners_operations import GitHubOwnersOperations -from ._git_hub_repos_operations import GitHubReposOperations -from ._git_lab_groups_operations import GitLabGroupsOperations -from ._git_lab_subgroups_operations import GitLabSubgroupsOperations -from ._git_lab_projects_operations import GitLabProjectsOperations -from ._dev_ops_operation_results_operations import DevOpsOperationResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDevOpsOrgsOperations", - "AzureDevOpsProjectsOperations", - "AzureDevOpsReposOperations", - "DevOpsConfigurationsOperations", - "GitHubOwnersOperations", - "GitHubReposOperations", - "GitLabGroupsOperations", - "GitLabSubgroupsOperations", - "GitLabProjectsOperations", - "DevOpsOperationResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_orgs_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_orgs_operations.py deleted file mode 100644 index 1e279ceebf01..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_orgs_operations.py +++ /dev/null @@ -1,733 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._azure_dev_ops_orgs_operations import ( - build_create_or_update_request, - build_get_request, - build_list_available_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AzureDevOpsOrgsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`azure_dev_ops_orgs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.AzureDevOpsOrgListResponse: - """Returns a list of all Azure DevOps organizations accessible by the user token consumed by the - connector. - - Returns a list of all Azure DevOps organizations accessible by the user token consumed by the - connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: AzureDevOpsOrgListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrgListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureDevOpsOrg"]: - """Returns a list of Azure DevOps organizations onboarded to the connector. - - Returns a list of Azure DevOps organizations onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either AzureDevOpsOrg or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrgListResponse", 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, security_connector_name: str, org_name: str, **kwargs: Any - ) -> _models.AzureDevOpsOrg: - """Returns a monitored Azure DevOps organization resource. - - Returns a monitored Azure DevOps organization resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :return: AzureDevOpsOrg or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsOrg: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_org, (IOBase, bytes)): - _content = azure_dev_ops_org - else: - _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: _models.AzureDevOpsOrg, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg - :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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a - AzureDevOpsOrg type or a IO[bytes] type. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - azure_dev_ops_org=azure_dev_ops_org, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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.AzureDevOpsOrg].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsOrg]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsOrg: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_org, (IOBase, bytes)): - _content = azure_dev_ops_org - else: - _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: _models.AzureDevOpsOrg, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg - :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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a - AzureDevOpsOrg type or a IO[bytes] type. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - azure_dev_ops_org=azure_dev_ops_org, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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.AzureDevOpsOrg].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsOrg]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_projects_operations.py deleted file mode 100644 index 9e23658e479d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_projects_operations.py +++ /dev/null @@ -1,697 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._azure_dev_ops_projects_operations import ( - build_create_or_update_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AzureDevOpsProjectsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`azure_dev_ops_projects` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, org_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureDevOpsProject"]: - """Returns a list of Azure DevOps projects onboarded to the connector. - - Returns a list of Azure DevOps projects onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :return: An iterator like instance of either AzureDevOpsProject or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsProjectListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProjectListResponse", 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, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any - ) -> _models.AzureDevOpsProject: - """Returns a monitored Azure DevOps project resource. - - Returns a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: AzureDevOpsProject or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsProject: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_project, (IOBase, bytes)): - _content = azure_dev_ops_project - else: - _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: _models.AzureDevOpsProject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - :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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a - AzureDevOpsProject type or a IO[bytes] type. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - azure_dev_ops_project=azure_dev_ops_project, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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.AzureDevOpsProject].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsProject]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsProject: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_project, (IOBase, bytes)): - _content = azure_dev_ops_project - else: - _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: _models.AzureDevOpsProject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - :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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a - AzureDevOpsProject type or a IO[bytes] type. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - azure_dev_ops_project=azure_dev_ops_project, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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.AzureDevOpsProject].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsProject]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_repos_operations.py deleted file mode 100644 index 3fc87a299127..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_repos_operations.py +++ /dev/null @@ -1,736 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._azure_dev_ops_repos_operations import ( - build_create_or_update_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AzureDevOpsReposOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`azure_dev_ops_repos` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureDevOpsRepository"]: - """Returns a list of Azure DevOps repositories onboarded to the connector. - - Returns a list of Azure DevOps repositories onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: An iterator like instance of either AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsRepositoryListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepositoryListResponse", 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, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - """Returns a monitored Azure DevOps repository resource. - - Returns a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :return: AzureDevOpsRepository or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_repository, (IOBase, bytes)): - _content = azure_dev_ops_repository - else: - _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: _models.AzureDevOpsRepository, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository - :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 AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a - AzureDevOpsRepository type or a IO[bytes] type. Required. - :type azure_dev_ops_repository: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - azure_dev_ops_repository=azure_dev_ops_repository, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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.AzureDevOpsRepository].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsRepository]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_repository, (IOBase, bytes)): - _content = azure_dev_ops_repository - else: - _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: _models.AzureDevOpsRepository, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository - :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 AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a - AzureDevOpsRepository type or a IO[bytes] type. Required. - :type azure_dev_ops_repository: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - azure_dev_ops_repository=azure_dev_ops_repository, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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.AzureDevOpsRepository].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsRepository]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_configurations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_configurations_operations.py deleted file mode 100644 index f5ef187309a5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_configurations_operations.py +++ /dev/null @@ -1,749 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._dev_ops_configurations_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DevOpsConfigurationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`dev_ops_configurations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DevOpsConfiguration"]: - """List DevOps Configurations. - - List DevOps Configurations. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either DevOpsConfiguration or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.DevOpsConfigurationListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DevOpsConfigurationListResponse", 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, security_connector_name: str, **kwargs: Any - ) -> _models.DevOpsConfiguration: - """Gets a DevOps Configuration. - - Gets a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: DevOpsConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.DevOpsConfiguration: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(dev_ops_configuration, (IOBase, bytes)): - _content = dev_ops_configuration - else: - _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: _models.DevOpsConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration - :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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: 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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Is either a - DevOpsConfiguration type or a IO[bytes] type. Required. - :type dev_ops_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = 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, - security_connector_name=security_connector_name, - dev_ops_configuration=dev_ops_configuration, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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.DevOpsConfiguration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DevOpsConfiguration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.DevOpsConfiguration: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(dev_ops_configuration, (IOBase, bytes)): - _content = dev_ops_configuration - else: - _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: _models.DevOpsConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration - :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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: 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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Is either a - DevOpsConfiguration type or a IO[bytes] type. Required. - :type dev_ops_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = 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, - security_connector_name=security_connector_name, - dev_ops_configuration=dev_ops_configuration, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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.DevOpsConfiguration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DevOpsConfiguration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a DevOps Connector. - - Deletes a DevOps Connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_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._api_version or "2023-09-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_operation_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_operation_results_operations.py deleted file mode 100644 index 5c614e749a62..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_operation_results_operations.py +++ /dev/null @@ -1,123 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._dev_ops_operation_results_operations import build_get_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DevOpsOperationResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`dev_ops_operation_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, resource_group_name: str, security_connector_name: str, operation_result_id: str, **kwargs: Any - ) -> _models.OperationStatusResult: - """Get devops long running operation result. - - Get devops long running operation result. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param operation_result_id: The operation result Id. Required. - :type operation_result_id: str - :return: OperationStatusResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.OperationStatusResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - operation_result_id=operation_result_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatusResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_owners_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_owners_operations.py deleted file mode 100644 index 8e7737733588..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_owners_operations.py +++ /dev/null @@ -1,280 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_hub_owners_operations import build_get_request, build_list_available_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitHubOwnersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`git_hub_owners` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.GitHubOwnerListResponse: - """Returns a list of all GitHub owners accessible by the user token consumed by the connector. - - Returns a list of all GitHub owners accessible by the user token consumed by the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: GitHubOwnerListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwnerListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GitHubOwner"]: - """Returns a list of GitHub owners onboarded to the connector. - - Returns a list of GitHub owners onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either GitHubOwner or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GitHubOwnerListResponse", 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, security_connector_name: str, owner_name: str, **kwargs: Any - ) -> _models.GitHubOwner: - """Returns a monitored GitHub owner. - - Returns a monitored GitHub owner. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :return: GitHubOwner or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubOwner] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubOwner", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_repos_operations.py deleted file mode 100644 index 22cbc95cb5b7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_repos_operations.py +++ /dev/null @@ -1,223 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_hub_repos_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitHubReposOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`git_hub_repos` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, owner_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GitHubRepository"]: - """Returns a list of GitHub repositories onboarded to the connector. - - Returns a list of GitHub repositories onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :return: An iterator like instance of either GitHubRepository or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubRepositoryListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GitHubRepositoryListResponse", 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, security_connector_name: str, owner_name: str, repo_name: str, **kwargs: Any - ) -> _models.GitHubRepository: - """Returns a monitored GitHub repository. - - Returns a monitored GitHub repository. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :return: GitHubRepository or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubRepository] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_groups_operations.py deleted file mode 100644 index 748dfd88c04f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_groups_operations.py +++ /dev/null @@ -1,280 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_lab_groups_operations import build_get_request, build_list_available_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitLabGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`git_lab_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.GitLabGroupListResponse: - """Returns a list of all GitLab groups accessible by the user token consumed by the connector. - - Returns a list of all GitLab groups accessible by the user token consumed by the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: GitLabGroupListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GitLabGroup"]: - """Returns a list of GitLab groups onboarded to the connector. - - Returns a list of GitLab groups onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either GitLabGroup or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GitLabGroupListResponse", 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, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> _models.GitLabGroup: - """Returns a monitored GitLab Group resource for a given fully-qualified name. - - Returns a monitored GitLab Group resource for a given fully-qualified name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: GitLabGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_projects_operations.py deleted file mode 100644 index 5baa86d47d47..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_projects_operations.py +++ /dev/null @@ -1,232 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_lab_projects_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitLabProjectsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`git_lab_projects` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GitLabProject"]: - """Gets a list of GitLab projects that are directly owned by given group and onboarded to the - connector. - - Gets a list of GitLab projects that are directly owned by given group and onboarded to the - connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: An iterator like instance of either GitLabProject or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabProjectListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GitLabProjectListResponse", 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, - security_connector_name: str, - group_fq_name: str, - project_name: str, - **kwargs: Any - ) -> _models.GitLabProject: - """Returns a monitored GitLab Project resource for a given fully-qualified group name and project - name. - - Returns a monitored GitLab Project resource for a given fully-qualified group name and project - name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: GitLabProject or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabProject] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_subgroups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_subgroups_operations.py deleted file mode 100644 index b59c5cd0eeb5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_subgroups_operations.py +++ /dev/null @@ -1,123 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_lab_subgroups_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitLabSubgroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s - :attr:`git_lab_subgroups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list( - self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> _models.GitLabGroupListResponse: - """Gets nested subgroups of given GitLab Group which are onboarded to the connector. - - Gets nested subgroups of given GitLab Group which are onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: GitLabGroupListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/__init__.py deleted file mode 100644 index 2153763afd16..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/__init__.py +++ /dev/null @@ -1,115 +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 ._models_py3 import ActionableRemediation -from ._models_py3 import Authorization -from ._models_py3 import AzureDevOpsOrg -from ._models_py3 import AzureDevOpsOrgListResponse -from ._models_py3 import AzureDevOpsOrgProperties -from ._models_py3 import AzureDevOpsOrganizationConfiguration -from ._models_py3 import AzureDevOpsProject -from ._models_py3 import AzureDevOpsProjectConfiguration -from ._models_py3 import AzureDevOpsProjectListResponse -from ._models_py3 import AzureDevOpsProjectProperties -from ._models_py3 import AzureDevOpsRepository -from ._models_py3 import AzureDevOpsRepositoryListResponse -from ._models_py3 import AzureDevOpsRepositoryProperties -from ._models_py3 import BaseResourceConfiguration -from ._models_py3 import CategoryConfiguration -from ._models_py3 import DevOpsConfiguration -from ._models_py3 import DevOpsConfigurationListResponse -from ._models_py3 import DevOpsConfigurationProperties -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import GitHubOwner -from ._models_py3 import GitHubOwnerConfiguration -from ._models_py3 import GitHubOwnerListResponse -from ._models_py3 import GitHubOwnerProperties -from ._models_py3 import GitHubRepository -from ._models_py3 import GitHubRepositoryListResponse -from ._models_py3 import GitHubRepositoryProperties -from ._models_py3 import GitLabGroup -from ._models_py3 import GitLabGroupConfiguration -from ._models_py3 import GitLabGroupListResponse -from ._models_py3 import GitLabGroupProperties -from ._models_py3 import GitLabProject -from ._models_py3 import GitLabProjectListResponse -from ._models_py3 import GitLabProjectProperties -from ._models_py3 import OperationStatusResult -from ._models_py3 import ProxyResource -from ._models_py3 import Resource -from ._models_py3 import SystemData -from ._models_py3 import TargetBranchConfiguration - -from ._security_center_enums import ActionableRemediationState -from ._security_center_enums import AnnotateDefaultBranchState -from ._security_center_enums import AutoDiscovery -from ._security_center_enums import CreatedByType -from ._security_center_enums import DesiredOnboardingState -from ._security_center_enums import DevOpsProvisioningState -from ._security_center_enums import InheritFromParentState -from ._security_center_enums import OnboardingState -from ._security_center_enums import RuleCategory -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionableRemediation", - "Authorization", - "AzureDevOpsOrg", - "AzureDevOpsOrgListResponse", - "AzureDevOpsOrgProperties", - "AzureDevOpsOrganizationConfiguration", - "AzureDevOpsProject", - "AzureDevOpsProjectConfiguration", - "AzureDevOpsProjectListResponse", - "AzureDevOpsProjectProperties", - "AzureDevOpsRepository", - "AzureDevOpsRepositoryListResponse", - "AzureDevOpsRepositoryProperties", - "BaseResourceConfiguration", - "CategoryConfiguration", - "DevOpsConfiguration", - "DevOpsConfigurationListResponse", - "DevOpsConfigurationProperties", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "GitHubOwner", - "GitHubOwnerConfiguration", - "GitHubOwnerListResponse", - "GitHubOwnerProperties", - "GitHubRepository", - "GitHubRepositoryListResponse", - "GitHubRepositoryProperties", - "GitLabGroup", - "GitLabGroupConfiguration", - "GitLabGroupListResponse", - "GitLabGroupProperties", - "GitLabProject", - "GitLabProjectListResponse", - "GitLabProjectProperties", - "OperationStatusResult", - "ProxyResource", - "Resource", - "SystemData", - "TargetBranchConfiguration", - "ActionableRemediationState", - "AnnotateDefaultBranchState", - "AutoDiscovery", - "CreatedByType", - "DesiredOnboardingState", - "DevOpsProvisioningState", - "InheritFromParentState", - "OnboardingState", - "RuleCategory", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_models_py3.py deleted file mode 100644 index 029ed58a7818..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_models_py3.py +++ /dev/null @@ -1,2111 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionableRemediation(_serialization.Model): - """Configuration payload for PR Annotations. - - :ivar state: ActionableRemediation Setting. - None - the setting was never set. - Enabled - ActionableRemediation is enabled. - Disabled - ActionableRemediation is disabled. Known values are: "None", "Disabled", and - "Enabled". - :vartype state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediationState - :ivar category_configurations: Gets or sets list of categories and severity levels. - :vartype category_configurations: - list[~azure.mgmt.security.v2023_09_01_preview.models.CategoryConfiguration] - :ivar branch_configuration: Repository branch configuration for PR Annotations. - :vartype branch_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.TargetBranchConfiguration - :ivar inherit_from_parent_state: Update Settings. - - Enabled - Resource should inherit configurations from parent. - Disabled - Resource should not inherit configurations from parent. Known values are: - "Disabled" and "Enabled". - :vartype inherit_from_parent_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.InheritFromParentState - """ - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "category_configurations": {"key": "categoryConfigurations", "type": "[CategoryConfiguration]"}, - "branch_configuration": {"key": "branchConfiguration", "type": "TargetBranchConfiguration"}, - "inherit_from_parent_state": {"key": "inheritFromParentState", "type": "str"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.ActionableRemediationState"]] = None, - category_configurations: Optional[List["_models.CategoryConfiguration"]] = None, - branch_configuration: Optional["_models.TargetBranchConfiguration"] = None, - inherit_from_parent_state: Optional[Union[str, "_models.InheritFromParentState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: ActionableRemediation Setting. - None - the setting was never set. - Enabled - ActionableRemediation is enabled. - Disabled - ActionableRemediation is disabled. Known values are: "None", "Disabled", and - "Enabled". - :paramtype state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediationState - :keyword category_configurations: Gets or sets list of categories and severity levels. - :paramtype category_configurations: - list[~azure.mgmt.security.v2023_09_01_preview.models.CategoryConfiguration] - :keyword branch_configuration: Repository branch configuration for PR Annotations. - :paramtype branch_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.TargetBranchConfiguration - :keyword inherit_from_parent_state: Update Settings. - - Enabled - Resource should inherit configurations from parent. - Disabled - Resource should not inherit configurations from parent. Known values are: - "Disabled" and "Enabled". - :paramtype inherit_from_parent_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.InheritFromParentState - """ - super().__init__(**kwargs) - self.state = state - self.category_configurations = category_configurations - self.branch_configuration = branch_configuration - self.inherit_from_parent_state = inherit_from_parent_state - - -class Authorization(_serialization.Model): - """Authorization payload. - - :ivar code: Gets or sets one-time OAuth code to exchange for refresh and access tokens. - - Only used during PUT/PATCH operations. The secret is cleared during GET. - :vartype code: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Gets or sets one-time OAuth code to exchange for refresh and access tokens. - - Only used during PUT/PATCH operations. The secret is cleared during GET. - :paramtype code: str - """ - super().__init__(**kwargs) - self.code = code - - -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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - -class AzureDevOpsOrg(ProxyResource): - """Azure DevOps Organization 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData - :ivar properties: Azure DevOps Organization properties. - :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrgProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "AzureDevOpsOrgProperties"}, - } - - def __init__(self, *, properties: Optional["_models.AzureDevOpsOrgProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Azure DevOps Organization properties. - :paramtype properties: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrgProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class AzureDevOpsOrganizationConfiguration(_serialization.Model): - """AzureDevOps Org Inventory Configuration. - - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :ivar project_configs: AzureDevOps Project Inventory Configuration. - Dictionary of AzureDevOps project name to desired project configuration. - If AutoDiscovery is Enabled, this field should be empty or null. - :vartype project_configs: dict[str, - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProjectConfiguration] - """ - - _attribute_map = { - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "project_configs": {"key": "projectConfigs", "type": "{AzureDevOpsProjectConfiguration}"}, - } - - def __init__( - self, - *, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - project_configs: Optional[Dict[str, "_models.AzureDevOpsProjectConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :keyword project_configs: AzureDevOps Project Inventory Configuration. - Dictionary of AzureDevOps project name to desired project configuration. - If AutoDiscovery is Enabled, this field should be empty or null. - :paramtype project_configs: dict[str, - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProjectConfiguration] - """ - super().__init__(**kwargs) - self.auto_discovery = auto_discovery - self.project_configs = project_configs - - -class AzureDevOpsOrgListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AzureDevOpsOrg]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.AzureDevOpsOrg"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AzureDevOpsOrgProperties(_serialization.Model): - """Azure DevOps Organization properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - :ivar actionable_remediation: Configuration payload for PR Annotations. - :vartype actionable_remediation: - ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - actionable_remediation: Optional["_models.ActionableRemediation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - :keyword actionable_remediation: Configuration payload for PR Annotations. - :paramtype actionable_remediation: - ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.onboarding_state = onboarding_state - self.actionable_remediation = actionable_remediation - - -class AzureDevOpsProject(ProxyResource): - """Azure DevOps Project 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData - :ivar properties: Azure DevOps Project properties. - :vartype properties: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProjectProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "AzureDevOpsProjectProperties"}, - } - - def __init__(self, *, properties: Optional["_models.AzureDevOpsProjectProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Azure DevOps Project properties. - :paramtype properties: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProjectProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class AzureDevOpsProjectConfiguration(_serialization.Model): - """AzureDevOps Project Inventory Configuration. - - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :ivar repository_configs: AzureDevOps Repository Inventory Configuration. - Dictionary of AzureDevOps repository name to desired repository configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :vartype repository_configs: dict[str, - ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] - """ - - _attribute_map = { - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "repository_configs": {"key": "repositoryConfigs", "type": "{BaseResourceConfiguration}"}, - } - - def __init__( - self, - *, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - repository_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :keyword repository_configs: AzureDevOps Repository Inventory Configuration. - Dictionary of AzureDevOps repository name to desired repository configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :paramtype repository_configs: dict[str, - ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] - """ - super().__init__(**kwargs) - self.auto_discovery = auto_discovery - self.repository_configs = repository_configs - - -class AzureDevOpsProjectListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AzureDevOpsProject]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AzureDevOpsProject"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AzureDevOpsProjectProperties(_serialization.Model): - """Azure DevOps Project properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :ivar parent_org_name: Gets or sets parent Azure DevOps Organization name. - :vartype parent_org_name: str - :ivar project_id: Gets or sets Azure DevOps Project id. - :vartype project_id: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - :ivar actionable_remediation: Configuration payload for PR Annotations. - :vartype actionable_remediation: - ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "project_id": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "parent_org_name": {"key": "parentOrgName", "type": "str"}, - "project_id": {"key": "projectId", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - parent_org_name: Optional[str] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - actionable_remediation: Optional["_models.ActionableRemediation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :keyword parent_org_name: Gets or sets parent Azure DevOps Organization name. - :paramtype parent_org_name: str - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - :keyword actionable_remediation: Configuration payload for PR Annotations. - :paramtype actionable_remediation: - ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.parent_org_name = parent_org_name - self.project_id = None - self.onboarding_state = onboarding_state - self.actionable_remediation = actionable_remediation - - -class AzureDevOpsRepository(ProxyResource): - """Azure DevOps Repository 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData - :ivar properties: Azure DevOps Repository properties. - :vartype properties: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepositoryProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "AzureDevOpsRepositoryProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.AzureDevOpsRepositoryProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Azure DevOps Repository properties. - :paramtype properties: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepositoryProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class AzureDevOpsRepositoryListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AzureDevOpsRepository]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AzureDevOpsRepository"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AzureDevOpsRepositoryProperties(_serialization.Model): - """Azure DevOps Repository properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :ivar parent_org_name: Gets or sets parent Azure DevOps Organization name. - :vartype parent_org_name: str - :ivar parent_project_name: Gets or sets parent Azure DevOps Project name. - :vartype parent_project_name: str - :ivar repo_id: Gets or sets Azure DevOps Repository id. - :vartype repo_id: str - :ivar repo_url: Gets or sets Azure DevOps Repository url. - :vartype repo_url: str - :ivar visibility: Gets or sets Azure DevOps repository visibility, whether it is public or - private etc. - :vartype visibility: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - :ivar actionable_remediation: Configuration payload for PR Annotations. - :vartype actionable_remediation: - ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "repo_id": {"readonly": True}, - "repo_url": {"readonly": True}, - "visibility": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "parent_org_name": {"key": "parentOrgName", "type": "str"}, - "parent_project_name": {"key": "parentProjectName", "type": "str"}, - "repo_id": {"key": "repoId", "type": "str"}, - "repo_url": {"key": "repoUrl", "type": "str"}, - "visibility": {"key": "visibility", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - parent_org_name: Optional[str] = None, - parent_project_name: Optional[str] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - actionable_remediation: Optional["_models.ActionableRemediation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :keyword parent_org_name: Gets or sets parent Azure DevOps Organization name. - :paramtype parent_org_name: str - :keyword parent_project_name: Gets or sets parent Azure DevOps Project name. - :paramtype parent_project_name: str - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - :keyword actionable_remediation: Configuration payload for PR Annotations. - :paramtype actionable_remediation: - ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.parent_org_name = parent_org_name - self.parent_project_name = parent_project_name - self.repo_id = None - self.repo_url = None - self.visibility = None - self.onboarding_state = onboarding_state - self.actionable_remediation = actionable_remediation - - -class BaseResourceConfiguration(_serialization.Model): - """Base Resource Inventory configuration changes. - - :ivar desired_onboarding_state: Onboarding states. Known values are: "Disabled" and "Enabled". - :vartype desired_onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DesiredOnboardingState - """ - - _attribute_map = { - "desired_onboarding_state": {"key": "desiredOnboardingState", "type": "str"}, - } - - def __init__( - self, *, desired_onboarding_state: Optional[Union[str, "_models.DesiredOnboardingState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword desired_onboarding_state: Onboarding states. Known values are: "Disabled" and - "Enabled". - :paramtype desired_onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DesiredOnboardingState - """ - super().__init__(**kwargs) - self.desired_onboarding_state = desired_onboarding_state - - -class CategoryConfiguration(_serialization.Model): - """Severity level per category configuration for PR Annotations. - - :ivar minimum_severity_level: Gets or sets minimum severity level for a given category. - :vartype minimum_severity_level: str - :ivar category: Rule categories. - Code - code scanning results. - Artifact scanning results. - Dependencies scanning results. - IaC results. - Secrets scanning results. - Container scanning results. Known values are: "Code", "Artifacts", "Dependencies", "Secrets", - "IaC", and "Containers". - :vartype category: str or ~azure.mgmt.security.v2023_09_01_preview.models.RuleCategory - """ - - _attribute_map = { - "minimum_severity_level": {"key": "minimumSeverityLevel", "type": "str"}, - "category": {"key": "category", "type": "str"}, - } - - def __init__( - self, - *, - minimum_severity_level: Optional[str] = None, - category: Optional[Union[str, "_models.RuleCategory"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword minimum_severity_level: Gets or sets minimum severity level for a given category. - :paramtype minimum_severity_level: str - :keyword category: Rule categories. - Code - code scanning results. - Artifact scanning results. - Dependencies scanning results. - IaC results. - Secrets scanning results. - Container scanning results. Known values are: "Code", "Artifacts", "Dependencies", "Secrets", - "IaC", and "Containers". - :paramtype category: str or ~azure.mgmt.security.v2023_09_01_preview.models.RuleCategory - """ - super().__init__(**kwargs) - self.minimum_severity_level = minimum_severity_level - self.category = category - - -class DevOpsConfiguration(ProxyResource): - """DevOps Configuration 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData - :ivar properties: DevOps Configuration properties. - :vartype properties: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfigurationProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "DevOpsConfigurationProperties"}, - } - - def __init__(self, *, properties: Optional["_models.DevOpsConfigurationProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: DevOps Configuration properties. - :paramtype properties: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfigurationProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class DevOpsConfigurationListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DevOpsConfiguration]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.DevOpsConfiguration"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DevOpsConfigurationProperties(_serialization.Model): - """DevOps Configuration properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :ivar authorization: Authorization payload. - :vartype authorization: ~azure.mgmt.security.v2023_09_01_preview.models.Authorization - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :ivar top_level_inventory_list: List of top-level inventory to select when AutoDiscovery is - disabled. - This field is ignored when AutoDiscovery is enabled. - :vartype top_level_inventory_list: list[str] - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "authorization": {"key": "authorization", "type": "Authorization"}, - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "top_level_inventory_list": {"key": "topLevelInventoryList", "type": "[str]"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - authorization: Optional["_models.Authorization"] = None, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - top_level_inventory_list: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :keyword authorization: Authorization payload. - :paramtype authorization: ~azure.mgmt.security.v2023_09_01_preview.models.Authorization - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :keyword top_level_inventory_list: List of top-level inventory to select when AutoDiscovery is - disabled. - This field is ignored when AutoDiscovery is enabled. - :paramtype top_level_inventory_list: list[str] - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.authorization = authorization - self.auto_discovery = auto_discovery - self.top_level_inventory_list = top_level_inventory_list - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.security.v2023_09_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2023_09_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.security.v2023_09_01_preview.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.security.v2023_09_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class GitHubOwner(ProxyResource): - """GitHub Owner 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData - :ivar properties: GitHub Owner properties. - :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwnerProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "GitHubOwnerProperties"}, - } - - def __init__(self, *, properties: Optional["_models.GitHubOwnerProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: GitHub Owner properties. - :paramtype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwnerProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class GitHubOwnerConfiguration(_serialization.Model): - """GitHub Owner Inventory Configuration. - - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :ivar repository_configs: GitHub Repository Inventory Configuration. - Dictionary of GitHub repository name to desired repository configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :vartype repository_configs: dict[str, - ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] - """ - - _attribute_map = { - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "repository_configs": {"key": "repositoryConfigs", "type": "{BaseResourceConfiguration}"}, - } - - def __init__( - self, - *, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - repository_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :keyword repository_configs: GitHub Repository Inventory Configuration. - Dictionary of GitHub repository name to desired repository configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :paramtype repository_configs: dict[str, - ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] - """ - super().__init__(**kwargs) - self.auto_discovery = auto_discovery - self.repository_configs = repository_configs - - -class GitHubOwnerListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GitHubOwner]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.GitHubOwner"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GitHubOwnerProperties(_serialization.Model): - """GitHub Owner properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :ivar owner_url: Gets or sets GitHub Owner url. - :vartype owner_url: str - :ivar git_hub_internal_id: Gets or sets internal GitHub id. - :vartype git_hub_internal_id: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "owner_url": {"readonly": True}, - "git_hub_internal_id": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "owner_url": {"key": "ownerUrl", "type": "str"}, - "git_hub_internal_id": {"key": "gitHubInternalId", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.owner_url = None - self.git_hub_internal_id = None - self.onboarding_state = onboarding_state - - -class GitHubRepository(ProxyResource): - """GitHub Repository 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData - :ivar properties: GitHub Repository properties. - :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepositoryProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "GitHubRepositoryProperties"}, - } - - def __init__(self, *, properties: Optional["_models.GitHubRepositoryProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: GitHub Repository properties. - :paramtype properties: - ~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepositoryProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class GitHubRepositoryListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GitHubRepository]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.GitHubRepository"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GitHubRepositoryProperties(_serialization.Model): - """GitHub Repository properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :ivar repo_id: Gets or sets GitHub Repository id. - - This is a numeric id defined by Github. - Eg: "123456". - :vartype repo_id: str - :ivar repo_name: Gets or sets GitHub Repository name. - Eg: "new-repo-1". - :vartype repo_name: str - :ivar repo_full_name: Gets or sets GitHub Full Name. - Repository name, prefixed with Owner name. - Eg: "my-org/new-repo-1". - :vartype repo_full_name: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - :ivar repo_url: Gets or sets GitHub Repository url. - :vartype repo_url: str - :ivar parent_owner_name: Gets or sets parent GitHub Owner name. - :vartype parent_owner_name: str - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "repo_id": {"readonly": True}, - "repo_name": {"readonly": True}, - "repo_full_name": {"readonly": True}, - "repo_url": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "repo_id": {"key": "repoId", "type": "str"}, - "repo_name": {"key": "repoName", "type": "str"}, - "repo_full_name": {"key": "repoFullName", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - "repo_url": {"key": "repoUrl", "type": "str"}, - "parent_owner_name": {"key": "parentOwnerName", "type": "str"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - parent_owner_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - :keyword parent_owner_name: Gets or sets parent GitHub Owner name. - :paramtype parent_owner_name: str - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.repo_id = None - self.repo_name = None - self.repo_full_name = None - self.onboarding_state = onboarding_state - self.repo_url = None - self.parent_owner_name = parent_owner_name - - -class GitLabGroup(ProxyResource): - """GitLab Group 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData - :ivar properties: GitLab Group properties. - :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "GitLabGroupProperties"}, - } - - def __init__(self, *, properties: Optional["_models.GitLabGroupProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: GitLab Group properties. - :paramtype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class GitLabGroupConfiguration(_serialization.Model): - """GitLab Group Inventory Configuration. - - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :ivar project_configs: GitLab Project Inventory Configuration. - Dictionary of GitLab fully-qualified project name to desired project configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :vartype project_configs: dict[str, - ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] - """ - - _attribute_map = { - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "project_configs": {"key": "projectConfigs", "type": "{BaseResourceConfiguration}"}, - } - - def __init__( - self, - *, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - project_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery - :keyword project_configs: GitLab Project Inventory Configuration. - Dictionary of GitLab fully-qualified project name to desired project configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :paramtype project_configs: dict[str, - ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] - """ - super().__init__(**kwargs) - self.auto_discovery = auto_discovery - self.project_configs = project_configs - - -class GitLabGroupListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GitLabGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.GitLabGroup"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GitLabGroupProperties(_serialization.Model): - """GitLab Group properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :ivar fully_qualified_name: Gets or sets the fully-qualified name of the Group object. - - This contains the entire namespace hierarchy where namespaces are separated by the '$' - character. - :vartype fully_qualified_name: str - :ivar fully_qualified_friendly_name: Gets or sets the human readable fully-qualified name of - the Group object. - - This contains the entire namespace hierarchy as seen on GitLab UI where namespaces are - separated by the '/' character. - :vartype fully_qualified_friendly_name: str - :ivar url: Gets or sets the url of the GitLab Group. - :vartype url: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "fully_qualified_name": {"readonly": True}, - "fully_qualified_friendly_name": {"readonly": True}, - "url": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "fully_qualified_name": {"key": "fullyQualifiedName", "type": "str"}, - "fully_qualified_friendly_name": {"key": "fullyQualifiedFriendlyName", "type": "str"}, - "url": {"key": "url", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.fully_qualified_name = None - self.fully_qualified_friendly_name = None - self.url = None - self.onboarding_state = onboarding_state - - -class GitLabProject(ProxyResource): - """GitLab Project 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData - :ivar properties: GitLab Project properties. - :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabProjectProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "GitLabProjectProperties"}, - } - - def __init__(self, *, properties: Optional["_models.GitLabProjectProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: GitLab Project properties. - :paramtype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabProjectProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class GitLabProjectListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GitLabProject]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.GitLabProject"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GitLabProjectProperties(_serialization.Model): - """GitLab Project properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :ivar fully_qualified_name: Gets or sets the fully-qualified name of the project object. - - This contains the entire hierarchy where entities are separated by the '$' character. - :vartype fully_qualified_name: str - :ivar fully_qualified_friendly_name: Gets or sets the human readable fully-qualified name of - the Project object. - - This contains the entire namespace hierarchy as seen on GitLab UI where entities are separated - by the '/' character. - :vartype fully_qualified_friendly_name: str - :ivar fully_qualified_parent_group_name: Gets or sets the fully-qualified name of the project's - parent group object. - - This contains the entire hierarchy where namespaces are separated by the '$' character. - :vartype fully_qualified_parent_group_name: str - :ivar url: Gets or sets the url of the GitLab Project. - :vartype url: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "fully_qualified_name": {"readonly": True}, - "fully_qualified_friendly_name": {"readonly": True}, - "fully_qualified_parent_group_name": {"readonly": True}, - "url": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "fully_qualified_name": {"key": "fullyQualifiedName", "type": "str"}, - "fully_qualified_friendly_name": {"key": "fullyQualifiedFriendlyName", "type": "str"}, - "fully_qualified_parent_group_name": {"key": "fullyQualifiedParentGroupName", "type": "str"}, - "url": {"key": "url", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or - ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.fully_qualified_name = None - self.fully_qualified_friendly_name = None - self.fully_qualified_parent_group_name = None - self.url = None - self.onboarding_state = onboarding_state - - -class OperationStatusResult(_serialization.Model): - """The current status of an async operation. - - 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 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.security.v2023_09_01_preview.models.OperationStatusResult] - :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.security.v2023_09_01_preview.models.ErrorDetail - """ - - _validation = { - "status": {"required": True}, - "percent_complete": {"maximum": 100, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "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.security.v2023_09_01_preview.models.OperationStatusResult] - :keyword error: If present, details of the operation error. - :paramtype error: ~azure.mgmt.security.v2023_09_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.id = id - 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 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.security.v2023_09_01_preview.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.security.v2023_09_01_preview.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.security.v2023_09_01_preview.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.security.v2023_09_01_preview.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 TargetBranchConfiguration(_serialization.Model): - """Repository branch configuration for PR Annotations. - - :ivar branch_names: Gets or sets branches that should have annotations. - :vartype branch_names: list[str] - :ivar annotate_default_branch: Configuration of PR Annotations on default branch. - - Enabled - PR Annotations are enabled on the resource's default branch. - Disabled - PR Annotations are disabled on the resource's default branch. Known values are: - "Disabled" and "Enabled". - :vartype annotate_default_branch: str or - ~azure.mgmt.security.v2023_09_01_preview.models.AnnotateDefaultBranchState - """ - - _attribute_map = { - "branch_names": {"key": "branchNames", "type": "[str]"}, - "annotate_default_branch": {"key": "annotateDefaultBranch", "type": "str"}, - } - - def __init__( - self, - *, - branch_names: Optional[List[str]] = None, - annotate_default_branch: Optional[Union[str, "_models.AnnotateDefaultBranchState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword branch_names: Gets or sets branches that should have annotations. - :paramtype branch_names: list[str] - :keyword annotate_default_branch: Configuration of PR Annotations on default branch. - - Enabled - PR Annotations are enabled on the resource's default branch. - Disabled - PR Annotations are disabled on the resource's default branch. Known values are: - "Disabled" and "Enabled". - :paramtype annotate_default_branch: str or - ~azure.mgmt.security.v2023_09_01_preview.models.AnnotateDefaultBranchState - """ - super().__init__(**kwargs) - self.branch_names = branch_names - self.annotate_default_branch = annotate_default_branch diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_security_center_enums.py deleted file mode 100644 index 3744941c0212..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,123 +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 ActionableRemediationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ActionableRemediation Setting. - None - the setting was never set. - Enabled - ActionableRemediation is enabled. - Disabled - ActionableRemediation is disabled. - """ - - NONE = "None" - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class AnnotateDefaultBranchState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Configuration of PR Annotations on default branch. - - Enabled - PR Annotations are enabled on the resource's default branch. - Disabled - PR Annotations are disabled on the resource's default branch. - """ - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class AutoDiscovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AutoDiscovery states.""" - - DISABLED = "Disabled" - ENABLED = "Enabled" - NOT_APPLICABLE = "NotApplicable" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class DesiredOnboardingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Onboarding states.""" - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class DevOpsProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. - """ - - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - PENDING = "Pending" - PENDING_DELETION = "PendingDeletion" - DELETION_SUCCESS = "DeletionSuccess" - DELETION_FAILURE = "DeletionFailure" - - -class InheritFromParentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Update Settings. - - Enabled - Resource should inherit configurations from parent. - Disabled - Resource should not inherit configurations from parent. - """ - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class OnboardingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. This - is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. - """ - - NOT_APPLICABLE = "NotApplicable" - ONBOARDED_BY_OTHER_CONNECTOR = "OnboardedByOtherConnector" - ONBOARDED = "Onboarded" - NOT_ONBOARDED = "NotOnboarded" - - -class RuleCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule categories. - Code - code scanning results. - Artifact scanning results. - Dependencies scanning results. - IaC results. - Secrets scanning results. - Container scanning results. - """ - - CODE = "Code" - ARTIFACTS = "Artifacts" - DEPENDENCIES = "Dependencies" - SECRETS = "Secrets" - IA_C = "IaC" - CONTAINERS = "Containers" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/__init__.py deleted file mode 100644 index f7948e9fc6d4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/__init__.py +++ /dev/null @@ -1,37 +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 ._azure_dev_ops_orgs_operations import AzureDevOpsOrgsOperations -from ._azure_dev_ops_projects_operations import AzureDevOpsProjectsOperations -from ._azure_dev_ops_repos_operations import AzureDevOpsReposOperations -from ._dev_ops_configurations_operations import DevOpsConfigurationsOperations -from ._git_hub_owners_operations import GitHubOwnersOperations -from ._git_hub_repos_operations import GitHubReposOperations -from ._git_lab_groups_operations import GitLabGroupsOperations -from ._git_lab_subgroups_operations import GitLabSubgroupsOperations -from ._git_lab_projects_operations import GitLabProjectsOperations -from ._dev_ops_operation_results_operations import DevOpsOperationResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDevOpsOrgsOperations", - "AzureDevOpsProjectsOperations", - "AzureDevOpsReposOperations", - "DevOpsConfigurationsOperations", - "GitHubOwnersOperations", - "GitHubReposOperations", - "GitLabGroupsOperations", - "GitLabSubgroupsOperations", - "GitLabProjectsOperations", - "DevOpsOperationResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_orgs_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_orgs_operations.py deleted file mode 100644 index d0c07013a758..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_orgs_operations.py +++ /dev/null @@ -1,901 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_available_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableAzureDevOpsOrgs", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( - resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_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) - - -class AzureDevOpsOrgsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`azure_dev_ops_orgs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.AzureDevOpsOrgListResponse: - """Returns a list of all Azure DevOps organizations accessible by the user token consumed by the - connector. - - Returns a list of all Azure DevOps organizations accessible by the user token consumed by the - connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: AzureDevOpsOrgListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrgListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> Iterable["_models.AzureDevOpsOrg"]: - """Returns a list of Azure DevOps organizations onboarded to the connector. - - Returns a list of Azure DevOps organizations onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either AzureDevOpsOrg or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrgListResponse", 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, security_connector_name: str, org_name: str, **kwargs: Any - ) -> _models.AzureDevOpsOrg: - """Returns a monitored Azure DevOps organization resource. - - Returns a monitored Azure DevOps organization resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :return: AzureDevOpsOrg or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsOrg: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_org, (IOBase, bytes)): - _content = azure_dev_ops_org - else: - _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: _models.AzureDevOpsOrg, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg - :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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a - AzureDevOpsOrg type or a IO[bytes] type. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg or - IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - azure_dev_ops_org=azure_dev_ops_org, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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.AzureDevOpsOrg].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsOrg]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsOrg: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_org, (IOBase, bytes)): - _content = azure_dev_ops_org - else: - _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: _models.AzureDevOpsOrg, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg - :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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a - AzureDevOpsOrg type or a IO[bytes] type. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg or - IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - azure_dev_ops_org=azure_dev_ops_org, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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.AzureDevOpsOrg].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsOrg]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_projects_operations.py deleted file mode 100644 index 65eeb835c793..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_projects_operations.py +++ /dev/null @@ -1,852 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_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_get_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_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) - - -class AzureDevOpsProjectsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`azure_dev_ops_projects` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, org_name: str, **kwargs: Any - ) -> Iterable["_models.AzureDevOpsProject"]: - """Returns a list of Azure DevOps projects onboarded to the connector. - - Returns a list of Azure DevOps projects onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :return: An iterator like instance of either AzureDevOpsProject or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsProjectListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProjectListResponse", 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, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any - ) -> _models.AzureDevOpsProject: - """Returns a monitored Azure DevOps project resource. - - Returns a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: AzureDevOpsProject or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsProject: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_project, (IOBase, bytes)): - _content = azure_dev_ops_project - else: - _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: _models.AzureDevOpsProject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - :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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a - AzureDevOpsProject type or a IO[bytes] type. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - or IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - azure_dev_ops_project=azure_dev_ops_project, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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.AzureDevOpsProject].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsProject]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsProject: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_project, (IOBase, bytes)): - _content = azure_dev_ops_project - else: - _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: _models.AzureDevOpsProject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - :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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a - AzureDevOpsProject type or a IO[bytes] type. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject - or IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - azure_dev_ops_project=azure_dev_ops_project, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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.AzureDevOpsProject].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsProject]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_repos_operations.py deleted file mode 100644 index bbdbdddefe23..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_repos_operations.py +++ /dev/null @@ -1,903 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_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_get_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "repoName": _SERIALIZER.url("repo_name", repo_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) - - -class AzureDevOpsReposOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`azure_dev_ops_repos` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any - ) -> Iterable["_models.AzureDevOpsRepository"]: - """Returns a list of Azure DevOps repositories onboarded to the connector. - - Returns a list of Azure DevOps repositories onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: An iterator like instance of either AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsRepositoryListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepositoryListResponse", 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, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - """Returns a monitored Azure DevOps repository resource. - - Returns a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :return: AzureDevOpsRepository or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_repository, (IOBase, bytes)): - _content = azure_dev_ops_repository - else: - _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: _models.AzureDevOpsRepository, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository - :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 AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a - AzureDevOpsRepository type or a IO[bytes] type. Required. - :type azure_dev_ops_repository: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository or IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - azure_dev_ops_repository=azure_dev_ops_repository, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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.AzureDevOpsRepository].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsRepository]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_repository, (IOBase, bytes)): - _content = azure_dev_ops_repository - else: - _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: _models.AzureDevOpsRepository, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository - :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 AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a - AzureDevOpsRepository type or a IO[bytes] type. Required. - :type azure_dev_ops_repository: - ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository or IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - azure_dev_ops_repository=azure_dev_ops_repository, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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.AzureDevOpsRepository].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsRepository]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_configurations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_configurations_operations.py deleted file mode 100644 index f3f882e897ec..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_configurations_operations.py +++ /dev/null @@ -1,910 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DevOpsConfigurationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`dev_ops_configurations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> Iterable["_models.DevOpsConfiguration"]: - """List DevOps Configurations. - - List DevOps Configurations. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either DevOpsConfiguration or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.DevOpsConfigurationListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DevOpsConfigurationListResponse", 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, security_connector_name: str, **kwargs: Any) -> _models.DevOpsConfiguration: - """Gets a DevOps Configuration. - - Gets a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: DevOpsConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.DevOpsConfiguration: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(dev_ops_configuration, (IOBase, bytes)): - _content = dev_ops_configuration - else: - _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: _models.DevOpsConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration - :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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: 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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Is either a - DevOpsConfiguration type or a IO[bytes] type. Required. - :type dev_ops_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration or IO[bytes] - :return: An instance of LROPoller that returns either DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = 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, - security_connector_name=security_connector_name, - dev_ops_configuration=dev_ops_configuration, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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.DevOpsConfiguration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DevOpsConfiguration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.DevOpsConfiguration: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(dev_ops_configuration, (IOBase, bytes)): - _content = dev_ops_configuration - else: - _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: _models.DevOpsConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration - :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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: 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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Is either a - DevOpsConfiguration type or a IO[bytes] type. Required. - :type dev_ops_configuration: - ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration or IO[bytes] - :return: An instance of LROPoller that returns either DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] - :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._api_version or "2023-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = 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, - security_connector_name=security_connector_name, - dev_ops_configuration=dev_ops_configuration, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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.DevOpsConfiguration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DevOpsConfiguration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a DevOps Connector. - - Deletes a DevOps Connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_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._api_version or "2023-09-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_operation_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_operation_results_operations.py deleted file mode 100644 index dc42f077fb6d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_operation_results_operations.py +++ /dev/null @@ -1,164 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - security_connector_name: str, - operation_result_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", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/operationResults/{operationResultId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "operationResultId": _SERIALIZER.url("operation_result_id", operation_result_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) - - -class DevOpsOperationResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`dev_ops_operation_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, resource_group_name: str, security_connector_name: str, operation_result_id: str, **kwargs: Any - ) -> _models.OperationStatusResult: - """Get devops long running operation result. - - Get devops long running operation result. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param operation_result_id: The operation result Id. Required. - :type operation_result_id: str - :return: OperationStatusResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.OperationStatusResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - operation_result_id=operation_result_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatusResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_owners_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_owners_operations.py deleted file mode 100644 index 97ec703acf52..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_owners_operations.py +++ /dev/null @@ -1,382 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_available_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitHubOwners", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( - resource_group_name: str, security_connector_name: str, owner_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "ownerName": _SERIALIZER.url("owner_name", owner_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) - - -class GitHubOwnersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`git_hub_owners` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.GitHubOwnerListResponse: - """Returns a list of all GitHub owners accessible by the user token consumed by the connector. - - Returns a list of all GitHub owners accessible by the user token consumed by the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: GitHubOwnerListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwnerListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> Iterable["_models.GitHubOwner"]: - """Returns a list of GitHub owners onboarded to the connector. - - Returns a list of GitHub owners onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either GitHubOwner or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GitHubOwnerListResponse", 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, security_connector_name: str, owner_name: str, **kwargs: Any - ) -> _models.GitHubOwner: - """Returns a monitored GitHub owner. - - Returns a monitored GitHub owner. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :return: GitHubOwner or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubOwner] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubOwner", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_repos_operations.py deleted file mode 100644 index 5702ad2614e7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_repos_operations.py +++ /dev/null @@ -1,299 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, owner_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "ownerName": _SERIALIZER.url("owner_name", owner_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_get_request( - resource_group_name: str, - security_connector_name: str, - owner_name: str, - repo_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos/{repoName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "ownerName": _SERIALIZER.url("owner_name", owner_name, "str"), - "repoName": _SERIALIZER.url("repo_name", repo_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) - - -class GitHubReposOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`git_hub_repos` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, owner_name: str, **kwargs: Any - ) -> Iterable["_models.GitHubRepository"]: - """Returns a list of GitHub repositories onboarded to the connector. - - Returns a list of GitHub repositories onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :return: An iterator like instance of either GitHubRepository or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubRepositoryListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GitHubRepositoryListResponse", 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, security_connector_name: str, owner_name: str, repo_name: str, **kwargs: Any - ) -> _models.GitHubRepository: - """Returns a monitored GitHub repository. - - Returns a monitored GitHub repository. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :return: GitHubRepository or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitHubRepository] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_groups_operations.py deleted file mode 100644 index 4f00007df6db..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_groups_operations.py +++ /dev/null @@ -1,382 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_available_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitLabGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( - resource_group_name: str, security_connector_name: str, group_fq_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_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) - - -class GitLabGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`git_lab_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.GitLabGroupListResponse: - """Returns a list of all GitLab groups accessible by the user token consumed by the connector. - - Returns a list of all GitLab groups accessible by the user token consumed by the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: GitLabGroupListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> Iterable["_models.GitLabGroup"]: - """Returns a list of GitLab groups onboarded to the connector. - - Returns a list of GitLab groups onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either GitLabGroup or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GitLabGroupListResponse", 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, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> _models.GitLabGroup: - """Returns a monitored GitLab Group resource for a given fully-qualified name. - - Returns a monitored GitLab Group resource for a given fully-qualified name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: GitLabGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_projects_operations.py deleted file mode 100644 index e197bf712f03..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_projects_operations.py +++ /dev/null @@ -1,308 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, group_fq_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_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_get_request( - resource_group_name: str, - security_connector_name: str, - group_fq_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects/{projectName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_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) - - -class GitLabProjectsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`git_lab_projects` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> Iterable["_models.GitLabProject"]: - """Gets a list of GitLab projects that are directly owned by given group and onboarded to the - connector. - - Gets a list of GitLab projects that are directly owned by given group and onboarded to the - connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: An iterator like instance of either GitLabProject or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject] - :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._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabProjectListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GitLabProjectListResponse", 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, - security_connector_name: str, - group_fq_name: str, - project_name: str, - **kwargs: Any - ) -> _models.GitLabProject: - """Returns a monitored GitLab Project resource for a given fully-qualified group name and project - name. - - Returns a monitored GitLab Project resource for a given fully-qualified group name and project - name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: GitLabProject or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabProject] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_subgroups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_subgroups_operations.py deleted file mode 100644 index 93f3a7a5f0c9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_subgroups_operations.py +++ /dev/null @@ -1,160 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, group_fq_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/listSubgroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class GitLabSubgroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s - :attr:`git_lab_subgroups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> _models.GitLabGroupListResponse: - """Gets nested subgroups of given GitLab Group which are onboarded to the connector. - - Gets nested subgroups of given GitLab Group which are onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: GitLabGroupListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") - ) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_configuration.py deleted file mode 100644 index 2558bb091ec2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-10-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", "2023-10-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_metadata.json deleted file mode 100644 index a63d3fe1f82d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2023-10-01-preview", - "total_api_version_list": ["2023-10-01-preview"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "security_connectors": "SecurityConnectorsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_security_center.py deleted file mode 100644 index 4a1d5925027d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_security_center.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityConnectorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2023_10_01_preview.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-10-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_configuration.py deleted file mode 100644 index fb1b48c2bb78..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-10-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", "2023-10-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_security_center.py deleted file mode 100644 index 95eef1761d60..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_security_center.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import SecurityConnectorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar security_connectors: SecurityConnectorsOperations operations - :vartype security_connectors: - azure.mgmt.security.v2023_10_01_preview.aio.operations.SecurityConnectorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure subscription ID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-10-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, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/__init__.py deleted file mode 100644 index 8e4ac6c4f04e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_security_connectors_operations.py deleted file mode 100644 index 1bebc9ecdf7a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_security_connectors_operations.py +++ /dev/null @@ -1,625 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_connectors_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_10_01_preview.aio.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] - :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._api_version or "2023-10-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] - :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._api_version or "2023-10-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/__init__.py deleted file mode 100644 index edf6edd347c5..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/__init__.py +++ /dev/null @@ -1,227 +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 ._models_py3 import AwsEnvironmentData -from ._models_py3 import AwsOrganizationalData -from ._models_py3 import AwsOrganizationalDataMaster -from ._models_py3 import AwsOrganizationalDataMember -from ._models_py3 import AzureDevOpsScopeEnvironmentData -from ._models_py3 import AzureTrackedResourceLocation -from ._models_py3 import CloudErrorBody -from ._models_py3 import CloudOffering -from ._models_py3 import CspmMonitorAwsOffering -from ._models_py3 import CspmMonitorAwsOfferingNativeCloudConnection -from ._models_py3 import CspmMonitorAzureDevOpsOffering -from ._models_py3 import CspmMonitorGcpOffering -from ._models_py3 import CspmMonitorGcpOfferingNativeCloudConnection -from ._models_py3 import CspmMonitorGitLabOffering -from ._models_py3 import CspmMonitorGithubOffering -from ._models_py3 import DefenderCspmAwsOffering -from ._models_py3 import DefenderCspmAwsOfferingCiem -from ._models_py3 import DefenderCspmAwsOfferingCiemDiscovery -from ._models_py3 import DefenderCspmAwsOfferingCiemOidc -from ._models_py3 import DefenderCspmAwsOfferingDataSensitivityDiscovery -from ._models_py3 import DefenderCspmAwsOfferingDatabasesDspm -from ._models_py3 import DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S -from ._models_py3 import DefenderCspmAwsOfferingMdcContainersImageAssessment -from ._models_py3 import DefenderCspmAwsOfferingVmScanners -from ._models_py3 import DefenderCspmAwsOfferingVmScannersConfiguration -from ._models_py3 import DefenderCspmGcpOffering -from ._models_py3 import DefenderCspmGcpOfferingCiemDiscovery -from ._models_py3 import DefenderCspmGcpOfferingDataSensitivityDiscovery -from ._models_py3 import DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S -from ._models_py3 import DefenderCspmGcpOfferingMdcContainersImageAssessment -from ._models_py3 import DefenderCspmGcpOfferingVmScanners -from ._models_py3 import DefenderCspmGcpOfferingVmScannersConfiguration -from ._models_py3 import DefenderFoDatabasesAwsOffering -from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioning -from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderFoDatabasesAwsOfferingDatabasesDspm -from ._models_py3 import DefenderFoDatabasesAwsOfferingRds -from ._models_py3 import DefenderForContainersAwsOffering -from ._models_py3 import DefenderForContainersAwsOfferingCloudWatchToKinesis -from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessment -from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask -from ._models_py3 import DefenderForContainersAwsOfferingKinesisToS3 -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesScubaReader -from ._models_py3 import DefenderForContainersAwsOfferingKubernetesService -from ._models_py3 import DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S -from ._models_py3 import DefenderForContainersAwsOfferingMdcContainersImageAssessment -from ._models_py3 import DefenderForContainersGcpOffering -from ._models_py3 import DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection -from ._models_py3 import DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S -from ._models_py3 import DefenderForContainersGcpOfferingMdcContainersImageAssessment -from ._models_py3 import DefenderForContainersGcpOfferingNativeCloudConnection -from ._models_py3 import DefenderForDatabasesGcpOffering -from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioning -from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning -from ._models_py3 import DefenderForDevOpsAzureDevOpsOffering -from ._models_py3 import DefenderForDevOpsGitLabOffering -from ._models_py3 import DefenderForDevOpsGithubOffering -from ._models_py3 import DefenderForServersAwsOffering -from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersAwsOfferingDefenderForServers -from ._models_py3 import DefenderForServersAwsOfferingMdeAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingSubPlan -from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioning -from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersAwsOfferingVmScanners -from ._models_py3 import DefenderForServersAwsOfferingVmScannersConfiguration -from ._models_py3 import DefenderForServersGcpOffering -from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersGcpOfferingDefenderForServers -from ._models_py3 import DefenderForServersGcpOfferingMdeAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingSubPlan -from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioning -from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioningConfiguration -from ._models_py3 import DefenderForServersGcpOfferingVmScanners -from ._models_py3 import DefenderForServersGcpOfferingVmScannersConfiguration -from ._models_py3 import ETag -from ._models_py3 import EnvironmentData -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import GcpOrganizationalData -from ._models_py3 import GcpOrganizationalDataMember -from ._models_py3 import GcpOrganizationalDataOrganization -from ._models_py3 import GcpProjectDetails -from ._models_py3 import GcpProjectEnvironmentData -from ._models_py3 import GithubScopeEnvironmentData -from ._models_py3 import GitlabScopeEnvironmentData -from ._models_py3 import InformationProtectionAwsOffering -from ._models_py3 import InformationProtectionAwsOfferingInformationProtection -from ._models_py3 import Kind -from ._models_py3 import Resource -from ._models_py3 import SecurityConnector -from ._models_py3 import SecurityConnectorsList -from ._models_py3 import SystemData -from ._models_py3 import Tags -from ._models_py3 import TrackedResource - -from ._security_center_enums import CloudName -from ._security_center_enums import CreatedByType -from ._security_center_enums import EnvironmentType -from ._security_center_enums import OfferingType -from ._security_center_enums import OrganizationMembershipType -from ._security_center_enums import ScanningMode -from ._security_center_enums import SubPlan -from ._security_center_enums import Type -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AwsEnvironmentData", - "AwsOrganizationalData", - "AwsOrganizationalDataMaster", - "AwsOrganizationalDataMember", - "AzureDevOpsScopeEnvironmentData", - "AzureTrackedResourceLocation", - "CloudErrorBody", - "CloudOffering", - "CspmMonitorAwsOffering", - "CspmMonitorAwsOfferingNativeCloudConnection", - "CspmMonitorAzureDevOpsOffering", - "CspmMonitorGcpOffering", - "CspmMonitorGcpOfferingNativeCloudConnection", - "CspmMonitorGitLabOffering", - "CspmMonitorGithubOffering", - "DefenderCspmAwsOffering", - "DefenderCspmAwsOfferingCiem", - "DefenderCspmAwsOfferingCiemDiscovery", - "DefenderCspmAwsOfferingCiemOidc", - "DefenderCspmAwsOfferingDataSensitivityDiscovery", - "DefenderCspmAwsOfferingDatabasesDspm", - "DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S", - "DefenderCspmAwsOfferingMdcContainersImageAssessment", - "DefenderCspmAwsOfferingVmScanners", - "DefenderCspmAwsOfferingVmScannersConfiguration", - "DefenderCspmGcpOffering", - "DefenderCspmGcpOfferingCiemDiscovery", - "DefenderCspmGcpOfferingDataSensitivityDiscovery", - "DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S", - "DefenderCspmGcpOfferingMdcContainersImageAssessment", - "DefenderCspmGcpOfferingVmScanners", - "DefenderCspmGcpOfferingVmScannersConfiguration", - "DefenderFoDatabasesAwsOffering", - "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", - "DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration", - "DefenderFoDatabasesAwsOfferingDatabasesDspm", - "DefenderFoDatabasesAwsOfferingRds", - "DefenderForContainersAwsOffering", - "DefenderForContainersAwsOfferingCloudWatchToKinesis", - "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", - "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", - "DefenderForContainersAwsOfferingKinesisToS3", - "DefenderForContainersAwsOfferingKubernetesScubaReader", - "DefenderForContainersAwsOfferingKubernetesService", - "DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S", - "DefenderForContainersAwsOfferingMdcContainersImageAssessment", - "DefenderForContainersGcpOffering", - "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", - "DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S", - "DefenderForContainersGcpOfferingMdcContainersImageAssessment", - "DefenderForContainersGcpOfferingNativeCloudConnection", - "DefenderForDatabasesGcpOffering", - "DefenderForDatabasesGcpOfferingArcAutoProvisioning", - "DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration", - "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", - "DefenderForDevOpsAzureDevOpsOffering", - "DefenderForDevOpsGitLabOffering", - "DefenderForDevOpsGithubOffering", - "DefenderForServersAwsOffering", - "DefenderForServersAwsOfferingArcAutoProvisioning", - "DefenderForServersAwsOfferingArcAutoProvisioningConfiguration", - "DefenderForServersAwsOfferingDefenderForServers", - "DefenderForServersAwsOfferingMdeAutoProvisioning", - "DefenderForServersAwsOfferingSubPlan", - "DefenderForServersAwsOfferingVaAutoProvisioning", - "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", - "DefenderForServersAwsOfferingVmScanners", - "DefenderForServersAwsOfferingVmScannersConfiguration", - "DefenderForServersGcpOffering", - "DefenderForServersGcpOfferingArcAutoProvisioning", - "DefenderForServersGcpOfferingArcAutoProvisioningConfiguration", - "DefenderForServersGcpOfferingDefenderForServers", - "DefenderForServersGcpOfferingMdeAutoProvisioning", - "DefenderForServersGcpOfferingSubPlan", - "DefenderForServersGcpOfferingVaAutoProvisioning", - "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", - "DefenderForServersGcpOfferingVmScanners", - "DefenderForServersGcpOfferingVmScannersConfiguration", - "ETag", - "EnvironmentData", - "ErrorAdditionalInfo", - "GcpOrganizationalData", - "GcpOrganizationalDataMember", - "GcpOrganizationalDataOrganization", - "GcpProjectDetails", - "GcpProjectEnvironmentData", - "GithubScopeEnvironmentData", - "GitlabScopeEnvironmentData", - "InformationProtectionAwsOffering", - "InformationProtectionAwsOfferingInformationProtection", - "Kind", - "Resource", - "SecurityConnector", - "SecurityConnectorsList", - "SystemData", - "Tags", - "TrackedResource", - "CloudName", - "CreatedByType", - "EnvironmentType", - "OfferingType", - "OrganizationMembershipType", - "ScanningMode", - "SubPlan", - "Type", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_models_py3.py deleted file mode 100644 index f83800cc7523..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_models_py3.py +++ /dev/null @@ -1,3990 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class EnvironmentData(_serialization.Model): - """The security connector environment data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AwsEnvironmentData, AzureDevOpsScopeEnvironmentData, GcpProjectEnvironmentData, - GithubScopeEnvironmentData, GitlabScopeEnvironmentData - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - _subtype_map = { - "environment_type": { - "AwsAccount": "AwsEnvironmentData", - "AzureDevOpsScope": "AzureDevOpsScopeEnvironmentData", - "GcpProject": "GcpProjectEnvironmentData", - "GithubScope": "GithubScopeEnvironmentData", - "GitlabScope": "GitlabScopeEnvironmentData", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: Optional[str] = None - - -class AwsEnvironmentData(EnvironmentData): - """The AWS connector environment data. - - 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 environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType - :ivar organizational_data: The AWS account's organizational data. - :vartype organizational_data: - ~azure.mgmt.security.v2023_10_01_preview.models.AwsOrganizationalData - :ivar regions: list of regions to scan. - :vartype regions: list[str] - :ivar account_name: The AWS account name. - :vartype account_name: str - :ivar scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). - :vartype scan_interval: int - """ - - _validation = { - "environment_type": {"required": True}, - "account_name": {"readonly": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - "organizational_data": {"key": "organizationalData", "type": "AwsOrganizationalData"}, - "regions": {"key": "regions", "type": "[str]"}, - "account_name": {"key": "accountName", "type": "str"}, - "scan_interval": {"key": "scanInterval", "type": "int"}, - } - - def __init__( - self, - *, - organizational_data: Optional["_models.AwsOrganizationalData"] = None, - regions: Optional[List[str]] = None, - scan_interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword organizational_data: The AWS account's organizational data. - :paramtype organizational_data: - ~azure.mgmt.security.v2023_10_01_preview.models.AwsOrganizationalData - :keyword regions: list of regions to scan. - :paramtype regions: list[str] - :keyword scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). - :paramtype scan_interval: int - """ - super().__init__(**kwargs) - self.environment_type: str = "AwsAccount" - self.organizational_data = organizational_data - self.regions = regions - self.account_name = None - self.scan_interval = scan_interval - - -class AwsOrganizationalData(_serialization.Model): - """The AWS organization data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AwsOrganizationalDataMember, AwsOrganizationalDataMaster - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - } - - _subtype_map = { - "organization_membership_type": { - "Member": "AwsOrganizationalDataMember", - "Organization": "AwsOrganizationalDataMaster", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.organization_membership_type: Optional[str] = None - - -class AwsOrganizationalDataMaster(AwsOrganizationalData): - """The AWS organization data for the master account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType - :ivar stackset_name: If the multi cloud account is of membership type organization, this will - be the name of the onboarding stackset. - :vartype stackset_name: str - :ivar excluded_account_ids: If the multi cloud account is of membership type organization, list - of accounts excluded from offering. - :vartype excluded_account_ids: list[str] - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "stackset_name": {"key": "stacksetName", "type": "str"}, - "excluded_account_ids": {"key": "excludedAccountIds", "type": "[str]"}, - } - - def __init__( - self, *, stackset_name: Optional[str] = None, excluded_account_ids: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword stackset_name: If the multi cloud account is of membership type organization, this - will be the name of the onboarding stackset. - :paramtype stackset_name: str - :keyword excluded_account_ids: If the multi cloud account is of membership type organization, - list of accounts excluded from offering. - :paramtype excluded_account_ids: list[str] - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Organization" - self.stackset_name = stackset_name - self.excluded_account_ids = excluded_account_ids - - -class AwsOrganizationalDataMember(AwsOrganizationalData): - """The AWS organization data for the member account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType - :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, - this will be the ID of the account's parent. - :vartype parent_hierarchy_id: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, - } - - def __init__(self, *, parent_hierarchy_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword parent_hierarchy_id: If the multi cloud account is not of membership type - organization, this will be the ID of the account's parent. - :paramtype parent_hierarchy_id: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Member" - self.parent_hierarchy_id = parent_hierarchy_id - - -class AzureDevOpsScopeEnvironmentData(EnvironmentData): - """The AzureDevOps scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "AzureDevOpsScope" - - -class AzureTrackedResourceLocation(_serialization.Model): - """Describes an Azure resource with location. - - :ivar location: Location where the resource is stored. - :vartype location: str - """ - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - - -class CloudErrorBody(_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.security.v2023_10_01_preview.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.security.v2023_10_01_preview.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class CloudOffering(_serialization.Model): - """The security offering details. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - CspmMonitorAwsOffering, CspmMonitorAzureDevOpsOffering, CspmMonitorGcpOffering, - CspmMonitorGitLabOffering, CspmMonitorGithubOffering, DefenderCspmAwsOffering, - DefenderCspmGcpOffering, DefenderForContainersAwsOffering, DefenderForContainersGcpOffering, - DefenderFoDatabasesAwsOffering, DefenderForDatabasesGcpOffering, - DefenderForDevOpsAzureDevOpsOffering, DefenderForDevOpsGitLabOffering, - DefenderForDevOpsGithubOffering, DefenderForServersAwsOffering, DefenderForServersGcpOffering, - InformationProtectionAwsOffering - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - _subtype_map = { - "offering_type": { - "CspmMonitorAws": "CspmMonitorAwsOffering", - "CspmMonitorAzureDevOps": "CspmMonitorAzureDevOpsOffering", - "CspmMonitorGcp": "CspmMonitorGcpOffering", - "CspmMonitorGitLab": "CspmMonitorGitLabOffering", - "CspmMonitorGithub": "CspmMonitorGithubOffering", - "DefenderCspmAws": "DefenderCspmAwsOffering", - "DefenderCspmGcp": "DefenderCspmGcpOffering", - "DefenderForContainersAws": "DefenderForContainersAwsOffering", - "DefenderForContainersGcp": "DefenderForContainersGcpOffering", - "DefenderForDatabasesAws": "DefenderFoDatabasesAwsOffering", - "DefenderForDatabasesGcp": "DefenderForDatabasesGcpOffering", - "DefenderForDevOpsAzureDevOps": "DefenderForDevOpsAzureDevOpsOffering", - "DefenderForDevOpsGitLab": "DefenderForDevOpsGitLabOffering", - "DefenderForDevOpsGithub": "DefenderForDevOpsGithubOffering", - "DefenderForServersAws": "DefenderForServersAwsOffering", - "DefenderForServersGcp": "DefenderForServersGcpOffering", - "InformationProtectionAws": "InformationProtectionAwsOffering", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: Optional[str] = None - self.description = None - - -class CspmMonitorAwsOffering(CloudOffering): - """The CSPM monitoring for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2023_10_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "CspmMonitorAwsOfferingNativeCloudConnection", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.CspmMonitorAwsOfferingNativeCloudConnection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2023_10_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection - """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorAws" - self.native_cloud_connection = native_cloud_connection - - -class CspmMonitorAwsOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class CspmMonitorAzureDevOpsOffering(CloudOffering): - """The CSPM monitoring for AzureDevOps offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorAzureDevOps" - - -class CspmMonitorGcpOffering(CloudOffering): - """The CSPM monitoring for GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2023_10_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "CspmMonitorGcpOfferingNativeCloudConnection", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.CspmMonitorGcpOfferingNativeCloudConnection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2023_10_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection - """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGcp" - self.native_cloud_connection = native_cloud_connection - - -class CspmMonitorGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar workload_identity_provider_id: The GCP workload identity provider id for the offering. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword workload_identity_provider_id: The GCP workload identity provider id for the offering. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class CspmMonitorGithubOffering(CloudOffering): - """The CSPM monitoring for github offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGithub" - - -class CspmMonitorGitLabOffering(CloudOffering): - """The CSPM (Cloud security posture management) monitoring for gitlab offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "CspmMonitorGitLab" - - -class DefenderCspmAwsOffering(CloudOffering): - """The CSPM P1 for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingVmScanners - :ivar data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery - configuration. - :vartype data_sensitivity_discovery: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingDataSensitivityDiscovery - :ivar databases_dspm: The databases DSPM configuration. - :vartype databases_dspm: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingDatabasesDspm - :ivar ciem: Defenders CSPM Cloud infrastructure entitlement management (CIEM) offering - configurations. - :vartype ciem: ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiem - :ivar mdc_containers_image_assessment: The Microsoft Defender container image assessment - configuration. - :vartype mdc_containers_image_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingMdcContainersImageAssessment - :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless - discovery K8s configuration. - :vartype mdc_containers_agentless_discovery_k8_s: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderCspmAwsOfferingVmScanners"}, - "data_sensitivity_discovery": { - "key": "dataSensitivityDiscovery", - "type": "DefenderCspmAwsOfferingDataSensitivityDiscovery", - }, - "databases_dspm": {"key": "databasesDspm", "type": "DefenderCspmAwsOfferingDatabasesDspm"}, - "ciem": {"key": "ciem", "type": "DefenderCspmAwsOfferingCiem"}, - "mdc_containers_image_assessment": { - "key": "mdcContainersImageAssessment", - "type": "DefenderCspmAwsOfferingMdcContainersImageAssessment", - }, - "mdc_containers_agentless_discovery_k8_s": { - "key": "mdcContainersAgentlessDiscoveryK8s", - "type": "DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S", - }, - } - - def __init__( - self, - *, - vm_scanners: Optional["_models.DefenderCspmAwsOfferingVmScanners"] = None, - data_sensitivity_discovery: Optional["_models.DefenderCspmAwsOfferingDataSensitivityDiscovery"] = None, - databases_dspm: Optional["_models.DefenderCspmAwsOfferingDatabasesDspm"] = None, - ciem: Optional["_models.DefenderCspmAwsOfferingCiem"] = None, - mdc_containers_image_assessment: Optional["_models.DefenderCspmAwsOfferingMdcContainersImageAssessment"] = None, - mdc_containers_agentless_discovery_k8_s: Optional[ - "_models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingVmScanners - :keyword data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery - configuration. - :paramtype data_sensitivity_discovery: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingDataSensitivityDiscovery - :keyword databases_dspm: The databases DSPM configuration. - :paramtype databases_dspm: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingDatabasesDspm - :keyword ciem: Defenders CSPM Cloud infrastructure entitlement management (CIEM) offering - configurations. - :paramtype ciem: ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiem - :keyword mdc_containers_image_assessment: The Microsoft Defender container image assessment - configuration. - :paramtype mdc_containers_image_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingMdcContainersImageAssessment - :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless - discovery K8s configuration. - :paramtype mdc_containers_agentless_discovery_k8_s: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderCspmAws" - self.vm_scanners = vm_scanners - self.data_sensitivity_discovery = data_sensitivity_discovery - self.databases_dspm = databases_dspm - self.ciem = ciem - self.mdc_containers_image_assessment = mdc_containers_image_assessment - self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s - - -class DefenderCspmAwsOfferingCiem(_serialization.Model): - """Defenders CSPM Cloud infrastructure entitlement management (CIEM) offering configurations. - - :ivar ciem_discovery: Defender CSPM CIEM discovery configuration. - :vartype ciem_discovery: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiemDiscovery - :ivar ciem_oidc: Defender CSPM CIEM AWS OIDC (open id connect) configuration. - :vartype ciem_oidc: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiemOidc - """ - - _attribute_map = { - "ciem_discovery": {"key": "ciemDiscovery", "type": "DefenderCspmAwsOfferingCiemDiscovery"}, - "ciem_oidc": {"key": "ciemOidc", "type": "DefenderCspmAwsOfferingCiemOidc"}, - } - - def __init__( - self, - *, - ciem_discovery: Optional["_models.DefenderCspmAwsOfferingCiemDiscovery"] = None, - ciem_oidc: Optional["_models.DefenderCspmAwsOfferingCiemOidc"] = None, - **kwargs: Any - ) -> None: - """ - :keyword ciem_discovery: Defender CSPM CIEM discovery configuration. - :paramtype ciem_discovery: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiemDiscovery - :keyword ciem_oidc: Defender CSPM CIEM AWS OIDC (open id connect) configuration. - :paramtype ciem_oidc: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiemOidc - """ - super().__init__(**kwargs) - self.ciem_discovery = ciem_discovery - self.ciem_oidc = ciem_oidc - - -class DefenderCspmAwsOfferingCiemDiscovery(_serialization.Model): - """Defender CSPM CIEM discovery configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for CIEM discovery. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for CIEM discovery. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderCspmAwsOfferingCiemOidc(_serialization.Model): - """Defender CSPM CIEM AWS OIDC (open id connect) configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for CIEM oidc connection. - :vartype cloud_role_arn: str - :ivar azure_active_directory_app_name: the azure active directory app name used of - authenticating against AWS. - :vartype azure_active_directory_app_name: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "azure_active_directory_app_name": {"key": "azureActiveDirectoryAppName", "type": "str"}, - } - - def __init__( - self, - *, - cloud_role_arn: Optional[str] = None, - azure_active_directory_app_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for CIEM oidc connection. - :paramtype cloud_role_arn: str - :keyword azure_active_directory_app_name: the azure active directory app name used of - authenticating against AWS. - :paramtype azure_active_directory_app_name: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - self.azure_active_directory_app_name = azure_active_directory_app_name - - -class DefenderCspmAwsOfferingDatabasesDspm(_serialization.Model): - """The databases DSPM configuration. - - :ivar enabled: Is databases DSPM protection enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is databases DSPM protection enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderCspmAwsOfferingDataSensitivityDiscovery(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender Data Sensitivity discovery configuration. - - :ivar enabled: Is Microsoft Defender Data Sensitivity discovery enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender Data Sensitivity discovery enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender container agentless discovery K8s configuration. - - :ivar enabled: Is Microsoft Defender container agentless discovery K8s enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender container agentless discovery K8s enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderCspmAwsOfferingMdcContainersImageAssessment(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender container image assessment configuration. - - :ivar enabled: Is Microsoft Defender container image assessment enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender container image assessment enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderCspmAwsOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderCspmAwsOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderCspmAwsOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderCspmAwsOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar scanning_mode: The scanning mode for the VM scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. - :vartype exclusion_tags: dict[str, str] - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, - } - - def __init__( - self, - *, - cloud_role_arn: Optional[str] = None, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword scanning_mode: The scanning mode for the VM scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. - :paramtype exclusion_tags: dict[str, str] - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class DefenderCspmGcpOffering(CloudOffering): - """The CSPM P1 for GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar ciem_discovery: GCP Defenders CSPM Cloud infrastructure entitlement management (CIEM) - discovery offering configurations. - :vartype ciem_discovery: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingCiemDiscovery - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingVmScanners - :ivar data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery - configuration. - :vartype data_sensitivity_discovery: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingDataSensitivityDiscovery - :ivar mdc_containers_image_assessment: The Microsoft Defender Container image assessment - configuration. - :vartype mdc_containers_image_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingMdcContainersImageAssessment - :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless - discovery configuration. - :vartype mdc_containers_agentless_discovery_k8_s: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "ciem_discovery": {"key": "ciemDiscovery", "type": "DefenderCspmGcpOfferingCiemDiscovery"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderCspmGcpOfferingVmScanners"}, - "data_sensitivity_discovery": { - "key": "dataSensitivityDiscovery", - "type": "DefenderCspmGcpOfferingDataSensitivityDiscovery", - }, - "mdc_containers_image_assessment": { - "key": "mdcContainersImageAssessment", - "type": "DefenderCspmGcpOfferingMdcContainersImageAssessment", - }, - "mdc_containers_agentless_discovery_k8_s": { - "key": "mdcContainersAgentlessDiscoveryK8s", - "type": "DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S", - }, - } - - def __init__( - self, - *, - ciem_discovery: Optional["_models.DefenderCspmGcpOfferingCiemDiscovery"] = None, - vm_scanners: Optional["_models.DefenderCspmGcpOfferingVmScanners"] = None, - data_sensitivity_discovery: Optional["_models.DefenderCspmGcpOfferingDataSensitivityDiscovery"] = None, - mdc_containers_image_assessment: Optional["_models.DefenderCspmGcpOfferingMdcContainersImageAssessment"] = None, - mdc_containers_agentless_discovery_k8_s: Optional[ - "_models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword ciem_discovery: GCP Defenders CSPM Cloud infrastructure entitlement management (CIEM) - discovery offering configurations. - :paramtype ciem_discovery: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingCiemDiscovery - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingVmScanners - :keyword data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery - configuration. - :paramtype data_sensitivity_discovery: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingDataSensitivityDiscovery - :keyword mdc_containers_image_assessment: The Microsoft Defender Container image assessment - configuration. - :paramtype mdc_containers_image_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingMdcContainersImageAssessment - :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless - discovery configuration. - :paramtype mdc_containers_agentless_discovery_k8_s: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderCspmGcp" - self.ciem_discovery = ciem_discovery - self.vm_scanners = vm_scanners - self.data_sensitivity_discovery = data_sensitivity_discovery - self.mdc_containers_image_assessment = mdc_containers_image_assessment - self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s - - -class DefenderCspmGcpOfferingCiemDiscovery(_serialization.Model): - """GCP Defenders CSPM Cloud infrastructure entitlement management (CIEM) discovery offering - configurations. - - :ivar workload_identity_provider_id: The GCP workload identity provider id for CIEM discovery - offering. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for CIEM - discovery offering. - :vartype service_account_email_address: str - :ivar azure_active_directory_app_name: the azure active directory app name used of - authenticating against GCP workload identity federation. - :vartype azure_active_directory_app_name: str - """ - - _attribute_map = { - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "azure_active_directory_app_name": {"key": "azureActiveDirectoryAppName", "type": "str"}, - } - - def __init__( - self, - *, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - azure_active_directory_app_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword workload_identity_provider_id: The GCP workload identity provider id for CIEM - discovery offering. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for CIEM - discovery offering. - :paramtype service_account_email_address: str - :keyword azure_active_directory_app_name: the azure active directory app name used of - authenticating against GCP workload identity federation. - :paramtype azure_active_directory_app_name: str - """ - super().__init__(**kwargs) - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - self.azure_active_directory_app_name = azure_active_directory_app_name - - -class DefenderCspmGcpOfferingDataSensitivityDiscovery(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender Data Sensitivity discovery configuration. - - :ivar enabled: Is Microsoft Defender Data Sensitivity discovery enabled. - :vartype enabled: bool - :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this feature. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender Data Sensitivity discovery enabled. - :paramtype enabled: bool - :keyword workload_identity_provider_id: The workload identity provider id in GCP for this - feature. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - feature. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender Container agentless discovery configuration. - - :ivar enabled: Is Microsoft Defender container agentless discovery enabled. - :vartype enabled: bool - :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this feature. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender container agentless discovery enabled. - :paramtype enabled: bool - :keyword workload_identity_provider_id: The workload identity provider id in GCP for this - feature. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - feature. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class DefenderCspmGcpOfferingMdcContainersImageAssessment(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender Container image assessment configuration. - - :ivar enabled: Is Microsoft Defender container image assessment enabled. - :vartype enabled: bool - :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this feature. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender container image assessment enabled. - :paramtype enabled: bool - :keyword workload_identity_provider_id: The workload identity provider id in GCP for this - feature. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - feature. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class DefenderCspmGcpOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderCspmGcpOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderCspmGcpOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderCspmGcpOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar scanning_mode: The scanning mode for the VM scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. - :vartype exclusion_tags: dict[str, str] - """ - - _attribute_map = { - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, - } - - def __init__( - self, - *, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword scanning_mode: The scanning mode for the VM scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. - :paramtype exclusion_tags: dict[str, str] - """ - super().__init__(**kwargs) - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class DefenderFoDatabasesAwsOffering(CloudOffering): - """The Defender for Databases AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning - :ivar rds: The RDS configuration. - :vartype rds: ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingRds - :ivar databases_dspm: The databases data security posture management (DSPM) configuration. - :vartype databases_dspm: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingDatabasesDspm - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", - }, - "rds": {"key": "rds", "type": "DefenderFoDatabasesAwsOfferingRds"}, - "databases_dspm": {"key": "databasesDspm", "type": "DefenderFoDatabasesAwsOfferingDatabasesDspm"}, - } - - def __init__( - self, - *, - arc_auto_provisioning: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning"] = None, - rds: Optional["_models.DefenderFoDatabasesAwsOfferingRds"] = None, - databases_dspm: Optional["_models.DefenderFoDatabasesAwsOfferingDatabasesDspm"] = None, - **kwargs: Any - ) -> None: - """ - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning - :keyword rds: The RDS configuration. - :paramtype rds: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingRds - :keyword databases_dspm: The databases data security posture management (DSPM) configuration. - :paramtype databases_dspm: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingDatabasesDspm - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDatabasesAws" - self.arc_auto_provisioning = arc_auto_provisioning - self.rds = rds - self.databases_dspm = databases_dspm - - -class DefenderFoDatabasesAwsOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar configuration: Configuration for servers Arc auto provisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "configuration": { - "key": "configuration", - "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - cloud_role_arn: Optional[str] = None, - configuration: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword configuration: Configuration for servers Arc auto provisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - self.configuration = configuration - - -class DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for servers Arc auto provisioning. - - :ivar proxy: Optional http proxy endpoint to use for the Arc agent. - :vartype proxy: str - :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :vartype private_link_scope: str - """ - - _attribute_map = { - "proxy": {"key": "proxy", "type": "str"}, - "private_link_scope": {"key": "privateLinkScope", "type": "str"}, - } - - def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword proxy: Optional http proxy endpoint to use for the Arc agent. - :paramtype proxy: str - :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :paramtype private_link_scope: str - """ - super().__init__(**kwargs) - self.proxy = proxy - self.private_link_scope = private_link_scope - - -class DefenderFoDatabasesAwsOfferingDatabasesDspm(_serialization.Model): # pylint: disable=name-too-long - """The databases data security posture management (DSPM) configuration. - - :ivar enabled: Is databases data security posture management (DSPM) protection enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is databases data security posture management (DSPM) protection enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderFoDatabasesAwsOfferingRds(_serialization.Model): - """The RDS configuration. - - :ivar enabled: Is RDS protection enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is RDS protection enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOffering(CloudOffering): # pylint: disable=too-many-instance-attributes - """The Defender for Containers AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar kubernetes_service: The kubernetes service connection configuration. - :vartype kubernetes_service: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :ivar kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :vartype kubernetes_scuba_reader: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :ivar cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :vartype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :ivar kinesis_to_s3: The kinesis to s3 connection configuration. - :vartype kinesis_to_s3: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - :ivar container_vulnerability_assessment: The container vulnerability assessment configuration. - :vartype container_vulnerability_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment - :ivar container_vulnerability_assessment_task: The container vulnerability assessment task - configuration. - :vartype container_vulnerability_assessment_task: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask # pylint: disable=line-too-long - :ivar enable_container_vulnerability_assessment: Enable container vulnerability assessment - feature. - :vartype enable_container_vulnerability_assessment: bool - :ivar auto_provisioning: Is audit logs pipeline auto provisioning enabled. - :vartype auto_provisioning: bool - :ivar kube_audit_retention_time: The retention time in days of kube audit logs set on the - CloudWatch log group. - :vartype kube_audit_retention_time: int - :ivar scuba_external_id: The externalId used by the data reader to prevent the confused deputy - attack. - :vartype scuba_external_id: str - :ivar mdc_containers_image_assessment: The Microsoft Defender container image assessment - configuration. - :vartype mdc_containers_image_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingMdcContainersImageAssessment - :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless - discovery K8s configuration. - :vartype mdc_containers_agentless_discovery_k8_s: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "kubernetes_service": {"key": "kubernetesService", "type": "DefenderForContainersAwsOfferingKubernetesService"}, - "kubernetes_scuba_reader": { - "key": "kubernetesScubaReader", - "type": "DefenderForContainersAwsOfferingKubernetesScubaReader", - }, - "cloud_watch_to_kinesis": { - "key": "cloudWatchToKinesis", - "type": "DefenderForContainersAwsOfferingCloudWatchToKinesis", - }, - "kinesis_to_s3": {"key": "kinesisToS3", "type": "DefenderForContainersAwsOfferingKinesisToS3"}, - "container_vulnerability_assessment": { - "key": "containerVulnerabilityAssessment", - "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", - }, - "container_vulnerability_assessment_task": { - "key": "containerVulnerabilityAssessmentTask", - "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", - }, - "enable_container_vulnerability_assessment": {"key": "enableContainerVulnerabilityAssessment", "type": "bool"}, - "auto_provisioning": {"key": "autoProvisioning", "type": "bool"}, - "kube_audit_retention_time": {"key": "kubeAuditRetentionTime", "type": "int"}, - "scuba_external_id": {"key": "scubaExternalId", "type": "str"}, - "mdc_containers_image_assessment": { - "key": "mdcContainersImageAssessment", - "type": "DefenderForContainersAwsOfferingMdcContainersImageAssessment", - }, - "mdc_containers_agentless_discovery_k8_s": { - "key": "mdcContainersAgentlessDiscoveryK8s", - "type": "DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S", - }, - } - - def __init__( - self, - *, - kubernetes_service: Optional["_models.DefenderForContainersAwsOfferingKubernetesService"] = None, - kubernetes_scuba_reader: Optional["_models.DefenderForContainersAwsOfferingKubernetesScubaReader"] = None, - cloud_watch_to_kinesis: Optional["_models.DefenderForContainersAwsOfferingCloudWatchToKinesis"] = None, - kinesis_to_s3: Optional["_models.DefenderForContainersAwsOfferingKinesisToS3"] = None, - container_vulnerability_assessment: Optional[ - "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment" - ] = None, - container_vulnerability_assessment_task: Optional[ - "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask" - ] = None, - enable_container_vulnerability_assessment: Optional[bool] = None, - auto_provisioning: Optional[bool] = None, - kube_audit_retention_time: Optional[int] = None, - scuba_external_id: Optional[str] = None, - mdc_containers_image_assessment: Optional[ - "_models.DefenderForContainersAwsOfferingMdcContainersImageAssessment" - ] = None, - mdc_containers_agentless_discovery_k8_s: Optional[ - "_models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword kubernetes_service: The kubernetes service connection configuration. - :paramtype kubernetes_service: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKubernetesService - :keyword kubernetes_scuba_reader: The kubernetes to scuba connection configuration. - :paramtype kubernetes_scuba_reader: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader - :keyword cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. - :paramtype cloud_watch_to_kinesis: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis - :keyword kinesis_to_s3: The kinesis to s3 connection configuration. - :paramtype kinesis_to_s3: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 - :keyword container_vulnerability_assessment: The container vulnerability assessment - configuration. - :paramtype container_vulnerability_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment # pylint: disable=line-too-long - :keyword container_vulnerability_assessment_task: The container vulnerability assessment task - configuration. - :paramtype container_vulnerability_assessment_task: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask # pylint: disable=line-too-long - :keyword enable_container_vulnerability_assessment: Enable container vulnerability assessment - feature. - :paramtype enable_container_vulnerability_assessment: bool - :keyword auto_provisioning: Is audit logs pipeline auto provisioning enabled. - :paramtype auto_provisioning: bool - :keyword kube_audit_retention_time: The retention time in days of kube audit logs set on the - CloudWatch log group. - :paramtype kube_audit_retention_time: int - :keyword scuba_external_id: The externalId used by the data reader to prevent the confused - deputy attack. - :paramtype scuba_external_id: str - :keyword mdc_containers_image_assessment: The Microsoft Defender container image assessment - configuration. - :paramtype mdc_containers_image_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingMdcContainersImageAssessment - :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless - discovery K8s configuration. - :paramtype mdc_containers_agentless_discovery_k8_s: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForContainersAws" - self.kubernetes_service = kubernetes_service - self.kubernetes_scuba_reader = kubernetes_scuba_reader - self.cloud_watch_to_kinesis = cloud_watch_to_kinesis - self.kinesis_to_s3 = kinesis_to_s3 - self.container_vulnerability_assessment = container_vulnerability_assessment - self.container_vulnerability_assessment_task = container_vulnerability_assessment_task - self.enable_container_vulnerability_assessment = enable_container_vulnerability_assessment - self.auto_provisioning = auto_provisioning - self.kube_audit_retention_time = kube_audit_retention_time - self.scuba_external_id = scuba_external_id - self.mdc_containers_image_assessment = mdc_containers_image_assessment - self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s - - -class DefenderForContainersAwsOfferingCloudWatchToKinesis(_serialization.Model): # pylint: disable=name-too-long - """The cloudwatch to kinesis connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into - Kinesis. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into - Kinesis. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingContainerVulnerabilityAssessment( - _serialization.Model -): # pylint: disable=name-too-long - """The container vulnerability assessment configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask( - _serialization.Model -): # pylint: disable=name-too-long - """The container vulnerability assessment task configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKinesisToS3(_serialization.Model): # pylint: disable=name-too-long - """The kinesis to s3 connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesScubaReader(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes to scuba connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingKubernetesService(_serialization.Model): # pylint: disable=name-too-long - """The kubernetes service connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning - resources. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning - resources. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S( - _serialization.Model -): # pylint: disable=name-too-long - """The Microsoft Defender container agentless discovery K8s configuration. - - :ivar enabled: Is Microsoft Defender container agentless discovery K8s enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender container agentless discovery K8s enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersAwsOfferingMdcContainersImageAssessment( - _serialization.Model -): # pylint: disable=name-too-long - """The Microsoft Defender container image assessment configuration. - - :ivar enabled: Is Microsoft Defender container image assessment enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender container image assessment enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - - -class DefenderForContainersGcpOffering(CloudOffering): - """The containers GCP offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar native_cloud_connection: The native cloud connection configuration. - :vartype native_cloud_connection: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection - :ivar data_pipeline_native_cloud_connection: The native cloud connection configuration. - :vartype data_pipeline_native_cloud_connection: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection - :ivar audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. - :vartype audit_logs_auto_provisioning_flag: bool - :ivar defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes agent - auto provisioning enabled. - :vartype defender_agent_auto_provisioning_flag: bool - :ivar policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning - enabled. - :vartype policy_agent_auto_provisioning_flag: bool - :ivar mdc_containers_image_assessment: The Microsoft Defender Container image assessment - configuration. - :vartype mdc_containers_image_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingMdcContainersImageAssessment - :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless - discovery configuration. - :vartype mdc_containers_agentless_discovery_k8_s: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "native_cloud_connection": { - "key": "nativeCloudConnection", - "type": "DefenderForContainersGcpOfferingNativeCloudConnection", - }, - "data_pipeline_native_cloud_connection": { - "key": "dataPipelineNativeCloudConnection", - "type": "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", - }, - "audit_logs_auto_provisioning_flag": {"key": "auditLogsAutoProvisioningFlag", "type": "bool"}, - "defender_agent_auto_provisioning_flag": {"key": "defenderAgentAutoProvisioningFlag", "type": "bool"}, - "policy_agent_auto_provisioning_flag": {"key": "policyAgentAutoProvisioningFlag", "type": "bool"}, - "mdc_containers_image_assessment": { - "key": "mdcContainersImageAssessment", - "type": "DefenderForContainersGcpOfferingMdcContainersImageAssessment", - }, - "mdc_containers_agentless_discovery_k8_s": { - "key": "mdcContainersAgentlessDiscoveryK8s", - "type": "DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S", - }, - } - - def __init__( - self, - *, - native_cloud_connection: Optional["_models.DefenderForContainersGcpOfferingNativeCloudConnection"] = None, - data_pipeline_native_cloud_connection: Optional[ - "_models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection" - ] = None, - audit_logs_auto_provisioning_flag: Optional[bool] = None, - defender_agent_auto_provisioning_flag: Optional[bool] = None, - policy_agent_auto_provisioning_flag: Optional[bool] = None, - mdc_containers_image_assessment: Optional[ - "_models.DefenderForContainersGcpOfferingMdcContainersImageAssessment" - ] = None, - mdc_containers_agentless_discovery_k8_s: Optional[ - "_models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword native_cloud_connection: The native cloud connection configuration. - :paramtype native_cloud_connection: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection - :keyword data_pipeline_native_cloud_connection: The native cloud connection configuration. - :paramtype data_pipeline_native_cloud_connection: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection # pylint: disable=line-too-long - :keyword audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. - :paramtype audit_logs_auto_provisioning_flag: bool - :keyword defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes - agent auto provisioning enabled. - :paramtype defender_agent_auto_provisioning_flag: bool - :keyword policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning - enabled. - :paramtype policy_agent_auto_provisioning_flag: bool - :keyword mdc_containers_image_assessment: The Microsoft Defender Container image assessment - configuration. - :paramtype mdc_containers_image_assessment: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingMdcContainersImageAssessment - :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless - discovery configuration. - :paramtype mdc_containers_agentless_discovery_k8_s: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForContainersGcp" - self.native_cloud_connection = native_cloud_connection - self.data_pipeline_native_cloud_connection = data_pipeline_native_cloud_connection - self.audit_logs_auto_provisioning_flag = audit_logs_auto_provisioning_flag - self.defender_agent_auto_provisioning_flag = defender_agent_auto_provisioning_flag - self.policy_agent_auto_provisioning_flag = policy_agent_auto_provisioning_flag - self.mdc_containers_image_assessment = mdc_containers_image_assessment - self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s - - -class DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection( - _serialization.Model -): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The data collection service account email address in GCP - for this offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The data collection GCP workload identity provider id for - this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The data collection service account email address in - GCP for this offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The data collection GCP workload identity provider id - for this offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S( - _serialization.Model -): # pylint: disable=name-too-long - """The Microsoft Defender Container agentless discovery configuration. - - :ivar enabled: Is Microsoft Defender container agentless discovery enabled. - :vartype enabled: bool - :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this feature. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender container agentless discovery enabled. - :paramtype enabled: bool - :keyword workload_identity_provider_id: The workload identity provider id in GCP for this - feature. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - feature. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class DefenderForContainersGcpOfferingMdcContainersImageAssessment( - _serialization.Model -): # pylint: disable=name-too-long - """The Microsoft Defender Container image assessment configuration. - - :ivar enabled: Is Microsoft Defender container image assessment enabled. - :vartype enabled: bool - :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this feature. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender container image assessment enabled. - :paramtype enabled: bool - :keyword workload_identity_provider_id: The workload identity provider id in GCP for this - feature. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - feature. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class DefenderForContainersGcpOfferingNativeCloudConnection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id for this - offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForDatabasesGcpOffering(CloudOffering): - """The Defender for Databases GCP offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning - :ivar defender_for_databases_arc_auto_provisioning: The native cloud connection configuration. - :vartype defender_for_databases_arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning # pylint: disable=line-too-long - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioning", - }, - "defender_for_databases_arc_auto_provisioning": { - "key": "defenderForDatabasesArcAutoProvisioning", - "type": "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", - }, - } - - def __init__( - self, - *, - arc_auto_provisioning: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioning"] = None, - defender_for_databases_arc_auto_provisioning: Optional[ - "_models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning - :keyword defender_for_databases_arc_auto_provisioning: The native cloud connection - configuration. - :paramtype defender_for_databases_arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDatabasesGcp" - self.arc_auto_provisioning = arc_auto_provisioning - self.defender_for_databases_arc_auto_provisioning = defender_for_databases_arc_auto_provisioning - - -class DefenderForDatabasesGcpOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: Configuration for servers Arc auto provisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: Configuration for servers Arc auto provisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for servers Arc auto provisioning. - - :ivar proxy: Optional http proxy endpoint to use for the Arc agent. - :vartype proxy: str - :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :vartype private_link_scope: str - """ - - _attribute_map = { - "proxy": {"key": "proxy", "type": "str"}, - "private_link_scope": {"key": "privateLinkScope", "type": "str"}, - } - - def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword proxy: Optional http proxy endpoint to use for the Arc agent. - :paramtype proxy: str - :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :paramtype private_link_scope: str - """ - super().__init__(**kwargs) - self.proxy = proxy - self.private_link_scope = private_link_scope - - -class DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning( - _serialization.Model -): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar service_account_email_address: The service account email address in GCP for this - offering. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. - :vartype workload_identity_provider_id: str - """ - - _attribute_map = { - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - } - - def __init__( - self, - *, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_account_email_address: The service account email address in GCP for this - offering. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id for this - offering. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - - -class DefenderForDevOpsAzureDevOpsOffering(CloudOffering): - """The Defender for DevOps for Azure DevOps offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDevOpsAzureDevOps" - - -class DefenderForDevOpsGithubOffering(CloudOffering): - """The Defender for DevOps for Github offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDevOpsGithub" - - -class DefenderForDevOpsGitLabOffering(CloudOffering): - """The Defender for DevOps for Gitlab offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForDevOpsGitLab" - - -class DefenderForServersAwsOffering(CloudOffering): - """The Defender for Servers AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar defender_for_servers: The Defender for servers connection configuration. - :vartype defender_for_servers: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :vartype va_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning - :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :vartype mde_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning - :ivar sub_plan: configuration for the servers offering subPlan. - :vartype sub_plan: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingSubPlan - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVmScanners - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "defender_for_servers": { - "key": "defenderForServers", - "type": "DefenderForServersAwsOfferingDefenderForServers", - }, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForServersAwsOfferingArcAutoProvisioning", - }, - "va_auto_provisioning": { - "key": "vaAutoProvisioning", - "type": "DefenderForServersAwsOfferingVaAutoProvisioning", - }, - "mde_auto_provisioning": { - "key": "mdeAutoProvisioning", - "type": "DefenderForServersAwsOfferingMdeAutoProvisioning", - }, - "sub_plan": {"key": "subPlan", "type": "DefenderForServersAwsOfferingSubPlan"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersAwsOfferingVmScanners"}, - } - - def __init__( - self, - *, - defender_for_servers: Optional["_models.DefenderForServersAwsOfferingDefenderForServers"] = None, - arc_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioning"] = None, - va_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioning"] = None, - mde_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingMdeAutoProvisioning"] = None, - sub_plan: Optional["_models.DefenderForServersAwsOfferingSubPlan"] = None, - vm_scanners: Optional["_models.DefenderForServersAwsOfferingVmScanners"] = None, - **kwargs: Any - ) -> None: - """ - :keyword defender_for_servers: The Defender for servers connection configuration. - :paramtype defender_for_servers: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingDefenderForServers - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning - :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :paramtype va_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning - :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :paramtype mde_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning - :keyword sub_plan: configuration for the servers offering subPlan. - :paramtype sub_plan: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingSubPlan - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVmScanners - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForServersAws" - self.defender_for_servers = defender_for_servers - self.arc_auto_provisioning = arc_auto_provisioning - self.va_auto_provisioning = va_auto_provisioning - self.mde_auto_provisioning = mde_auto_provisioning - self.sub_plan = sub_plan - self.vm_scanners = vm_scanners - - -class DefenderForServersAwsOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar configuration: Configuration for servers Arc auto provisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersAwsOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - cloud_role_arn: Optional[str] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword configuration: Configuration for servers Arc auto provisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.cloud_role_arn = cloud_role_arn - self.configuration = configuration - - -class DefenderForServersAwsOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for servers Arc auto provisioning. - - :ivar proxy: Optional HTTP proxy endpoint to use for the Arc agent. - :vartype proxy: str - :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :vartype private_link_scope: str - """ - - _attribute_map = { - "proxy": {"key": "proxy", "type": "str"}, - "private_link_scope": {"key": "privateLinkScope", "type": "str"}, - } - - def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword proxy: Optional HTTP proxy endpoint to use for the Arc agent. - :paramtype proxy: str - :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :paramtype private_link_scope: str - """ - super().__init__(**kwargs) - self.proxy = proxy - self.private_link_scope = private_link_scope - - -class DefenderForServersAwsOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long - """The Defender for servers connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class DefenderForServersAwsOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender for Endpoint autoprovisioning configuration. - - :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :vartype configuration: JSON - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "object"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :paramtype configuration: JSON - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingSubPlan(_serialization.Model): - """configuration for the servers offering subPlan. - - :ivar type: The available sub plans. Known values are: "P1" and "P2". - :vartype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.SubPlan - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The available sub plans. Known values are: "P1" and "P2". - :paramtype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.SubPlan - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersAwsOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Vulnerability Assessment autoprovisioning configuration. - - :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingVaAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """configuration for Vulnerability Assessment autoprovisioning. - - :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :vartype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.Type - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :paramtype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.Type - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersAwsOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderForServersAwsOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersAwsOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersAwsOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - :ivar scanning_mode: The scanning mode for the VM scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. - :vartype exclusion_tags: dict[str, str] - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, - } - - def __init__( - self, - *, - cloud_role_arn: Optional[str] = None, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - :keyword scanning_mode: The scanning mode for the VM scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. - :paramtype exclusion_tags: dict[str, str] - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class DefenderForServersGcpOffering(CloudOffering): - """The Defender for Servers GCP offering configurations. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar defender_for_servers: The Defender for servers connection configuration. - :vartype defender_for_servers: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingDefenderForServers - :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. - :vartype arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning - :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :vartype va_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning - :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :vartype mde_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning - :ivar sub_plan: configuration for the servers offering subPlan. - :vartype sub_plan: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingSubPlan - :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :vartype vm_scanners: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVmScanners - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "defender_for_servers": { - "key": "defenderForServers", - "type": "DefenderForServersGcpOfferingDefenderForServers", - }, - "arc_auto_provisioning": { - "key": "arcAutoProvisioning", - "type": "DefenderForServersGcpOfferingArcAutoProvisioning", - }, - "va_auto_provisioning": { - "key": "vaAutoProvisioning", - "type": "DefenderForServersGcpOfferingVaAutoProvisioning", - }, - "mde_auto_provisioning": { - "key": "mdeAutoProvisioning", - "type": "DefenderForServersGcpOfferingMdeAutoProvisioning", - }, - "sub_plan": {"key": "subPlan", "type": "DefenderForServersGcpOfferingSubPlan"}, - "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersGcpOfferingVmScanners"}, - } - - def __init__( - self, - *, - defender_for_servers: Optional["_models.DefenderForServersGcpOfferingDefenderForServers"] = None, - arc_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioning"] = None, - va_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioning"] = None, - mde_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingMdeAutoProvisioning"] = None, - sub_plan: Optional["_models.DefenderForServersGcpOfferingSubPlan"] = None, - vm_scanners: Optional["_models.DefenderForServersGcpOfferingVmScanners"] = None, - **kwargs: Any - ) -> None: - """ - :keyword defender_for_servers: The Defender for servers connection configuration. - :paramtype defender_for_servers: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingDefenderForServers - :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. - :paramtype arc_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning - :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. - :paramtype va_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning - :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning - configuration. - :paramtype mde_auto_provisioning: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning - :keyword sub_plan: configuration for the servers offering subPlan. - :paramtype sub_plan: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingSubPlan - :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. - :paramtype vm_scanners: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVmScanners - """ - super().__init__(**kwargs) - self.offering_type: str = "DefenderForServersGcp" - self.defender_for_servers = defender_for_servers - self.arc_auto_provisioning = arc_auto_provisioning - self.va_auto_provisioning = va_auto_provisioning - self.mde_auto_provisioning = mde_auto_provisioning - self.sub_plan = sub_plan - self.vm_scanners = vm_scanners - - -class DefenderForServersGcpOfferingArcAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The ARC autoprovisioning configuration. - - :ivar enabled: Is arc auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: Configuration for servers Arc auto provisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersGcpOfferingArcAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is arc auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: Configuration for servers Arc auto provisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingArcAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for servers Arc auto provisioning. - - :ivar proxy: Optional HTTP proxy endpoint to use for the Arc agent. - :vartype proxy: str - :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :vartype private_link_scope: str - """ - - _attribute_map = { - "proxy": {"key": "proxy", "type": "str"}, - "private_link_scope": {"key": "privateLinkScope", "type": "str"}, - } - - def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword proxy: Optional HTTP proxy endpoint to use for the Arc agent. - :paramtype proxy: str - :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. - :paramtype private_link_scope: str - """ - super().__init__(**kwargs) - self.proxy = proxy - self.private_link_scope = private_link_scope - - -class DefenderForServersGcpOfferingDefenderForServers(_serialization.Model): # pylint: disable=name-too-long - """The Defender for servers connection configuration. - - :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. - :vartype workload_identity_provider_id: str - :ivar service_account_email_address: The service account email address in GCP for this feature. - :vartype service_account_email_address: str - """ - - _attribute_map = { - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - } - - def __init__( - self, - *, - workload_identity_provider_id: Optional[str] = None, - service_account_email_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword workload_identity_provider_id: The workload identity provider id in GCP for this - feature. - :paramtype workload_identity_provider_id: str - :keyword service_account_email_address: The service account email address in GCP for this - feature. - :paramtype service_account_email_address: str - """ - super().__init__(**kwargs) - self.workload_identity_provider_id = workload_identity_provider_id - self.service_account_email_address = service_account_email_address - - -class DefenderForServersGcpOfferingMdeAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Microsoft Defender for Endpoint autoprovisioning configuration. - - :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :vartype configuration: JSON - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "object"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. - :paramtype configuration: JSON - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingSubPlan(_serialization.Model): - """configuration for the servers offering subPlan. - - :ivar type: The available sub plans. Known values are: "P1" and "P2". - :vartype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.SubPlan - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The available sub plans. Known values are: "P1" and "P2". - :paramtype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.SubPlan - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersGcpOfferingVaAutoProvisioning(_serialization.Model): # pylint: disable=name-too-long - """The Vulnerability Assessment autoprovisioning configuration. - - :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": { - "key": "configuration", - "type": "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", - }, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingVaAutoProvisioningConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """configuration for Vulnerability Assessment autoprovisioning. - - :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :vartype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.Type - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or - 'Qualys'. Known values are: "Qualys" and "TVM". - :paramtype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.Type - """ - super().__init__(**kwargs) - self.type = type - - -class DefenderForServersGcpOfferingVmScanners(_serialization.Model): - """The Microsoft Defender for Server VM scanning configuration. - - :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. - :vartype enabled: bool - :ivar configuration: configuration for Microsoft Defender for Server VM scanning. - :vartype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVmScannersConfiguration - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "configuration": {"key": "configuration", "type": "DefenderForServersGcpOfferingVmScannersConfiguration"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - configuration: Optional["_models.DefenderForServersGcpOfferingVmScannersConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. - :paramtype enabled: bool - :keyword configuration: configuration for Microsoft Defender for Server VM scanning. - :paramtype configuration: - ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVmScannersConfiguration - """ - super().__init__(**kwargs) - self.enabled = enabled - self.configuration = configuration - - -class DefenderForServersGcpOfferingVmScannersConfiguration(_serialization.Model): # pylint: disable=name-too-long - """configuration for Microsoft Defender for Server VM scanning. - - :ivar scanning_mode: The scanning mode for the VM scan. "Default" - :vartype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode - :ivar exclusion_tags: VM tags that indicate that VM should not be scanned. - :vartype exclusion_tags: dict[str, str] - """ - - _attribute_map = { - "scanning_mode": {"key": "scanningMode", "type": "str"}, - "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, - } - - def __init__( - self, - *, - scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, - exclusion_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword scanning_mode: The scanning mode for the VM scan. "Default" - :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode - :keyword exclusion_tags: VM tags that indicate that VM should not be scanned. - :paramtype exclusion_tags: dict[str, str] - """ - super().__init__(**kwargs) - self.scanning_mode = scanning_mode - self.exclusion_tags = exclusion_tags - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ETag(_serialization.Model): - """Entity tag is used for comparing two or more entities from the same requested resource. - - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - """ - - _attribute_map = { - "etag": {"key": "etag", "type": "str"}, - } - - def __init__(self, *, etag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - """ - super().__init__(**kwargs) - self.etag = etag - - -class GcpOrganizationalData(_serialization.Model): - """The gcpOrganization data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - GcpOrganizationalDataMember, GcpOrganizationalDataOrganization - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - } - - _subtype_map = { - "organization_membership_type": { - "Member": "GcpOrganizationalDataMember", - "Organization": "GcpOrganizationalDataOrganization", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.organization_membership_type: Optional[str] = None - - -class GcpOrganizationalDataMember(GcpOrganizationalData): - """The gcpOrganization data for the member account. - - All required parameters must be populated in order to send to server. - - :ivar organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType - :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, - this will be the ID of the project's parent. - :vartype parent_hierarchy_id: str - :ivar management_project_number: The GCP management project number from organizational - onboarding. - :vartype management_project_number: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, - "management_project_number": {"key": "managementProjectNumber", "type": "str"}, - } - - def __init__( - self, - *, - parent_hierarchy_id: Optional[str] = None, - management_project_number: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword parent_hierarchy_id: If the multi cloud account is not of membership type - organization, this will be the ID of the project's parent. - :paramtype parent_hierarchy_id: str - :keyword management_project_number: The GCP management project number from organizational - onboarding. - :paramtype management_project_number: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Member" - self.parent_hierarchy_id = parent_hierarchy_id - self.management_project_number = management_project_number - - -class GcpOrganizationalDataOrganization(GcpOrganizationalData): - """The gcpOrganization data for the parent account. - - 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 organization_membership_type: The multi cloud account's membership type in the - organization. Required. Known values are: "Member" and "Organization". - :vartype organization_membership_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType - :ivar excluded_project_numbers: If the multi cloud account is of membership type organization, - list of accounts excluded from offering. - :vartype excluded_project_numbers: list[str] - :ivar service_account_email_address: The service account email address which represents the - organization level permissions container. - :vartype service_account_email_address: str - :ivar workload_identity_provider_id: The GCP workload identity provider id which represents the - permissions required to auto provision security connectors. - :vartype workload_identity_provider_id: str - :ivar organization_name: GCP organization name. - :vartype organization_name: str - """ - - _validation = { - "organization_membership_type": {"required": True}, - "organization_name": {"readonly": True}, - } - - _attribute_map = { - "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, - "excluded_project_numbers": {"key": "excludedProjectNumbers", "type": "[str]"}, - "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, - "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, - "organization_name": {"key": "organizationName", "type": "str"}, - } - - def __init__( - self, - *, - excluded_project_numbers: Optional[List[str]] = None, - service_account_email_address: Optional[str] = None, - workload_identity_provider_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword excluded_project_numbers: If the multi cloud account is of membership type - organization, list of accounts excluded from offering. - :paramtype excluded_project_numbers: list[str] - :keyword service_account_email_address: The service account email address which represents the - organization level permissions container. - :paramtype service_account_email_address: str - :keyword workload_identity_provider_id: The GCP workload identity provider id which represents - the permissions required to auto provision security connectors. - :paramtype workload_identity_provider_id: str - """ - super().__init__(**kwargs) - self.organization_membership_type: str = "Organization" - self.excluded_project_numbers = excluded_project_numbers - self.service_account_email_address = service_account_email_address - self.workload_identity_provider_id = workload_identity_provider_id - self.organization_name = None - - -class GcpProjectDetails(_serialization.Model): - """The details about the project represented by the security connector. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar project_number: The unique GCP Project number. - :vartype project_number: str - :ivar project_id: The GCP Project id. - :vartype project_id: str - :ivar workload_identity_pool_id: The GCP workload identity federation pool id. - :vartype workload_identity_pool_id: str - :ivar project_name: GCP project name. - :vartype project_name: str - """ - - _validation = { - "workload_identity_pool_id": {"readonly": True}, - "project_name": {"readonly": True}, - } - - _attribute_map = { - "project_number": {"key": "projectNumber", "type": "str"}, - "project_id": {"key": "projectId", "type": "str"}, - "workload_identity_pool_id": {"key": "workloadIdentityPoolId", "type": "str"}, - "project_name": {"key": "projectName", "type": "str"}, - } - - def __init__( - self, *, project_number: Optional[str] = None, project_id: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword project_number: The unique GCP Project number. - :paramtype project_number: str - :keyword project_id: The GCP Project id. - :paramtype project_id: str - """ - super().__init__(**kwargs) - self.project_number = project_number - self.project_id = project_id - self.workload_identity_pool_id = None - self.project_name = None - - -class GcpProjectEnvironmentData(EnvironmentData): - """The GCP project connector environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType - :ivar organizational_data: The Gcp project's organizational data. - :vartype organizational_data: - ~azure.mgmt.security.v2023_10_01_preview.models.GcpOrganizationalData - :ivar project_details: The Gcp project's details. - :vartype project_details: ~azure.mgmt.security.v2023_10_01_preview.models.GcpProjectDetails - :ivar scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). - :vartype scan_interval: int - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - "organizational_data": {"key": "organizationalData", "type": "GcpOrganizationalData"}, - "project_details": {"key": "projectDetails", "type": "GcpProjectDetails"}, - "scan_interval": {"key": "scanInterval", "type": "int"}, - } - - def __init__( - self, - *, - organizational_data: Optional["_models.GcpOrganizationalData"] = None, - project_details: Optional["_models.GcpProjectDetails"] = None, - scan_interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword organizational_data: The Gcp project's organizational data. - :paramtype organizational_data: - ~azure.mgmt.security.v2023_10_01_preview.models.GcpOrganizationalData - :keyword project_details: The Gcp project's details. - :paramtype project_details: ~azure.mgmt.security.v2023_10_01_preview.models.GcpProjectDetails - :keyword scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). - :paramtype scan_interval: int - """ - super().__init__(**kwargs) - self.environment_type: str = "GcpProject" - self.organizational_data = organizational_data - self.project_details = project_details - self.scan_interval = scan_interval - - -class GithubScopeEnvironmentData(EnvironmentData): - """The github scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "GithubScope" - - -class GitlabScopeEnvironmentData(EnvironmentData): - """The GitLab scope connector's environment data. - - All required parameters must be populated in order to send to server. - - :ivar environment_type: The type of the environment data. Required. Known values are: - "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". - :vartype environment_type: str or - ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType - """ - - _validation = { - "environment_type": {"required": True}, - } - - _attribute_map = { - "environment_type": {"key": "environmentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.environment_type: str = "GitlabScope" - - -class InformationProtectionAwsOffering(CloudOffering): - """The information protection for AWS offering. - - 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 offering_type: The type of the security offering. Required. Known values are: - "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", - "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", - "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", - "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", - "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". - :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType - :ivar description: The offering description. - :vartype description: str - :ivar information_protection: The native cloud connection configuration. - :vartype information_protection: - ~azure.mgmt.security.v2023_10_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - - _validation = { - "offering_type": {"required": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "offering_type": {"key": "offeringType", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "information_protection": { - "key": "informationProtection", - "type": "InformationProtectionAwsOfferingInformationProtection", - }, - } - - def __init__( - self, - *, - information_protection: Optional["_models.InformationProtectionAwsOfferingInformationProtection"] = None, - **kwargs: Any - ) -> None: - """ - :keyword information_protection: The native cloud connection configuration. - :paramtype information_protection: - ~azure.mgmt.security.v2023_10_01_preview.models.InformationProtectionAwsOfferingInformationProtection - """ - super().__init__(**kwargs) - self.offering_type: str = "InformationProtectionAws" - self.information_protection = information_protection - - -class InformationProtectionAwsOfferingInformationProtection(_serialization.Model): # pylint: disable=name-too-long - """The native cloud connection configuration. - - :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. - :vartype cloud_role_arn: str - """ - - _attribute_map = { - "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, - } - - def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. - :paramtype cloud_role_arn: str - """ - super().__init__(**kwargs) - self.cloud_role_arn = cloud_role_arn - - -class Kind(_serialization.Model): - """Describes an Azure resource with kind. - - :ivar kind: Kind of the resource. - :vartype kind: str - """ - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__(self, *, kind: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword kind: Kind of the resource. - :paramtype kind: str - """ - super().__init__(**kwargs) - self.kind = kind - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Tags(_serialization.Model): - """A list of key value pairs that describe the resource. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class TrackedResource(Resource, AzureTrackedResourceLocation, Kind, ETag, Tags): - """Describes an Azure tracked resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - """ - super().__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) - self.tags = tags - self.etag = etag - self.kind = kind - self.location = location - self.id = None - self.name = None - self.type = None - - -class SecurityConnector(TrackedResource): # pylint: disable=too-many-instance-attributes - """The security connector resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: A list of key value pairs that describe the resource. - :vartype tags: dict[str, str] - :ivar etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :vartype etag: str - :ivar kind: Kind of the resource. - :vartype kind: str - :ivar location: Location where the resource is stored. - :vartype location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.v2023_10_01_preview.models.SystemData - :ivar hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector, project number in case of GCP connector). - :vartype hierarchy_identifier: str - :ivar hierarchy_identifier_trial_end_date: The date on which the trial period will end, if - applicable. Trial period exists for 30 days after upgrading to payed offerings. - :vartype hierarchy_identifier_trial_end_date: ~datetime.datetime - :ivar environment_name: The multi cloud resource's cloud name. Known values are: "Azure", - "AWS", "GCP", "Github", "AzureDevOps", and "GitLab". - :vartype environment_name: str or ~azure.mgmt.security.v2023_10_01_preview.models.CloudName - :ivar offerings: A collection of offerings for the security connector. - :vartype offerings: list[~azure.mgmt.security.v2023_10_01_preview.models.CloudOffering] - :ivar environment_data: The security connector environment data. - :vartype environment_data: ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "hierarchy_identifier_trial_end_date": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "hierarchy_identifier": {"key": "properties.hierarchyIdentifier", "type": "str"}, - "hierarchy_identifier_trial_end_date": { - "key": "properties.hierarchyIdentifierTrialEndDate", - "type": "iso-8601", - }, - "environment_name": {"key": "properties.environmentName", "type": "str"}, - "offerings": {"key": "properties.offerings", "type": "[CloudOffering]"}, - "environment_data": {"key": "properties.environmentData", "type": "EnvironmentData"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - kind: Optional[str] = None, - location: Optional[str] = None, - hierarchy_identifier: Optional[str] = None, - environment_name: Optional[Union[str, "_models.CloudName"]] = None, - offerings: Optional[List["_models.CloudOffering"]] = None, - environment_data: Optional["_models.EnvironmentData"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: A list of key value pairs that describe the resource. - :paramtype tags: dict[str, str] - :keyword etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :paramtype etag: str - :keyword kind: Kind of the resource. - :paramtype kind: str - :keyword location: Location where the resource is stored. - :paramtype location: str - :keyword hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS - connector, project number in case of GCP connector). - :paramtype hierarchy_identifier: str - :keyword environment_name: The multi cloud resource's cloud name. Known values are: "Azure", - "AWS", "GCP", "Github", "AzureDevOps", and "GitLab". - :paramtype environment_name: str or ~azure.mgmt.security.v2023_10_01_preview.models.CloudName - :keyword offerings: A collection of offerings for the security connector. - :paramtype offerings: list[~azure.mgmt.security.v2023_10_01_preview.models.CloudOffering] - :keyword environment_data: The security connector environment data. - :paramtype environment_data: ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentData - """ - super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) - self.system_data = None - self.hierarchy_identifier = hierarchy_identifier - self.hierarchy_identifier_trial_end_date = None - self.environment_name = environment_name - self.offerings = offerings - self.environment_data = environment_data - - -class SecurityConnectorsList(_serialization.Model): - """List of security connectors response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of security connectors under the given scope. Required. - :vartype value: list[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityConnector]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.SecurityConnector"], **kwargs: Any) -> None: - """ - :keyword value: The list of security connectors under the given scope. Required. - :paramtype value: list[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = 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.security.v2023_10_01_preview.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.security.v2023_10_01_preview.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.security.v2023_10_01_preview.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.security.v2023_10_01_preview.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 diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_security_center_enums.py deleted file mode 100644 index d93bbb6e8d04..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_security_center_enums.py +++ /dev/null @@ -1,89 +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 CloudName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud resource's cloud name.""" - - AZURE = "Azure" - AWS = "AWS" - GCP = "GCP" - GITHUB = "Github" - AZURE_DEV_OPS = "AzureDevOps" - GIT_LAB = "GitLab" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class EnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the environment data.""" - - AWS_ACCOUNT = "AwsAccount" - GCP_PROJECT = "GcpProject" - GITHUB_SCOPE = "GithubScope" - AZURE_DEV_OPS_SCOPE = "AzureDevOpsScope" - GITLAB_SCOPE = "GitlabScope" - - -class OfferingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the security offering.""" - - CSPM_MONITOR_AWS = "CspmMonitorAws" - DEFENDER_FOR_CONTAINERS_AWS = "DefenderForContainersAws" - DEFENDER_FOR_SERVERS_AWS = "DefenderForServersAws" - DEFENDER_FOR_DATABASES_AWS = "DefenderForDatabasesAws" - INFORMATION_PROTECTION_AWS = "InformationProtectionAws" - CSPM_MONITOR_GCP = "CspmMonitorGcp" - CSPM_MONITOR_GITHUB = "CspmMonitorGithub" - CSPM_MONITOR_AZURE_DEV_OPS = "CspmMonitorAzureDevOps" - DEFENDER_FOR_SERVERS_GCP = "DefenderForServersGcp" - DEFENDER_FOR_CONTAINERS_GCP = "DefenderForContainersGcp" - DEFENDER_FOR_DATABASES_GCP = "DefenderForDatabasesGcp" - DEFENDER_CSPM_AWS = "DefenderCspmAws" - DEFENDER_CSPM_GCP = "DefenderCspmGcp" - DEFENDER_FOR_DEV_OPS_GITHUB = "DefenderForDevOpsGithub" - DEFENDER_FOR_DEV_OPS_AZURE_DEV_OPS = "DefenderForDevOpsAzureDevOps" - CSPM_MONITOR_GIT_LAB = "CspmMonitorGitLab" - DEFENDER_FOR_DEV_OPS_GIT_LAB = "DefenderForDevOpsGitLab" - - -class OrganizationMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The multi cloud account's membership type in the organization.""" - - MEMBER = "Member" - ORGANIZATION = "Organization" - - -class ScanningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scanning mode for the VM scan.""" - - DEFAULT = "Default" - - -class SubPlan(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The available sub plans.""" - - P1 = "P1" - P2 = "P2" - - -class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or 'Qualys'.""" - - QUALYS = "Qualys" - TVM = "TVM" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/__init__.py deleted file mode 100644 index 8e4ac6c4f04e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._security_connectors_operations import SecurityConnectorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityConnectorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_security_connectors_operations.py deleted file mode 100644 index aa330ea3ac83..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_security_connectors_operations.py +++ /dev/null @@ -1,820 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _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_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" - ), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class SecurityConnectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_10_01_preview.SecurityCenter`'s - :attr:`security_connectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in - the response to get the next page of security connectors for the specified subscription. - - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] - :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._api_version or "2023-10-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: - """Lists all the security connectors in the specified resource group. Use the 'nextLink' property - in the response to get the next page of security connectors for the specified resource group. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :return: An iterator like instance of either SecurityConnector or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] - :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._api_version or "2023-10-01-preview") - ) - cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> _models.SecurityConnector: - """Retrieves details of a specific security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") - ) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Creates or updates a security connector. If a security connector is already created and a - subsequent request is issued for the same security connector id, then it will be updated. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityConnector", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: _models.SecurityConnector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Required. - :type security_connector: 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: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - security_connector_name: str, - security_connector: Union[_models.SecurityConnector, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityConnector: - """Updates a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param security_connector: The security connector resource. Is either a SecurityConnector type - or a IO[bytes] type. Required. - :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector or - IO[bytes] - :return: SecurityConnector or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_connector, (IOBase, bytes)): - _content = security_connector - else: - _json = self._serialize.body(security_connector, "SecurityConnector") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityConnector", pipeline_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, security_connector_name: str, **kwargs: Any - ) -> None: - """Deletes a security connector. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_configuration.py deleted file mode 100644 index 6763c6c984db..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :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 "2023-11-15". 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", "2023-11-15") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_metadata.json deleted file mode 100644 index 1cdcdc5c20d1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2023-11-15", - "total_api_version_list": ["2023-11-15"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. The value must be an UUID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. The value must be an UUID. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "api_collections": "APICollectionsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_security_center.py deleted file mode 100644 index 8a8ddd7dc45c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_security_center.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import APICollectionsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar api_collections: APICollectionsOperations operations - :vartype api_collections: azure.mgmt.security.v2023_11_15.operations.APICollectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-11-15". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.api_collections = APICollectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-11-15" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_configuration.py deleted file mode 100644 index 739850fb9b60..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :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 "2023-11-15". 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", "2023-11-15") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_security_center.py deleted file mode 100644 index cef57f7964c6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_security_center.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import APICollectionsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar api_collections: APICollectionsOperations operations - :vartype api_collections: - azure.mgmt.security.v2023_11_15.aio.operations.APICollectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-11-15". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.api_collections = APICollectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-11-15" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/__init__.py deleted file mode 100644 index 7ca7884efe21..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._api_collections_operations import APICollectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "APICollectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_api_collections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_api_collections_operations.py deleted file mode 100644 index 74519e736fd4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_api_collections_operations.py +++ /dev/null @@ -1,582 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union, cast -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._api_collections_operations import ( - build_get_by_azure_api_management_service_request, - build_list_by_azure_api_management_service_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_offboard_azure_api_management_api_request, - build_onboard_azure_api_management_api_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class APICollectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_11_15.aio.SecurityCenter`'s - :attr:`api_collections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ApiCollection"]: - """Gets a list of API collections within a subscription. - - Gets a list of API collections within a subscription that have been onboarded to Microsoft - Defender for APIs. - - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] - :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._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ApiCollectionList", 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_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ApiCollection"]: - """Gets a list of API collections within a resource group. - - Gets a list of API collections within a resource group that have been onboarded to Microsoft - Defender for APIs. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] - :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._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ApiCollectionList", 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_by_azure_api_management_service( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ApiCollection"]: - """Gets a list of onboarded Azure API Management APIs. - - Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for - APIs. If an Azure API Management API is onboarded to Microsoft Defender for APIs, the system - will monitor the operations within the Azure API Management API for intrusive behaviors and - provide alerts for attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] - :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._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_azure_api_management_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ApiCollectionList", 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_by_azure_api_management_service( - self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any - ) -> _models.ApiCollection: - """Gets an onboarded Azure API Management API. - - Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an - Azure API Management API is onboarded to Microsoft Defender for APIs, the system will monitor - the operations within the Azure API Management API for intrusive behaviors and provide alerts - for attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_id: API revision identifier. Must be unique in the API Management service instance. - Non-current revision has ;rev=n as a suffix where n is the revision number. Required. - :type api_id: str - :return: ApiCollection or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_11_15.models.ApiCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - - _request = build_get_by_azure_api_management_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApiCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _onboard_azure_api_management_api_initial( # pylint: disable=name-too-long - self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any - ) -> _models.ApiCollection: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - - _request = build_onboard_azure_api_management_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiCollection", pipeline_response) - - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = self._deserialize("ApiCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_onboard_azure_api_management_api( - self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ApiCollection]: - """Onboard an Azure API Management API to Microsoft Defender for APIs. - - Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start - monitoring the operations within the Azure Management API for intrusive behaviors and provide - alerts for attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_id: API revision identifier. Must be unique in the API Management service instance. - Non-current revision has ;rev=n as a suffix where n is the revision number. Required. - :type api_id: str - :return: An instance of AsyncLROPoller that returns either ApiCollection or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_11_15.models.ApiCollection] - :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._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollection] = 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._onboard_azure_api_management_api_initial( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiCollection", pipeline_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.ApiCollection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ApiCollection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def offboard_azure_api_management_api( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any - ) -> None: - """Offboard an Azure API Management API from Microsoft Defender for APIs. - - Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop - monitoring the operations within the Azure API Management API for intrusive behaviors. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_id: API revision identifier. Must be unique in the API Management service instance. - Non-current revision has ;rev=n as a suffix where n is the revision number. Required. - :type api_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_offboard_azure_api_management_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/__init__.py deleted file mode 100644 index 963840654215..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/__init__.py +++ /dev/null @@ -1,31 +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 ._models_py3 import ApiCollection -from ._models_py3 import ApiCollectionList -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Resource - -from ._security_center_enums import ProvisioningState -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApiCollection", - "ApiCollectionList", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Resource", - "ProvisioningState", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_models_py3.py deleted file mode 100644 index 238ceee2e173..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_models_py3.py +++ /dev/null @@ -1,263 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ApiCollection(Resource): # pylint: disable=too-many-instance-attributes - """An API collection as represented by Microsoft Defender for APIs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: Gets the provisioning state of the API collection. Known values are: - "Succeeded", "Failed", "Canceled", and "InProgress". - :vartype provisioning_state: str or ~azure.mgmt.security.v2023_11_15.models.ProvisioningState - :ivar display_name: The display name of the API collection. - :vartype display_name: str - :ivar discovered_via: The resource Id of the resource from where this API collection was - discovered. - :vartype discovered_via: str - :ivar base_url: The base URI for this API collection. All endpoints of this API collection - extend this base URI. - :vartype base_url: str - :ivar number_of_api_endpoints: The number of API endpoints discovered in this API collection. - :vartype number_of_api_endpoints: int - :ivar number_of_inactive_api_endpoints: The number of API endpoints in this API collection that - have not received any API traffic in the last 30 days. - :vartype number_of_inactive_api_endpoints: int - :ivar number_of_unauthenticated_api_endpoints: The number of API endpoints in this API - collection that are unauthenticated. - :vartype number_of_unauthenticated_api_endpoints: int - :ivar number_of_external_api_endpoints: The number of API endpoints in this API collection for - which API traffic from the internet was observed. - :vartype number_of_external_api_endpoints: int - :ivar number_of_api_endpoints_with_sensitive_data_exposed: The number of API endpoints in this - API collection which are exposing sensitive data in their requests and/or responses. - :vartype number_of_api_endpoints_with_sensitive_data_exposed: int - :ivar sensitivity_label: The highest priority sensitivity label from Microsoft Purview in this - API collection. - :vartype sensitivity_label: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "display_name": {"readonly": True}, - "discovered_via": {"readonly": True}, - "base_url": {"readonly": True}, - "number_of_api_endpoints": {"readonly": True}, - "number_of_inactive_api_endpoints": {"readonly": True}, - "number_of_unauthenticated_api_endpoints": {"readonly": True}, - "number_of_external_api_endpoints": {"readonly": True}, - "number_of_api_endpoints_with_sensitive_data_exposed": {"readonly": True}, - "sensitivity_label": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "discovered_via": {"key": "properties.discoveredVia", "type": "str"}, - "base_url": {"key": "properties.baseUrl", "type": "str"}, - "number_of_api_endpoints": {"key": "properties.numberOfApiEndpoints", "type": "int"}, - "number_of_inactive_api_endpoints": {"key": "properties.numberOfInactiveApiEndpoints", "type": "int"}, - "number_of_unauthenticated_api_endpoints": { - "key": "properties.numberOfUnauthenticatedApiEndpoints", - "type": "int", - }, - "number_of_external_api_endpoints": {"key": "properties.numberOfExternalApiEndpoints", "type": "int"}, - "number_of_api_endpoints_with_sensitive_data_exposed": { - "key": "properties.numberOfApiEndpointsWithSensitiveDataExposed", - "type": "int", - }, - "sensitivity_label": {"key": "properties.sensitivityLabel", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provisioning_state = None - self.display_name = None - self.discovered_via = None - self.base_url = None - self.number_of_api_endpoints = None - self.number_of_inactive_api_endpoints = None - self.number_of_unauthenticated_api_endpoints = None - self.number_of_external_api_endpoints = None - self.number_of_api_endpoints_with_sensitive_data_exposed = None - self.sensitivity_label = None - - -class ApiCollectionList(_serialization.Model): - """Page of a list of API collections as represented by Microsoft Defender for APIs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: API collections in this page. - :vartype value: list[~azure.mgmt.security.v2023_11_15.models.ApiCollection] - :ivar next_link: The URI to fetch the next page. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ApiCollection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.security.v2023_11_15.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2023_11_15.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.security.v2023_11_15.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.security.v2023_11_15.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_security_center_enums.py deleted file mode 100644 index 018a701d8035..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_security_center_enums.py +++ /dev/null @@ -1,19 +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 ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the provisioning state of the API collection.""" - - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - IN_PROGRESS = "InProgress" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/__init__.py deleted file mode 100644 index 7ca7884efe21..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._api_collections_operations import APICollectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "APICollectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_api_collections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_api_collections_operations.py deleted file mode 100644 index 777ee1535fd1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_api_collections_operations.py +++ /dev/null @@ -1,790 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union, cast -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/apiCollections") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/apiCollections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_azure_api_management_service_request( # pylint: disable=name-too-long - resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serviceName": _SERIALIZER.url( - "service_name", - service_name, - "str", - max_length=50, - min_length=1, - pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[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_get_by_azure_api_management_service_request( # pylint: disable=name-too-long - resource_group_name: str, service_name: str, api_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", "2023-11-15")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serviceName": _SERIALIZER.url( - "service_name", - service_name, - "str", - max_length=50, - min_length=1, - pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, 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_onboard_azure_api_management_api_request( # pylint: disable=name-too-long - resource_group_name: str, service_name: str, api_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", "2023-11-15")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serviceName": _SERIALIZER.url( - "service_name", - service_name, - "str", - max_length=50, - min_length=1, - pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_offboard_azure_api_management_api_request( # pylint: disable=name-too-long - resource_group_name: str, service_name: str, api_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", "2023-11-15")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serviceName": _SERIALIZER.url( - "service_name", - service_name, - "str", - max_length=50, - min_length=1, - pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, 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) - - -class APICollectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2023_11_15.SecurityCenter`'s - :attr:`api_collections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ApiCollection"]: - """Gets a list of API collections within a subscription. - - Gets a list of API collections within a subscription that have been onboarded to Microsoft - Defender for APIs. - - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] - :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._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ApiCollectionList", 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_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ApiCollection"]: - """Gets a list of API collections within a resource group. - - Gets a list of API collections within a resource group that have been onboarded to Microsoft - Defender for APIs. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] - :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._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ApiCollectionList", 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_by_azure_api_management_service( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> Iterable["_models.ApiCollection"]: - """Gets a list of onboarded Azure API Management APIs. - - Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for - APIs. If an Azure API Management API is onboarded to Microsoft Defender for APIs, the system - will monitor the operations within the Azure API Management API for intrusive behaviors and - provide alerts for attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] - :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._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_azure_api_management_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ApiCollectionList", 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_by_azure_api_management_service( - self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any - ) -> _models.ApiCollection: - """Gets an onboarded Azure API Management API. - - Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an - Azure API Management API is onboarded to Microsoft Defender for APIs, the system will monitor - the operations within the Azure API Management API for intrusive behaviors and provide alerts - for attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_id: API revision identifier. Must be unique in the API Management service instance. - Non-current revision has ;rev=n as a suffix where n is the revision number. Required. - :type api_id: str - :return: ApiCollection or the result of cls(response) - :rtype: ~azure.mgmt.security.v2023_11_15.models.ApiCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - - _request = build_get_by_azure_api_management_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApiCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _onboard_azure_api_management_api_initial( # pylint: disable=name-too-long - self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any - ) -> _models.ApiCollection: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - - _request = build_onboard_azure_api_management_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiCollection", pipeline_response) - - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = self._deserialize("ApiCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_onboard_azure_api_management_api( - self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any - ) -> LROPoller[_models.ApiCollection]: - """Onboard an Azure API Management API to Microsoft Defender for APIs. - - Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start - monitoring the operations within the Azure Management API for intrusive behaviors and provide - alerts for attacks that have been detected. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_id: API revision identifier. Must be unique in the API Management service instance. - Non-current revision has ;rev=n as a suffix where n is the revision number. Required. - :type api_id: str - :return: An instance of LROPoller that returns either ApiCollection or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_11_15.models.ApiCollection] - :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._api_version or "2023-11-15")) - cls: ClsType[_models.ApiCollection] = 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._onboard_azure_api_management_api_initial( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiCollection", pipeline_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.ApiCollection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ApiCollection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def offboard_azure_api_management_api( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any - ) -> None: - """Offboard an Azure API Management API from Microsoft Defender for APIs. - - Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop - monitoring the operations within the Azure API Management API for intrusive behaviors. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_id: API revision identifier. Must be unique in the API Management service instance. - Non-current revision has ;rev=n as a suffix where n is the revision number. Required. - :type api_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_offboard_azure_api_management_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_configuration.py deleted file mode 100644 index 65ebc17428bd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2024-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_metadata.json deleted file mode 100644 index 9f706f34cd51..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2024-01-01", - "total_api_version_list": ["2024-01-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "pricings": "PricingsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_security_center.py deleted file mode 100644 index 55e6b7bf7bbf..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_security_center.py +++ /dev/null @@ -1,101 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import PricingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.v2024_01_01.operations.PricingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2024-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2024-01-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/_configuration.py deleted file mode 100644 index dcd7df64494f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/_configuration.py +++ /dev/null @@ -1,60 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2024-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/_security_center.py deleted file mode 100644 index 0e0d3813e2d8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/_security_center.py +++ /dev/null @@ -1,103 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import PricingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.v2024_01_01.aio.operations.PricingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2024-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2024-01-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/operations/__init__.py deleted file mode 100644 index 3f34d5a48636..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._pricings_operations import PricingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PricingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/operations/_pricings_operations.py deleted file mode 100644 index 16fbb01e20f8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/aio/operations/_pricings_operations.py +++ /dev/null @@ -1,381 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._pricings_operations import ( - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PricingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_01_01.aio.SecurityCenter`'s - :attr:`pricings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, scope_id: str, pricing_name: str, **kwargs: Any) -> _models.Pricing: - """Get the Defender plans pricing configurations of the selected scope (valid scopes are resource - id or a subscription id). At the resource level, supported resource types are 'VirtualMachines, - VMSS and ARC Machines'. - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-01-01")) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - _request = build_get_request( - scope_id=scope_id, - pricing_name=pricing_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - scope_id: str, - pricing_name: str, - pricing: _models.Pricing, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid - scopes are: subscription id or a specific resource id (Supported resources are: - 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: ~azure.mgmt.security.v2024_01_01.models.Pricing - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - scope_id: str, - pricing_name: str, - pricing: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid - scopes are: subscription id or a specific resource id (Supported resources are: - 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: 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: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, scope_id: str, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid - scopes are: subscription id or a specific resource id (Supported resources are: - 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. - :type pricing: ~azure.mgmt.security.v2024_01_01.models.Pricing or IO[bytes] - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pricing, (IOBase, bytes)): - _content = pricing - else: - _json = self._serialize.body(pricing, "Pricing") - - _request = build_update_request( - scope_id=scope_id, - pricing_name=pricing_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Pricing", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, scope_id: str, pricing_name: str, **kwargs: Any - ) -> None: - """Deletes a provided Microsoft Defender for Cloud pricing configuration in a specific resource. - Valid only for resource scope (Supported resources are: 'VirtualMachines, VMSS and ARC - MachinesS'). - - :param scope_id: The identifier of the resource, (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}). - Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - scope_id=scope_id, - pricing_name=pricing_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def list(self, scope_id: str, filter: Optional[str] = None, **kwargs: Any) -> _models.PricingList: - """Lists Microsoft Defender for Cloud pricing configurations of the scopeId, that match the - optional given $filter. Valid scopes are: subscription id or a specific resource id (Supported - resources are: 'VirtualMachines, VMSS and ARC Machines'). Valid $filter is: 'name in - ({planName1},{planName2},...)'. If $filter is not provided, the unfiltered list will be - returned. If '$filter=name in (planName1,planName2)' is provided, the returned list includes - the pricings set for 'planName1' and 'planName2' only. - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: PricingList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.PricingList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-01-01")) - cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) - - _request = build_list_request( - scope_id=scope_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PricingList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/__init__.py deleted file mode 100644 index 91487c87c1f6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/__init__.py +++ /dev/null @@ -1,43 +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 ._models_py3 import CloudErrorBody -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import Extension -from ._models_py3 import OperationStatus -from ._models_py3 import Pricing -from ._models_py3 import PricingList -from ._models_py3 import Resource - -from ._security_center_enums import Code -from ._security_center_enums import Enforce -from ._security_center_enums import Inherited -from ._security_center_enums import IsEnabled -from ._security_center_enums import PricingTier -from ._security_center_enums import ResourcesCoverageStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "ErrorAdditionalInfo", - "Extension", - "OperationStatus", - "Pricing", - "PricingList", - "Resource", - "Code", - "Enforce", - "Inherited", - "IsEnabled", - "PricingTier", - "ResourcesCoverageStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/_models_py3.py deleted file mode 100644 index 7906d603185c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/_models_py3.py +++ /dev/null @@ -1,397 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CloudErrorBody(_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.security.v2024_01_01.models.CloudErrorBody] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2024_01_01.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": "[CloudErrorBody]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class Extension(_serialization.Model): - """A plan's extension properties. - - 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 name: The extension name. Supported values are: :code:`
`:code:`
`\\ - **AgentlessDiscoveryForKubernetes** - API-based discovery of information about Kubernetes - cluster architecture, workload objects, and setup. Required for Kubernetes inventory, identity - and network exposure detection, attack path analysis and risk hunting as part of the cloud - security explorer. - Available for CloudPosture plan.:code:`
`:code:`
`\\ **OnUploadMalwareScanning** - - Limits the GB to be scanned per month for each storage account within the subscription. Once - this limit reached on a given storage account, Blobs won't be scanned during current calendar - month. - Available for StorageAccounts plan.:code:`
`:code:`
`\\ **SensitiveDataDiscovery** - - Sensitive data discovery identifies Blob storage container with sensitive data such as - credentials, credit cards, and more, to help prioritize and investigate security events. - Available for StorageAccounts and CloudPosture plans.:code:`
`:code:`
`\\ - **ContainerRegistriesVulnerabilityAssessments** - Provides vulnerability management for images - stored in your container registries. - Available for CloudPosture and Containers plans. Required. - :vartype name: str - :ivar is_enabled: Indicates whether the extension is enabled. Required. Known values are: - "True" and "False". - :vartype is_enabled: str or ~azure.mgmt.security.v2024_01_01.models.IsEnabled - :ivar additional_extension_properties: Property values associated with the extension. - :vartype additional_extension_properties: dict[str, any] - :ivar operation_status: Optional. A status describing the success/failure of the extension's - enablement/disablement operation. - :vartype operation_status: ~azure.mgmt.security.v2024_01_01.models.OperationStatus - """ - - _validation = { - "name": {"required": True}, - "is_enabled": {"required": True}, - "operation_status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "str"}, - "additional_extension_properties": {"key": "additionalExtensionProperties", "type": "{object}"}, - "operation_status": {"key": "operationStatus", "type": "OperationStatus"}, - } - - def __init__( - self, - *, - name: str, - is_enabled: Union[str, "_models.IsEnabled"], - additional_extension_properties: Optional[Dict[str, Any]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The extension name. Supported values are: :code:`
`:code:`
`\\ - **AgentlessDiscoveryForKubernetes** - API-based discovery of information about Kubernetes - cluster architecture, workload objects, and setup. Required for Kubernetes inventory, identity - and network exposure detection, attack path analysis and risk hunting as part of the cloud - security explorer. - Available for CloudPosture plan.:code:`
`:code:`
`\\ **OnUploadMalwareScanning** - - Limits the GB to be scanned per month for each storage account within the subscription. Once - this limit reached on a given storage account, Blobs won't be scanned during current calendar - month. - Available for StorageAccounts plan.:code:`
`:code:`
`\\ **SensitiveDataDiscovery** - - Sensitive data discovery identifies Blob storage container with sensitive data such as - credentials, credit cards, and more, to help prioritize and investigate security events. - Available for StorageAccounts and CloudPosture plans.:code:`
`:code:`
`\\ - **ContainerRegistriesVulnerabilityAssessments** - Provides vulnerability management for images - stored in your container registries. - Available for CloudPosture and Containers plans. Required. - :paramtype name: str - :keyword is_enabled: Indicates whether the extension is enabled. Required. Known values are: - "True" and "False". - :paramtype is_enabled: str or ~azure.mgmt.security.v2024_01_01.models.IsEnabled - :keyword additional_extension_properties: Property values associated with the extension. - :paramtype additional_extension_properties: dict[str, any] - """ - super().__init__(**kwargs) - self.name = name - self.is_enabled = is_enabled - self.additional_extension_properties = additional_extension_properties - self.operation_status = None - - -class OperationStatus(_serialization.Model): - """A status describing the success/failure of the extension's enablement/disablement operation. - - :ivar code: The operation status code. Known values are: "Succeeded" and "Failed". - :vartype code: str or ~azure.mgmt.security.v2024_01_01.models.Code - :ivar message: Additional information regarding the success/failure of the operation. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[Union[str, "_models.Code"]] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The operation status code. Known values are: "Succeeded" and "Failed". - :paramtype code: str or ~azure.mgmt.security.v2024_01_01.models.Code - :keyword message: Additional information regarding the success/failure of the operation. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class Resource(_serialization.Model): - """Describes an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Pricing(Resource): # pylint: disable=too-many-instance-attributes - """Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. The standard - tier offers advanced security capabilities, while the free tier offers basic security features. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar pricing_tier: Indicates whether the Defender plan is enabled on the selected scope. - Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. The standard - tier offers advanced security capabilities, while the free tier offers basic security features. - Known values are: "Free" and "Standard". - :vartype pricing_tier: str or ~azure.mgmt.security.v2024_01_01.models.PricingTier - :ivar sub_plan: The sub-plan selected for a Standard pricing configuration, when more than one - sub-plan is available. Each sub-plan enables a set of security features. When not specified, - full plan is applied. For VirtualMachines plan, available sub plans are 'P1' & 'P2', where for - resource level only 'P1' sub plan is supported. - :vartype sub_plan: str - :ivar free_trial_remaining_time: The duration left for the subscriptions free trial period - in - ISO 8601 format (e.g. P3Y6M4DT12H30M5S). - :vartype free_trial_remaining_time: ~datetime.timedelta - :ivar enablement_time: Optional. If ``pricingTier`` is ``Standard`` then this property holds - the date of the last time the ``pricingTier`` was set to ``Standard``\\ , when available (e.g - 2023-03-01T12:42:42.1921106Z). - :vartype enablement_time: ~datetime.datetime - :ivar enforce: If set to "False", it allows the descendants of this scope to override the - pricing configuration set on this scope (allows setting inherited="False"). If set to "True", - it prevents overrides and forces this pricing configuration on all the descendants of this - scope. This field is only available for subscription-level pricing. Known values are: "False" - and "True". - :vartype enforce: str or ~azure.mgmt.security.v2024_01_01.models.Enforce - :ivar inherited: "inherited" = "True" indicates that the current scope inherits its pricing - configuration from its parent. The ID of the parent scope that provides the inherited - configuration is displayed in the "inheritedFrom" field. On the other hand, "inherited" = - "False" indicates that the current scope has its own pricing configuration explicitly set, and - does not inherit from its parent. This field is read only and available only for resource-level - pricing. Known values are: "True" and "False". - :vartype inherited: str or ~azure.mgmt.security.v2024_01_01.models.Inherited - :ivar inherited_from: The id of the scope inherited from. "Null" if not inherited. This field - is only available for resource-level pricing. - :vartype inherited_from: str - :ivar resources_coverage_status: This field is available for subscription-level only, and - reflects the coverage status of the resources under the subscription. Please note: The - "pricingTier" field reflects the plan status of the subscription. However, since the plan - status can also be defined at the resource level, there might be misalignment between the - subscription's plan status and the resource status. This field helps indicate the coverage - status of the resources. Known values are: "FullyCovered", "PartiallyCovered", and - "NotCovered". - :vartype resources_coverage_status: str or - ~azure.mgmt.security.v2024_01_01.models.ResourcesCoverageStatus - :ivar extensions: Optional. List of extensions offered under a plan. - :vartype extensions: list[~azure.mgmt.security.v2024_01_01.models.Extension] - :ivar deprecated: Optional. True if the plan is deprecated. If there are replacing plans they - will appear in ``replacedBy`` property. - :vartype deprecated: bool - :ivar replaced_by: Optional. List of plans that replace this plan. This property exists only if - this plan is deprecated. - :vartype replaced_by: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "free_trial_remaining_time": {"readonly": True}, - "enablement_time": {"readonly": True}, - "inherited": {"readonly": True}, - "inherited_from": {"readonly": True}, - "resources_coverage_status": {"readonly": True}, - "deprecated": {"readonly": True}, - "replaced_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "pricing_tier": {"key": "properties.pricingTier", "type": "str"}, - "sub_plan": {"key": "properties.subPlan", "type": "str"}, - "free_trial_remaining_time": {"key": "properties.freeTrialRemainingTime", "type": "duration"}, - "enablement_time": {"key": "properties.enablementTime", "type": "iso-8601"}, - "enforce": {"key": "properties.enforce", "type": "str"}, - "inherited": {"key": "properties.inherited", "type": "str"}, - "inherited_from": {"key": "properties.inheritedFrom", "type": "str"}, - "resources_coverage_status": {"key": "properties.resourcesCoverageStatus", "type": "str"}, - "extensions": {"key": "properties.extensions", "type": "[Extension]"}, - "deprecated": {"key": "properties.deprecated", "type": "bool"}, - "replaced_by": {"key": "properties.replacedBy", "type": "[str]"}, - } - - def __init__( - self, - *, - pricing_tier: Optional[Union[str, "_models.PricingTier"]] = None, - sub_plan: Optional[str] = None, - enforce: Optional[Union[str, "_models.Enforce"]] = None, - extensions: Optional[List["_models.Extension"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword pricing_tier: Indicates whether the Defender plan is enabled on the selected scope. - Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. The standard - tier offers advanced security capabilities, while the free tier offers basic security features. - Known values are: "Free" and "Standard". - :paramtype pricing_tier: str or ~azure.mgmt.security.v2024_01_01.models.PricingTier - :keyword sub_plan: The sub-plan selected for a Standard pricing configuration, when more than - one sub-plan is available. Each sub-plan enables a set of security features. When not - specified, full plan is applied. For VirtualMachines plan, available sub plans are 'P1' & 'P2', - where for resource level only 'P1' sub plan is supported. - :paramtype sub_plan: str - :keyword enforce: If set to "False", it allows the descendants of this scope to override the - pricing configuration set on this scope (allows setting inherited="False"). If set to "True", - it prevents overrides and forces this pricing configuration on all the descendants of this - scope. This field is only available for subscription-level pricing. Known values are: "False" - and "True". - :paramtype enforce: str or ~azure.mgmt.security.v2024_01_01.models.Enforce - :keyword extensions: Optional. List of extensions offered under a plan. - :paramtype extensions: list[~azure.mgmt.security.v2024_01_01.models.Extension] - """ - super().__init__(**kwargs) - self.pricing_tier = pricing_tier - self.sub_plan = sub_plan - self.free_trial_remaining_time = None - self.enablement_time = None - self.enforce = enforce - self.inherited = None - self.inherited_from = None - self.resources_coverage_status = None - self.extensions = extensions - self.deprecated = None - self.replaced_by = None - - -class PricingList(_serialization.Model): - """List of pricing configurations response. - - All required parameters must be populated in order to send to server. - - :ivar value: List of pricing configurations. Required. - :vartype value: list[~azure.mgmt.security.v2024_01_01.models.Pricing] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Pricing]"}, - } - - def __init__(self, *, value: List["_models.Pricing"], **kwargs: Any) -> None: - """ - :keyword value: List of pricing configurations. Required. - :paramtype value: list[~azure.mgmt.security.v2024_01_01.models.Pricing] - """ - super().__init__(**kwargs) - self.value = value diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/_security_center_enums.py deleted file mode 100644 index 65b5e9cbe6f7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/models/_security_center_enums.py +++ /dev/null @@ -1,88 +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 Code(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operation status code.""" - - SUCCEEDED = "Succeeded" - """Extension was created/updated successfully.""" - FAILED = "Failed" - """Extension was not created/updated successfully. See operation status message for more details.""" - - -class Enforce(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """If set to "False", it allows the descendants of this scope to override the pricing - configuration set on this scope (allows setting inherited="False"). If set to "True", it - prevents overrides and forces this pricing configuration on all the descendants of this scope. - This field is only available for subscription-level pricing. - """ - - FALSE = "False" - """Allows the descendants of this scope to override the pricing configuration set on this scope - (allows setting inherited="False")""" - TRUE = "True" - """Prevents overrides and forces the current scope's pricing configuration to all descendants""" - - -class Inherited(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ "inherited" = "True" indicates that the current scope inherits its pricing configuration from - its parent. The ID of the parent scope that provides the inherited configuration is displayed - in the "inheritedFrom" field. On the other hand, "inherited" = "False" indicates that the - current scope has its own pricing configuration explicitly set, and does not inherit from its - parent. This field is read only and available only for resource-level pricing. - """ - - TRUE = "True" - """Indicates that the current scope is inheriting its pricing configuration from its parent""" - FALSE = "False" - """Indicates that the current scope sets its own pricing configuration and does not inherit it - from its parent""" - - -class IsEnabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates whether the extension is enabled.""" - - TRUE = "True" - """Indicates the extension is enabled""" - FALSE = "False" - """Indicates the extension is disabled""" - - -class PricingTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates whether the Defender plan is enabled on the selected scope. Microsoft Defender for - Cloud is provided in two pricing tiers: free and standard. The standard tier offers advanced - security capabilities, while the free tier offers basic security features. - """ - - FREE = "Free" - """Get free Microsoft Defender for Cloud experience with basic security features""" - STANDARD = "Standard" - """Get the standard Microsoft Defender for Cloud experience with advanced security features""" - - -class ResourcesCoverageStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This field is available for subscription-level only, and reflects the coverage status of the - resources under the subscription. Please note: The "pricingTier" field reflects the plan status - of the subscription. However, since the plan status can also be defined at the resource level, - there might be misalignment between the subscription's plan status and the resource status. - This field helps indicate the coverage status of the resources. - """ - - FULLY_COVERED = "FullyCovered" - """This value indicates that all resources associated with the subscription have the Defender plan - enabled.""" - PARTIALLY_COVERED = "PartiallyCovered" - """This value indicates that some resources under the subscription have the Defender plan enabled, - while others have it disabled. There is a mixed coverage status among resources.""" - NOT_COVERED = "NotCovered" - """This value indicates that the Defender plan is disabled for all resources under the - subscription. None of the resources are protected by the Defender plan.""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/operations/__init__.py deleted file mode 100644 index 3f34d5a48636..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/operations/__init__.py +++ /dev/null @@ -1,19 +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 ._pricings_operations import PricingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PricingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/operations/_pricings_operations.py deleted file mode 100644 index 1592557325b6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/operations/_pricings_operations.py +++ /dev/null @@ -1,483 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(scope_id: str, pricing_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scopeId}/providers/Microsoft.Security/pricings/{pricingName}") - path_format_arguments = { - "scopeId": _SERIALIZER.url("scope_id", scope_id, "str", skip_quote=True), - "pricingName": _SERIALIZER.url("pricing_name", pricing_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_update_request(scope_id: str, pricing_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-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", "/{scopeId}/providers/Microsoft.Security/pricings/{pricingName}") - path_format_arguments = { - "scopeId": _SERIALIZER.url("scope_id", scope_id, "str", skip_quote=True), - "pricingName": _SERIALIZER.url("pricing_name", pricing_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_delete_request(scope_id: str, pricing_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scopeId}/providers/Microsoft.Security/pricings/{pricingName}") - path_format_arguments = { - "scopeId": _SERIALIZER.url("scope_id", scope_id, "str", skip_quote=True), - "pricingName": _SERIALIZER.url("pricing_name", pricing_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(scope_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scopeId}/providers/Microsoft.Security/pricings") - path_format_arguments = { - "scopeId": _SERIALIZER.url("scope_id", scope_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PricingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_01_01.SecurityCenter`'s - :attr:`pricings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, scope_id: str, pricing_name: str, **kwargs: Any) -> _models.Pricing: - """Get the Defender plans pricing configurations of the selected scope (valid scopes are resource - id or a subscription id). At the resource level, supported resource types are 'VirtualMachines, - VMSS and ARC Machines'. - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-01-01")) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - _request = build_get_request( - scope_id=scope_id, - pricing_name=pricing_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - scope_id: str, - pricing_name: str, - pricing: _models.Pricing, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid - scopes are: subscription id or a specific resource id (Supported resources are: - 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: ~azure.mgmt.security.v2024_01_01.models.Pricing - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - scope_id: str, - pricing_name: str, - pricing: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid - scopes are: subscription id or a specific resource id (Supported resources are: - 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Required. - :type pricing: 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: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, scope_id: str, pricing_name: str, pricing: Union[_models.Pricing, IO[bytes]], **kwargs: Any - ) -> _models.Pricing: - """Updates a provided Microsoft Defender for Cloud pricing configuration in the scope. Valid - scopes are: subscription id or a specific resource id (Supported resources are: - 'VirtualMachines, VMSS and ARC Machines' and only for plan='VirtualMachines' and subPlan='P1'). - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :param pricing: Pricing object. Is either a Pricing type or a IO[bytes] type. Required. - :type pricing: ~azure.mgmt.security.v2024_01_01.models.Pricing or IO[bytes] - :return: Pricing or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.Pricing - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pricing, (IOBase, bytes)): - _content = pricing - else: - _json = self._serialize.body(pricing, "Pricing") - - _request = build_update_request( - scope_id=scope_id, - pricing_name=pricing_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Pricing", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Pricing", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, scope_id: str, pricing_name: str, **kwargs: Any - ) -> None: - """Deletes a provided Microsoft Defender for Cloud pricing configuration in a specific resource. - Valid only for resource scope (Supported resources are: 'VirtualMachines, VMSS and ARC - MachinesS'). - - :param scope_id: The identifier of the resource, (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}). - Required. - :type scope_id: str - :param pricing_name: name of the pricing configuration. Required. - :type pricing_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - scope_id=scope_id, - pricing_name=pricing_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list(self, scope_id: str, filter: Optional[str] = None, **kwargs: Any) -> _models.PricingList: - """Lists Microsoft Defender for Cloud pricing configurations of the scopeId, that match the - optional given $filter. Valid scopes are: subscription id or a specific resource id (Supported - resources are: 'VirtualMachines, VMSS and ARC Machines'). Valid $filter is: 'name in - ({planName1},{planName2},...)'. If $filter is not provided, the unfiltered list will be - returned. If '$filter=name in (planName1,planName2)' is provided, the returned list includes - the pricings set for 'planName1' and 'planName2' only. - - :param scope_id: The scope id of the pricing. Valid scopes are: subscription (format: - 'subscriptions/{subscriptionId}'), or a specific resource (format: - 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}) - - Supported resources are (VirtualMachines). Required. - :type scope_id: str - :param filter: OData filter. Optional. Default value is None. - :type filter: str - :return: PricingList or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_01_01.models.PricingList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-01-01")) - cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) - - _request = build_list_request( - scope_id=scope_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PricingList", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_01_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/__init__.py deleted file mode 100644 index e95a015ca6b8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/__init__.py +++ /dev/null @@ -1,26 +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 ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_configuration.py deleted file mode 100644 index eb4234ecffda..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_metadata.json deleted file mode 100644 index 256b1c68a0fd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_metadata.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "chosen_version": "2024-04-01", - "total_api_version_list": ["2024-04-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "azure_dev_ops_orgs": "AzureDevOpsOrgsOperations", - "azure_dev_ops_projects": "AzureDevOpsProjectsOperations", - "azure_dev_ops_repos": "AzureDevOpsReposOperations", - "dev_ops_configurations": "DevOpsConfigurationsOperations", - "git_hub_owners": "GitHubOwnersOperations", - "git_hub_repos": "GitHubReposOperations", - "git_lab_groups": "GitLabGroupsOperations", - "git_lab_subgroups": "GitLabSubgroupsOperations", - "git_lab_projects": "GitLabProjectsOperations", - "dev_ops_operation_results": "DevOpsOperationResultsOperations" - } -} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_security_center.py deleted file mode 100644 index 5c07ad7013a3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_security_center.py +++ /dev/null @@ -1,173 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AzureDevOpsOrgsOperations, - AzureDevOpsProjectsOperations, - AzureDevOpsReposOperations, - DevOpsConfigurationsOperations, - DevOpsOperationResultsOperations, - GitHubOwnersOperations, - GitHubReposOperations, - GitLabGroupsOperations, - GitLabProjectsOperations, - GitLabSubgroupsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar azure_dev_ops_orgs: AzureDevOpsOrgsOperations operations - :vartype azure_dev_ops_orgs: - azure.mgmt.security.v2024_04_01.operations.AzureDevOpsOrgsOperations - :ivar azure_dev_ops_projects: AzureDevOpsProjectsOperations operations - :vartype azure_dev_ops_projects: - azure.mgmt.security.v2024_04_01.operations.AzureDevOpsProjectsOperations - :ivar azure_dev_ops_repos: AzureDevOpsReposOperations operations - :vartype azure_dev_ops_repos: - azure.mgmt.security.v2024_04_01.operations.AzureDevOpsReposOperations - :ivar dev_ops_configurations: DevOpsConfigurationsOperations operations - :vartype dev_ops_configurations: - azure.mgmt.security.v2024_04_01.operations.DevOpsConfigurationsOperations - :ivar git_hub_owners: GitHubOwnersOperations operations - :vartype git_hub_owners: azure.mgmt.security.v2024_04_01.operations.GitHubOwnersOperations - :ivar git_hub_repos: GitHubReposOperations operations - :vartype git_hub_repos: azure.mgmt.security.v2024_04_01.operations.GitHubReposOperations - :ivar git_lab_groups: GitLabGroupsOperations operations - :vartype git_lab_groups: azure.mgmt.security.v2024_04_01.operations.GitLabGroupsOperations - :ivar git_lab_subgroups: GitLabSubgroupsOperations operations - :vartype git_lab_subgroups: - azure.mgmt.security.v2024_04_01.operations.GitLabSubgroupsOperations - :ivar git_lab_projects: GitLabProjectsOperations operations - :vartype git_lab_projects: azure.mgmt.security.v2024_04_01.operations.GitLabProjectsOperations - :ivar dev_ops_operation_results: DevOpsOperationResultsOperations operations - :vartype dev_ops_operation_results: - azure.mgmt.security.v2024_04_01.operations.DevOpsOperationResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2024-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.azure_dev_ops_orgs = AzureDevOpsOrgsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.azure_dev_ops_projects = AzureDevOpsProjectsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.azure_dev_ops_repos = AzureDevOpsReposOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.dev_ops_configurations = DevOpsConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_hub_owners = GitHubOwnersOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_hub_repos = GitHubReposOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_lab_groups = GitLabGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_lab_subgroups = GitLabSubgroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_lab_projects = GitLabProjectsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.dev_ops_operation_results = DevOpsOperationResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "SecurityCenter": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_version.py deleted file mode 100644 index 364f3c906cf9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/_version.py +++ /dev/null @@ -1,9 +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. -# -------------------------------------------------------------------------- - -VERSION = "7.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/__init__.py deleted file mode 100644 index d9a53c22b3e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/__init__.py +++ /dev/null @@ -1,23 +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 ._security_center import SecurityCenter - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "SecurityCenter", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/_configuration.py deleted file mode 100644 index 13f9f872a052..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/_configuration.py +++ /dev/null @@ -1,65 +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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenterConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for SecurityCenter. - - 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. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/_security_center.py deleted file mode 100644 index 0f5b9cee9bc8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/_security_center.py +++ /dev/null @@ -1,176 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import SecurityCenterConfiguration -from .operations import ( - AzureDevOpsOrgsOperations, - AzureDevOpsProjectsOperations, - AzureDevOpsReposOperations, - DevOpsConfigurationsOperations, - DevOpsOperationResultsOperations, - GitHubOwnersOperations, - GitHubReposOperations, - GitLabGroupsOperations, - GitLabProjectsOperations, - GitLabSubgroupsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """API spec for Microsoft.Security (Azure Security Center) resource provider. - - :ivar azure_dev_ops_orgs: AzureDevOpsOrgsOperations operations - :vartype azure_dev_ops_orgs: - azure.mgmt.security.v2024_04_01.aio.operations.AzureDevOpsOrgsOperations - :ivar azure_dev_ops_projects: AzureDevOpsProjectsOperations operations - :vartype azure_dev_ops_projects: - azure.mgmt.security.v2024_04_01.aio.operations.AzureDevOpsProjectsOperations - :ivar azure_dev_ops_repos: AzureDevOpsReposOperations operations - :vartype azure_dev_ops_repos: - azure.mgmt.security.v2024_04_01.aio.operations.AzureDevOpsReposOperations - :ivar dev_ops_configurations: DevOpsConfigurationsOperations operations - :vartype dev_ops_configurations: - azure.mgmt.security.v2024_04_01.aio.operations.DevOpsConfigurationsOperations - :ivar git_hub_owners: GitHubOwnersOperations operations - :vartype git_hub_owners: azure.mgmt.security.v2024_04_01.aio.operations.GitHubOwnersOperations - :ivar git_hub_repos: GitHubReposOperations operations - :vartype git_hub_repos: azure.mgmt.security.v2024_04_01.aio.operations.GitHubReposOperations - :ivar git_lab_groups: GitLabGroupsOperations operations - :vartype git_lab_groups: azure.mgmt.security.v2024_04_01.aio.operations.GitLabGroupsOperations - :ivar git_lab_subgroups: GitLabSubgroupsOperations operations - :vartype git_lab_subgroups: - azure.mgmt.security.v2024_04_01.aio.operations.GitLabSubgroupsOperations - :ivar git_lab_projects: GitLabProjectsOperations operations - :vartype git_lab_projects: - azure.mgmt.security.v2024_04_01.aio.operations.GitLabProjectsOperations - :ivar dev_ops_operation_results: DevOpsOperationResultsOperations operations - :vartype dev_ops_operation_results: - azure.mgmt.security.v2024_04_01.aio.operations.DevOpsOperationResultsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2024-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.azure_dev_ops_orgs = AzureDevOpsOrgsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.azure_dev_ops_projects = AzureDevOpsProjectsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.azure_dev_ops_repos = AzureDevOpsReposOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.dev_ops_configurations = DevOpsConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_hub_owners = GitHubOwnersOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_hub_repos = GitHubReposOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_lab_groups = GitLabGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_lab_subgroups = GitLabSubgroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.git_lab_projects = GitLabProjectsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - self.dev_ops_operation_results = DevOpsOperationResultsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-04-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "SecurityCenter": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/__init__.py deleted file mode 100644 index f7948e9fc6d4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/__init__.py +++ /dev/null @@ -1,37 +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 ._azure_dev_ops_orgs_operations import AzureDevOpsOrgsOperations -from ._azure_dev_ops_projects_operations import AzureDevOpsProjectsOperations -from ._azure_dev_ops_repos_operations import AzureDevOpsReposOperations -from ._dev_ops_configurations_operations import DevOpsConfigurationsOperations -from ._git_hub_owners_operations import GitHubOwnersOperations -from ._git_hub_repos_operations import GitHubReposOperations -from ._git_lab_groups_operations import GitLabGroupsOperations -from ._git_lab_subgroups_operations import GitLabSubgroupsOperations -from ._git_lab_projects_operations import GitLabProjectsOperations -from ._dev_ops_operation_results_operations import DevOpsOperationResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDevOpsOrgsOperations", - "AzureDevOpsProjectsOperations", - "AzureDevOpsReposOperations", - "DevOpsConfigurationsOperations", - "GitHubOwnersOperations", - "GitHubReposOperations", - "GitLabGroupsOperations", - "GitLabSubgroupsOperations", - "GitLabProjectsOperations", - "DevOpsOperationResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_azure_dev_ops_orgs_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_azure_dev_ops_orgs_operations.py deleted file mode 100644 index 1b3474a4bbac..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_azure_dev_ops_orgs_operations.py +++ /dev/null @@ -1,717 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._azure_dev_ops_orgs_operations import ( - build_create_or_update_request, - build_get_request, - build_list_available_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AzureDevOpsOrgsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`azure_dev_ops_orgs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.AzureDevOpsOrgListResponse: - """Returns a list of all Azure DevOps organizations accessible by the user token consumed by the - connector. - - Returns a list of all Azure DevOps organizations accessible by the user token consumed by the - connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: AzureDevOpsOrgListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrgListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureDevOpsOrg"]: - """Returns a list of Azure DevOps organizations onboarded to the connector. - - Returns a list of Azure DevOps organizations onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either AzureDevOpsOrg or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrgListResponse", 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, security_connector_name: str, org_name: str, **kwargs: Any - ) -> _models.AzureDevOpsOrg: - """Returns a monitored Azure DevOps organization resource. - - Returns a monitored Azure DevOps organization resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :return: AzureDevOpsOrg or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsOrg: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_org, (IOBase, bytes)): - _content = azure_dev_ops_org - else: - _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: _models.AzureDevOpsOrg, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg - :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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a - AzureDevOpsOrg type or a IO[bytes] type. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - azure_dev_ops_org=azure_dev_ops_org, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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.AzureDevOpsOrg].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsOrg]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsOrg: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_org, (IOBase, bytes)): - _content = azure_dev_ops_org - else: - _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: _models.AzureDevOpsOrg, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg - :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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a - AzureDevOpsOrg type or a IO[bytes] type. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsOrg or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - azure_dev_ops_org=azure_dev_ops_org, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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.AzureDevOpsOrg].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsOrg]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_azure_dev_ops_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_azure_dev_ops_projects_operations.py deleted file mode 100644 index 2542a51cbe32..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_azure_dev_ops_projects_operations.py +++ /dev/null @@ -1,685 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._azure_dev_ops_projects_operations import ( - build_create_or_update_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AzureDevOpsProjectsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`azure_dev_ops_projects` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, org_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureDevOpsProject"]: - """Returns a list of Azure DevOps projects onboarded to the connector. - - Returns a list of Azure DevOps projects onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :return: An iterator like instance of either AzureDevOpsProject or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsProjectListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProjectListResponse", 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, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any - ) -> _models.AzureDevOpsProject: - """Returns a monitored Azure DevOps project resource. - - Returns a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: AzureDevOpsProject or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsProject: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_project, (IOBase, bytes)): - _content = azure_dev_ops_project - else: - _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: _models.AzureDevOpsProject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject - :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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a - AzureDevOpsProject type or a IO[bytes] type. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - azure_dev_ops_project=azure_dev_ops_project, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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.AzureDevOpsProject].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsProject]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsProject: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_project, (IOBase, bytes)): - _content = azure_dev_ops_project - else: - _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: _models.AzureDevOpsProject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject - :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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a - AzureDevOpsProject type or a IO[bytes] type. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - azure_dev_ops_project=azure_dev_ops_project, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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.AzureDevOpsProject].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsProject]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_azure_dev_ops_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_azure_dev_ops_repos_operations.py deleted file mode 100644 index 32c562b161dd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_azure_dev_ops_repos_operations.py +++ /dev/null @@ -1,722 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._azure_dev_ops_repos_operations import ( - build_create_or_update_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AzureDevOpsReposOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`azure_dev_ops_repos` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureDevOpsRepository"]: - """Returns a list of Azure DevOps repositories onboarded to the connector. - - Returns a list of Azure DevOps repositories onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: An iterator like instance of either AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsRepositoryListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepositoryListResponse", 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, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - """Returns a monitored Azure DevOps repository resource. - - Returns a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :return: AzureDevOpsRepository or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_repository, (IOBase, bytes)): - _content = azure_dev_ops_repository - else: - _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: _models.AzureDevOpsRepository, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - :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 AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a - AzureDevOpsRepository type or a IO[bytes] type. Required. - :type azure_dev_ops_repository: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - azure_dev_ops_repository=azure_dev_ops_repository, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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.AzureDevOpsRepository].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsRepository]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_repository, (IOBase, bytes)): - _content = azure_dev_ops_repository - else: - _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: _models.AzureDevOpsRepository, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - :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 AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a - AzureDevOpsRepository type or a IO[bytes] type. Required. - :type azure_dev_ops_repository: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureDevOpsRepository or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - azure_dev_ops_repository=azure_dev_ops_repository, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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.AzureDevOpsRepository].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureDevOpsRepository]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_dev_ops_configurations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_dev_ops_configurations_operations.py deleted file mode 100644 index a06921b2134b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_dev_ops_configurations_operations.py +++ /dev/null @@ -1,731 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._dev_ops_configurations_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DevOpsConfigurationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`dev_ops_configurations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DevOpsConfiguration"]: - """List DevOps Configurations. - - List DevOps Configurations. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either DevOpsConfiguration or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.DevOpsConfigurationListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DevOpsConfigurationListResponse", 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, security_connector_name: str, **kwargs: Any - ) -> _models.DevOpsConfiguration: - """Gets a DevOps Configuration. - - Gets a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: DevOpsConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.DevOpsConfiguration: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(dev_ops_configuration, (IOBase, bytes)): - _content = dev_ops_configuration - else: - _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: _models.DevOpsConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration - :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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: 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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Is either a - DevOpsConfiguration type or a IO[bytes] type. Required. - :type dev_ops_configuration: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = 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, - security_connector_name=security_connector_name, - dev_ops_configuration=dev_ops_configuration, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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.DevOpsConfiguration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DevOpsConfiguration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.DevOpsConfiguration: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(dev_ops_configuration, (IOBase, bytes)): - _content = dev_ops_configuration - else: - _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: _models.DevOpsConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration - :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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: 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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Is either a - DevOpsConfiguration type or a IO[bytes] type. Required. - :type dev_ops_configuration: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = 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, - security_connector_name=security_connector_name, - dev_ops_configuration=dev_ops_configuration, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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.DevOpsConfiguration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DevOpsConfiguration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a DevOps Connector. - - Deletes a DevOps Connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_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._api_version or "2024-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_dev_ops_operation_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_dev_ops_operation_results_operations.py deleted file mode 100644 index c4939c8e4cef..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_dev_ops_operation_results_operations.py +++ /dev/null @@ -1,121 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._dev_ops_operation_results_operations import build_get_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DevOpsOperationResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`dev_ops_operation_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, resource_group_name: str, security_connector_name: str, operation_result_id: str, **kwargs: Any - ) -> _models.OperationStatusResult: - """Get devops long running operation result. - - Get devops long running operation result. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param operation_result_id: The operation result Id. Required. - :type operation_result_id: str - :return: OperationStatusResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.OperationStatusResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - operation_result_id=operation_result_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatusResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_hub_owners_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_hub_owners_operations.py deleted file mode 100644 index 6607bd5ef19b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_hub_owners_operations.py +++ /dev/null @@ -1,274 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_hub_owners_operations import build_get_request, build_list_available_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitHubOwnersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`git_hub_owners` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.GitHubOwnerListResponse: - """Returns a list of all GitHub owners accessible by the user token consumed by the connector. - - Returns a list of all GitHub owners accessible by the user token consumed by the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: GitHubOwnerListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitHubOwnerListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GitHubOwner"]: - """Returns a list of GitHub owners onboarded to the connector. - - Returns a list of GitHub owners onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either GitHubOwner or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2024_04_01.models.GitHubOwner] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GitHubOwnerListResponse", 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, security_connector_name: str, owner_name: str, **kwargs: Any - ) -> _models.GitHubOwner: - """Returns a monitored GitHub owner. - - Returns a monitored GitHub owner. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :return: GitHubOwner or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitHubOwner - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubOwner] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubOwner", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_hub_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_hub_repos_operations.py deleted file mode 100644 index 8be9b161275a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_hub_repos_operations.py +++ /dev/null @@ -1,219 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_hub_repos_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitHubReposOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`git_hub_repos` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, owner_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GitHubRepository"]: - """Returns a list of GitHub repositories onboarded to the connector. - - Returns a list of GitHub repositories onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :return: An iterator like instance of either GitHubRepository or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2024_04_01.models.GitHubRepository] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubRepositoryListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GitHubRepositoryListResponse", 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, security_connector_name: str, owner_name: str, repo_name: str, **kwargs: Any - ) -> _models.GitHubRepository: - """Returns a monitored GitHub repository. - - Returns a monitored GitHub repository. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :return: GitHubRepository or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitHubRepository - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubRepository] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_lab_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_lab_groups_operations.py deleted file mode 100644 index 19aab14fa698..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_lab_groups_operations.py +++ /dev/null @@ -1,274 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_lab_groups_operations import build_get_request, build_list_available_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitLabGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`git_lab_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.GitLabGroupListResponse: - """Returns a list of all GitLab groups accessible by the user token consumed by the connector. - - Returns a list of all GitLab groups accessible by the user token consumed by the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: GitLabGroupListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitLabGroupListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GitLabGroup"]: - """Returns a list of GitLab groups onboarded to the connector. - - Returns a list of GitLab groups onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either GitLabGroup or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2024_04_01.models.GitLabGroup] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GitLabGroupListResponse", 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, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> _models.GitLabGroup: - """Returns a monitored GitLab Group resource for a given fully-qualified name. - - Returns a monitored GitLab Group resource for a given fully-qualified name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: GitLabGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitLabGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_lab_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_lab_projects_operations.py deleted file mode 100644 index cd8dd73326b1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_lab_projects_operations.py +++ /dev/null @@ -1,228 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_lab_projects_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitLabProjectsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`git_lab_projects` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GitLabProject"]: - """Gets a list of GitLab projects that are directly owned by given group and onboarded to the - connector. - - Gets a list of GitLab projects that are directly owned by given group and onboarded to the - connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: An iterator like instance of either GitLabProject or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2024_04_01.models.GitLabProject] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabProjectListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GitLabProjectListResponse", 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, - security_connector_name: str, - group_fq_name: str, - project_name: str, - **kwargs: Any - ) -> _models.GitLabProject: - """Returns a monitored GitLab Project resource for a given fully-qualified group name and project - name. - - Returns a monitored GitLab Project resource for a given fully-qualified group name and project - name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: GitLabProject or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitLabProject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabProject] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_lab_subgroups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_lab_subgroups_operations.py deleted file mode 100644 index 2c8e0cc396e2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_git_lab_subgroups_operations.py +++ /dev/null @@ -1,121 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._git_lab_subgroups_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GitLabSubgroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.aio.SecurityCenter`'s - :attr:`git_lab_subgroups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list( - self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> _models.GitLabGroupListResponse: - """Gets nested subgroups of given GitLab Group which are onboarded to the connector. - - Gets nested subgroups of given GitLab Group which are onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: GitLabGroupListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitLabGroupListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/__init__.py deleted file mode 100644 index 6366199623d9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/__init__.py +++ /dev/null @@ -1,117 +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 ._models_py3 import ActionableRemediation -from ._models_py3 import Authorization -from ._models_py3 import AzureDevOpsOrg -from ._models_py3 import AzureDevOpsOrgListResponse -from ._models_py3 import AzureDevOpsOrgProperties -from ._models_py3 import AzureDevOpsOrganizationConfiguration -from ._models_py3 import AzureDevOpsProject -from ._models_py3 import AzureDevOpsProjectConfiguration -from ._models_py3 import AzureDevOpsProjectListResponse -from ._models_py3 import AzureDevOpsProjectProperties -from ._models_py3 import AzureDevOpsRepository -from ._models_py3 import AzureDevOpsRepositoryListResponse -from ._models_py3 import AzureDevOpsRepositoryProperties -from ._models_py3 import BaseResourceConfiguration -from ._models_py3 import CategoryConfiguration -from ._models_py3 import DevOpsCapability -from ._models_py3 import DevOpsConfiguration -from ._models_py3 import DevOpsConfigurationListResponse -from ._models_py3 import DevOpsConfigurationProperties -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import GitHubOwner -from ._models_py3 import GitHubOwnerConfiguration -from ._models_py3 import GitHubOwnerListResponse -from ._models_py3 import GitHubOwnerProperties -from ._models_py3 import GitHubRepository -from ._models_py3 import GitHubRepositoryListResponse -from ._models_py3 import GitHubRepositoryProperties -from ._models_py3 import GitLabGroup -from ._models_py3 import GitLabGroupConfiguration -from ._models_py3 import GitLabGroupListResponse -from ._models_py3 import GitLabGroupProperties -from ._models_py3 import GitLabProject -from ._models_py3 import GitLabProjectListResponse -from ._models_py3 import GitLabProjectProperties -from ._models_py3 import OperationStatusResult -from ._models_py3 import ProxyResource -from ._models_py3 import Resource -from ._models_py3 import SystemData -from ._models_py3 import TargetBranchConfiguration - -from ._security_center_enums import ActionableRemediationState -from ._security_center_enums import AnnotateDefaultBranchState -from ._security_center_enums import AutoDiscovery -from ._security_center_enums import CreatedByType -from ._security_center_enums import DesiredOnboardingState -from ._security_center_enums import DevOpsProvisioningState -from ._security_center_enums import InheritFromParentState -from ._security_center_enums import OnboardingState -from ._security_center_enums import RuleCategory -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionableRemediation", - "Authorization", - "AzureDevOpsOrg", - "AzureDevOpsOrgListResponse", - "AzureDevOpsOrgProperties", - "AzureDevOpsOrganizationConfiguration", - "AzureDevOpsProject", - "AzureDevOpsProjectConfiguration", - "AzureDevOpsProjectListResponse", - "AzureDevOpsProjectProperties", - "AzureDevOpsRepository", - "AzureDevOpsRepositoryListResponse", - "AzureDevOpsRepositoryProperties", - "BaseResourceConfiguration", - "CategoryConfiguration", - "DevOpsCapability", - "DevOpsConfiguration", - "DevOpsConfigurationListResponse", - "DevOpsConfigurationProperties", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "GitHubOwner", - "GitHubOwnerConfiguration", - "GitHubOwnerListResponse", - "GitHubOwnerProperties", - "GitHubRepository", - "GitHubRepositoryListResponse", - "GitHubRepositoryProperties", - "GitLabGroup", - "GitLabGroupConfiguration", - "GitLabGroupListResponse", - "GitLabGroupProperties", - "GitLabProject", - "GitLabProjectListResponse", - "GitLabProjectProperties", - "OperationStatusResult", - "ProxyResource", - "Resource", - "SystemData", - "TargetBranchConfiguration", - "ActionableRemediationState", - "AnnotateDefaultBranchState", - "AutoDiscovery", - "CreatedByType", - "DesiredOnboardingState", - "DevOpsProvisioningState", - "InheritFromParentState", - "OnboardingState", - "RuleCategory", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/_models_py3.py deleted file mode 100644 index f305b1c17cd8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/_models_py3.py +++ /dev/null @@ -1,2113 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionableRemediation(_serialization.Model): - """Configuration payload for PR Annotations. - - :ivar state: ActionableRemediation Setting. - None - the setting was never set. - Enabled - ActionableRemediation is enabled. - Disabled - ActionableRemediation is disabled. Known values are: "None", "Disabled", and - "Enabled". - :vartype state: str or ~azure.mgmt.security.v2024_04_01.models.ActionableRemediationState - :ivar category_configurations: Gets or sets list of categories and severity levels. - :vartype category_configurations: - list[~azure.mgmt.security.v2024_04_01.models.CategoryConfiguration] - :ivar branch_configuration: Repository branch configuration for PR Annotations. - :vartype branch_configuration: - ~azure.mgmt.security.v2024_04_01.models.TargetBranchConfiguration - :ivar inherit_from_parent_state: Update Settings. - - Enabled - Resource should inherit configurations from parent. - Disabled - Resource should not inherit configurations from parent. Known values are: - "Disabled" and "Enabled". - :vartype inherit_from_parent_state: str or - ~azure.mgmt.security.v2024_04_01.models.InheritFromParentState - """ - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "category_configurations": {"key": "categoryConfigurations", "type": "[CategoryConfiguration]"}, - "branch_configuration": {"key": "branchConfiguration", "type": "TargetBranchConfiguration"}, - "inherit_from_parent_state": {"key": "inheritFromParentState", "type": "str"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.ActionableRemediationState"]] = None, - category_configurations: Optional[List["_models.CategoryConfiguration"]] = None, - branch_configuration: Optional["_models.TargetBranchConfiguration"] = None, - inherit_from_parent_state: Optional[Union[str, "_models.InheritFromParentState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: ActionableRemediation Setting. - None - the setting was never set. - Enabled - ActionableRemediation is enabled. - Disabled - ActionableRemediation is disabled. Known values are: "None", "Disabled", and - "Enabled". - :paramtype state: str or ~azure.mgmt.security.v2024_04_01.models.ActionableRemediationState - :keyword category_configurations: Gets or sets list of categories and severity levels. - :paramtype category_configurations: - list[~azure.mgmt.security.v2024_04_01.models.CategoryConfiguration] - :keyword branch_configuration: Repository branch configuration for PR Annotations. - :paramtype branch_configuration: - ~azure.mgmt.security.v2024_04_01.models.TargetBranchConfiguration - :keyword inherit_from_parent_state: Update Settings. - - Enabled - Resource should inherit configurations from parent. - Disabled - Resource should not inherit configurations from parent. Known values are: - "Disabled" and "Enabled". - :paramtype inherit_from_parent_state: str or - ~azure.mgmt.security.v2024_04_01.models.InheritFromParentState - """ - super().__init__(**kwargs) - self.state = state - self.category_configurations = category_configurations - self.branch_configuration = branch_configuration - self.inherit_from_parent_state = inherit_from_parent_state - - -class Authorization(_serialization.Model): - """Authorization payload. - - :ivar code: Gets or sets one-time OAuth code to exchange for refresh and access tokens. - - Only used during PUT/PATCH operations. The secret is cleared during GET. - :vartype code: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Gets or sets one-time OAuth code to exchange for refresh and access tokens. - - Only used during PUT/PATCH operations. The secret is cleared during GET. - :paramtype code: str - """ - super().__init__(**kwargs) - self.code = code - - -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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - -class AzureDevOpsOrg(ProxyResource): - """Azure DevOps Organization 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2024_04_01.models.SystemData - :ivar properties: Azure DevOps Organization properties. - :vartype properties: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrgProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "AzureDevOpsOrgProperties"}, - } - - def __init__(self, *, properties: Optional["_models.AzureDevOpsOrgProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Azure DevOps Organization properties. - :paramtype properties: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrgProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class AzureDevOpsOrganizationConfiguration(_serialization.Model): - """AzureDevOps Org Inventory Configuration. - - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :ivar project_configs: AzureDevOps Project Inventory Configuration. - Dictionary of AzureDevOps project name to desired project configuration. - If AutoDiscovery is Enabled, this field should be empty or null. - :vartype project_configs: dict[str, - ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProjectConfiguration] - """ - - _attribute_map = { - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "project_configs": {"key": "projectConfigs", "type": "{AzureDevOpsProjectConfiguration}"}, - } - - def __init__( - self, - *, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - project_configs: Optional[Dict[str, "_models.AzureDevOpsProjectConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :keyword project_configs: AzureDevOps Project Inventory Configuration. - Dictionary of AzureDevOps project name to desired project configuration. - If AutoDiscovery is Enabled, this field should be empty or null. - :paramtype project_configs: dict[str, - ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProjectConfiguration] - """ - super().__init__(**kwargs) - self.auto_discovery = auto_discovery - self.project_configs = project_configs - - -class AzureDevOpsOrgListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AzureDevOpsOrg]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.AzureDevOpsOrg"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AzureDevOpsOrgProperties(_serialization.Model): - """Azure DevOps Organization properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - :ivar actionable_remediation: Configuration payload for PR Annotations. - :vartype actionable_remediation: ~azure.mgmt.security.v2024_04_01.models.ActionableRemediation - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - actionable_remediation: Optional["_models.ActionableRemediation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - :keyword actionable_remediation: Configuration payload for PR Annotations. - :paramtype actionable_remediation: - ~azure.mgmt.security.v2024_04_01.models.ActionableRemediation - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.onboarding_state = onboarding_state - self.actionable_remediation = actionable_remediation - - -class AzureDevOpsProject(ProxyResource): - """Azure DevOps Project 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2024_04_01.models.SystemData - :ivar properties: Azure DevOps Project properties. - :vartype properties: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProjectProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "AzureDevOpsProjectProperties"}, - } - - def __init__(self, *, properties: Optional["_models.AzureDevOpsProjectProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Azure DevOps Project properties. - :paramtype properties: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProjectProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class AzureDevOpsProjectConfiguration(_serialization.Model): - """AzureDevOps Project Inventory Configuration. - - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :ivar repository_configs: AzureDevOps Repository Inventory Configuration. - Dictionary of AzureDevOps repository name to desired repository configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :vartype repository_configs: dict[str, - ~azure.mgmt.security.v2024_04_01.models.BaseResourceConfiguration] - """ - - _attribute_map = { - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "repository_configs": {"key": "repositoryConfigs", "type": "{BaseResourceConfiguration}"}, - } - - def __init__( - self, - *, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - repository_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :keyword repository_configs: AzureDevOps Repository Inventory Configuration. - Dictionary of AzureDevOps repository name to desired repository configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :paramtype repository_configs: dict[str, - ~azure.mgmt.security.v2024_04_01.models.BaseResourceConfiguration] - """ - super().__init__(**kwargs) - self.auto_discovery = auto_discovery - self.repository_configs = repository_configs - - -class AzureDevOpsProjectListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AzureDevOpsProject]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AzureDevOpsProject"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AzureDevOpsProjectProperties(_serialization.Model): - """Azure DevOps Project properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :ivar parent_org_name: Gets or sets parent Azure DevOps Organization name. - :vartype parent_org_name: str - :ivar project_id: Gets or sets Azure DevOps Project id. - :vartype project_id: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - :ivar actionable_remediation: Configuration payload for PR Annotations. - :vartype actionable_remediation: ~azure.mgmt.security.v2024_04_01.models.ActionableRemediation - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "project_id": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "parent_org_name": {"key": "parentOrgName", "type": "str"}, - "project_id": {"key": "projectId", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - parent_org_name: Optional[str] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - actionable_remediation: Optional["_models.ActionableRemediation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :keyword parent_org_name: Gets or sets parent Azure DevOps Organization name. - :paramtype parent_org_name: str - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - :keyword actionable_remediation: Configuration payload for PR Annotations. - :paramtype actionable_remediation: - ~azure.mgmt.security.v2024_04_01.models.ActionableRemediation - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.parent_org_name = parent_org_name - self.project_id = None - self.onboarding_state = onboarding_state - self.actionable_remediation = actionable_remediation - - -class AzureDevOpsRepository(ProxyResource): - """Azure DevOps Repository 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2024_04_01.models.SystemData - :ivar properties: Azure DevOps Repository properties. - :vartype properties: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepositoryProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "AzureDevOpsRepositoryProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.AzureDevOpsRepositoryProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Azure DevOps Repository properties. - :paramtype properties: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepositoryProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class AzureDevOpsRepositoryListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AzureDevOpsRepository]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AzureDevOpsRepository"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AzureDevOpsRepositoryProperties(_serialization.Model): - """Azure DevOps Repository properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :ivar parent_org_name: Gets or sets parent Azure DevOps Organization name. - :vartype parent_org_name: str - :ivar parent_project_name: Gets or sets parent Azure DevOps Project name. - :vartype parent_project_name: str - :ivar repo_id: Gets or sets Azure DevOps Repository id. - :vartype repo_id: str - :ivar repo_url: Gets or sets Azure DevOps Repository url. - :vartype repo_url: str - :ivar visibility: Gets or sets Azure DevOps repository visibility, whether it is public or - private etc. - :vartype visibility: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - :ivar actionable_remediation: Configuration payload for PR Annotations. - :vartype actionable_remediation: ~azure.mgmt.security.v2024_04_01.models.ActionableRemediation - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "repo_id": {"readonly": True}, - "repo_url": {"readonly": True}, - "visibility": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "parent_org_name": {"key": "parentOrgName", "type": "str"}, - "parent_project_name": {"key": "parentProjectName", "type": "str"}, - "repo_id": {"key": "repoId", "type": "str"}, - "repo_url": {"key": "repoUrl", "type": "str"}, - "visibility": {"key": "visibility", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - parent_org_name: Optional[str] = None, - parent_project_name: Optional[str] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - actionable_remediation: Optional["_models.ActionableRemediation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :keyword parent_org_name: Gets or sets parent Azure DevOps Organization name. - :paramtype parent_org_name: str - :keyword parent_project_name: Gets or sets parent Azure DevOps Project name. - :paramtype parent_project_name: str - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - :keyword actionable_remediation: Configuration payload for PR Annotations. - :paramtype actionable_remediation: - ~azure.mgmt.security.v2024_04_01.models.ActionableRemediation - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.parent_org_name = parent_org_name - self.parent_project_name = parent_project_name - self.repo_id = None - self.repo_url = None - self.visibility = None - self.onboarding_state = onboarding_state - self.actionable_remediation = actionable_remediation - - -class BaseResourceConfiguration(_serialization.Model): - """Base Resource Inventory configuration changes. - - :ivar desired_onboarding_state: Onboarding states. Known values are: "Disabled" and "Enabled". - :vartype desired_onboarding_state: str or - ~azure.mgmt.security.v2024_04_01.models.DesiredOnboardingState - """ - - _attribute_map = { - "desired_onboarding_state": {"key": "desiredOnboardingState", "type": "str"}, - } - - def __init__( - self, *, desired_onboarding_state: Optional[Union[str, "_models.DesiredOnboardingState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword desired_onboarding_state: Onboarding states. Known values are: "Disabled" and - "Enabled". - :paramtype desired_onboarding_state: str or - ~azure.mgmt.security.v2024_04_01.models.DesiredOnboardingState - """ - super().__init__(**kwargs) - self.desired_onboarding_state = desired_onboarding_state - - -class CategoryConfiguration(_serialization.Model): - """Severity level per category configuration for PR Annotations. - - :ivar minimum_severity_level: Gets or sets minimum severity level for a given category. - :vartype minimum_severity_level: str - :ivar category: Rule categories. - Code - code scanning results. - Artifact scanning results. - Dependencies scanning results. - IaC results. - Secrets scanning results. - Container scanning results. Known values are: "Code", "Artifacts", "Dependencies", "Secrets", - "IaC", and "Containers". - :vartype category: str or ~azure.mgmt.security.v2024_04_01.models.RuleCategory - """ - - _attribute_map = { - "minimum_severity_level": {"key": "minimumSeverityLevel", "type": "str"}, - "category": {"key": "category", "type": "str"}, - } - - def __init__( - self, - *, - minimum_severity_level: Optional[str] = None, - category: Optional[Union[str, "_models.RuleCategory"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword minimum_severity_level: Gets or sets minimum severity level for a given category. - :paramtype minimum_severity_level: str - :keyword category: Rule categories. - Code - code scanning results. - Artifact scanning results. - Dependencies scanning results. - IaC results. - Secrets scanning results. - Container scanning results. Known values are: "Code", "Artifacts", "Dependencies", "Secrets", - "IaC", and "Containers". - :paramtype category: str or ~azure.mgmt.security.v2024_04_01.models.RuleCategory - """ - super().__init__(**kwargs) - self.minimum_severity_level = minimum_severity_level - self.category = category - - -class DevOpsCapability(_serialization.Model): - """Details about DevOps capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Gets the name of the DevOps capability. - :vartype name: str - :ivar value: Gets the value of the DevOps capability. - :vartype value: str - """ - - _validation = { - "name": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name = None - self.value = None - - -class DevOpsConfiguration(ProxyResource): - """DevOps Configuration 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2024_04_01.models.SystemData - :ivar properties: DevOps Configuration properties. - :vartype properties: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfigurationProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "DevOpsConfigurationProperties"}, - } - - def __init__(self, *, properties: Optional["_models.DevOpsConfigurationProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: DevOps Configuration properties. - :paramtype properties: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfigurationProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class DevOpsConfigurationListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DevOpsConfiguration]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.DevOpsConfiguration"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DevOpsConfigurationProperties(_serialization.Model): - """DevOps Configuration properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :ivar authorization: Authorization payload. - :vartype authorization: ~azure.mgmt.security.v2024_04_01.models.Authorization - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :ivar top_level_inventory_list: List of top-level inventory to select when AutoDiscovery is - disabled. - This field is ignored when AutoDiscovery is enabled. - :vartype top_level_inventory_list: list[str] - :ivar capabilities: List of capabilities assigned to the DevOps configuration during the - discovery process. - :vartype capabilities: list[~azure.mgmt.security.v2024_04_01.models.DevOpsCapability] - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "capabilities": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "authorization": {"key": "authorization", "type": "Authorization"}, - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "top_level_inventory_list": {"key": "topLevelInventoryList", "type": "[str]"}, - "capabilities": {"key": "capabilities", "type": "[DevOpsCapability]"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - authorization: Optional["_models.Authorization"] = None, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - top_level_inventory_list: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :keyword authorization: Authorization payload. - :paramtype authorization: ~azure.mgmt.security.v2024_04_01.models.Authorization - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :keyword top_level_inventory_list: List of top-level inventory to select when AutoDiscovery is - disabled. - This field is ignored when AutoDiscovery is enabled. - :paramtype top_level_inventory_list: list[str] - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.authorization = authorization - self.auto_discovery = auto_discovery - self.top_level_inventory_list = top_level_inventory_list - self.capabilities = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.security.v2024_04_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.security.v2024_04_01.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.security.v2024_04_01.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.security.v2024_04_01.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class GitHubOwner(ProxyResource): - """GitHub Owner 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2024_04_01.models.SystemData - :ivar properties: GitHub Owner properties. - :vartype properties: ~azure.mgmt.security.v2024_04_01.models.GitHubOwnerProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "GitHubOwnerProperties"}, - } - - def __init__(self, *, properties: Optional["_models.GitHubOwnerProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: GitHub Owner properties. - :paramtype properties: ~azure.mgmt.security.v2024_04_01.models.GitHubOwnerProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class GitHubOwnerConfiguration(_serialization.Model): - """GitHub Owner Inventory Configuration. - - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :ivar repository_configs: GitHub Repository Inventory Configuration. - Dictionary of GitHub repository name to desired repository configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :vartype repository_configs: dict[str, - ~azure.mgmt.security.v2024_04_01.models.BaseResourceConfiguration] - """ - - _attribute_map = { - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "repository_configs": {"key": "repositoryConfigs", "type": "{BaseResourceConfiguration}"}, - } - - def __init__( - self, - *, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - repository_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :keyword repository_configs: GitHub Repository Inventory Configuration. - Dictionary of GitHub repository name to desired repository configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :paramtype repository_configs: dict[str, - ~azure.mgmt.security.v2024_04_01.models.BaseResourceConfiguration] - """ - super().__init__(**kwargs) - self.auto_discovery = auto_discovery - self.repository_configs = repository_configs - - -class GitHubOwnerListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2024_04_01.models.GitHubOwner] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GitHubOwner]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.GitHubOwner"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2024_04_01.models.GitHubOwner] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GitHubOwnerProperties(_serialization.Model): - """GitHub Owner properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :ivar owner_url: Gets or sets GitHub Owner url. - :vartype owner_url: str - :ivar git_hub_internal_id: Gets or sets internal GitHub id. - :vartype git_hub_internal_id: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "owner_url": {"readonly": True}, - "git_hub_internal_id": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "owner_url": {"key": "ownerUrl", "type": "str"}, - "git_hub_internal_id": {"key": "gitHubInternalId", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.owner_url = None - self.git_hub_internal_id = None - self.onboarding_state = onboarding_state - - -class GitHubRepository(ProxyResource): - """GitHub Repository 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2024_04_01.models.SystemData - :ivar properties: GitHub Repository properties. - :vartype properties: ~azure.mgmt.security.v2024_04_01.models.GitHubRepositoryProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "GitHubRepositoryProperties"}, - } - - def __init__(self, *, properties: Optional["_models.GitHubRepositoryProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: GitHub Repository properties. - :paramtype properties: ~azure.mgmt.security.v2024_04_01.models.GitHubRepositoryProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class GitHubRepositoryListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2024_04_01.models.GitHubRepository] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GitHubRepository]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.GitHubRepository"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2024_04_01.models.GitHubRepository] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GitHubRepositoryProperties(_serialization.Model): - """GitHub Repository properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :ivar repo_id: Gets or sets GitHub Repository id. - - This is a numeric id defined by Github. - Eg: "123456". - :vartype repo_id: str - :ivar repo_name: Gets or sets GitHub Repository name. - Eg: "new-repo-1". - :vartype repo_name: str - :ivar repo_full_name: Gets or sets GitHub Full Name. - Repository name, prefixed with Owner name. - Eg: "my-org/new-repo-1". - :vartype repo_full_name: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - :ivar repo_url: Gets or sets GitHub Repository url. - :vartype repo_url: str - :ivar parent_owner_name: Gets or sets parent GitHub Owner name. - :vartype parent_owner_name: str - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "repo_id": {"readonly": True}, - "repo_name": {"readonly": True}, - "repo_full_name": {"readonly": True}, - "repo_url": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "repo_id": {"key": "repoId", "type": "str"}, - "repo_name": {"key": "repoName", "type": "str"}, - "repo_full_name": {"key": "repoFullName", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - "repo_url": {"key": "repoUrl", "type": "str"}, - "parent_owner_name": {"key": "parentOwnerName", "type": "str"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - parent_owner_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - :keyword parent_owner_name: Gets or sets parent GitHub Owner name. - :paramtype parent_owner_name: str - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.repo_id = None - self.repo_name = None - self.repo_full_name = None - self.onboarding_state = onboarding_state - self.repo_url = None - self.parent_owner_name = parent_owner_name - - -class GitLabGroup(ProxyResource): - """GitLab Group 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2024_04_01.models.SystemData - :ivar properties: GitLab Group properties. - :vartype properties: ~azure.mgmt.security.v2024_04_01.models.GitLabGroupProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "GitLabGroupProperties"}, - } - - def __init__(self, *, properties: Optional["_models.GitLabGroupProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: GitLab Group properties. - :paramtype properties: ~azure.mgmt.security.v2024_04_01.models.GitLabGroupProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class GitLabGroupConfiguration(_serialization.Model): - """GitLab Group Inventory Configuration. - - :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :vartype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :ivar project_configs: GitLab Project Inventory Configuration. - Dictionary of GitLab fully-qualified project name to desired project configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :vartype project_configs: dict[str, - ~azure.mgmt.security.v2024_04_01.models.BaseResourceConfiguration] - """ - - _attribute_map = { - "auto_discovery": {"key": "autoDiscovery", "type": "str"}, - "project_configs": {"key": "projectConfigs", "type": "{BaseResourceConfiguration}"}, - } - - def __init__( - self, - *, - auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, - project_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and - "NotApplicable". - :paramtype auto_discovery: str or ~azure.mgmt.security.v2024_04_01.models.AutoDiscovery - :keyword project_configs: GitLab Project Inventory Configuration. - Dictionary of GitLab fully-qualified project name to desired project configuration. - If AutoDiscovery is Enabled, this field should be null or empty. - :paramtype project_configs: dict[str, - ~azure.mgmt.security.v2024_04_01.models.BaseResourceConfiguration] - """ - super().__init__(**kwargs) - self.auto_discovery = auto_discovery - self.project_configs = project_configs - - -class GitLabGroupListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2024_04_01.models.GitLabGroup] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GitLabGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.GitLabGroup"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2024_04_01.models.GitLabGroup] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GitLabGroupProperties(_serialization.Model): - """GitLab Group properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :ivar fully_qualified_name: Gets or sets the fully-qualified name of the Group object. - - This contains the entire namespace hierarchy where namespaces are separated by the '$' - character. - :vartype fully_qualified_name: str - :ivar fully_qualified_friendly_name: Gets or sets the human readable fully-qualified name of - the Group object. - - This contains the entire namespace hierarchy as seen on GitLab UI where namespaces are - separated by the '/' character. - :vartype fully_qualified_friendly_name: str - :ivar url: Gets or sets the url of the GitLab Group. - :vartype url: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "fully_qualified_name": {"readonly": True}, - "fully_qualified_friendly_name": {"readonly": True}, - "url": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "fully_qualified_name": {"key": "fullyQualifiedName", "type": "str"}, - "fully_qualified_friendly_name": {"key": "fullyQualifiedFriendlyName", "type": "str"}, - "url": {"key": "url", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.fully_qualified_name = None - self.fully_qualified_friendly_name = None - self.url = None - self.onboarding_state = onboarding_state - - -class GitLabProject(ProxyResource): - """GitLab Project 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. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.security.v2024_04_01.models.SystemData - :ivar properties: GitLab Project properties. - :vartype properties: ~azure.mgmt.security.v2024_04_01.models.GitLabProjectProperties - """ - - _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"}, - "properties": {"key": "properties", "type": "GitLabProjectProperties"}, - } - - def __init__(self, *, properties: Optional["_models.GitLabProjectProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: GitLab Project properties. - :paramtype properties: ~azure.mgmt.security.v2024_04_01.models.GitLabProjectProperties - """ - super().__init__(**kwargs) - self.system_data = None - self.properties = properties - - -class GitLabProjectListResponse(_serialization.Model): - """List of RP resources which supports pagination. - - :ivar value: Gets or sets list of resources. - :vartype value: list[~azure.mgmt.security.v2024_04_01.models.GitLabProject] - :ivar next_link: Gets or sets next link to scroll over the results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GitLabProject]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.GitLabProject"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets list of resources. - :paramtype value: list[~azure.mgmt.security.v2024_04_01.models.GitLabProject] - :keyword next_link: Gets or sets next link to scroll over the results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GitLabProjectProperties(_serialization.Model): - """GitLab Project properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_status_message: Gets or sets resource status message. - :vartype provisioning_status_message: str - :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. - :vartype provisioning_status_update_time_utc: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :vartype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :ivar fully_qualified_name: Gets or sets the fully-qualified name of the project object. - - This contains the entire hierarchy where entities are separated by the '$' character. - :vartype fully_qualified_name: str - :ivar fully_qualified_friendly_name: Gets or sets the human readable fully-qualified name of - the Project object. - - This contains the entire namespace hierarchy as seen on GitLab UI where entities are separated - by the '/' character. - :vartype fully_qualified_friendly_name: str - :ivar fully_qualified_parent_group_name: Gets or sets the fully-qualified name of the project's - parent group object. - - This contains the entire hierarchy where namespaces are separated by the '$' character. - :vartype fully_qualified_parent_group_name: str - :ivar url: Gets or sets the url of the GitLab Project. - :vartype url: str - :ivar onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :vartype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - """ - - _validation = { - "provisioning_status_message": {"readonly": True}, - "provisioning_status_update_time_utc": {"readonly": True}, - "fully_qualified_name": {"readonly": True}, - "fully_qualified_friendly_name": {"readonly": True}, - "fully_qualified_parent_group_name": {"readonly": True}, - "url": {"readonly": True}, - } - - _attribute_map = { - "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, - "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "fully_qualified_name": {"key": "fullyQualifiedName", "type": "str"}, - "fully_qualified_friendly_name": {"key": "fullyQualifiedFriendlyName", "type": "str"}, - "fully_qualified_parent_group_name": {"key": "fullyQualifiedParentGroupName", "type": "str"}, - "url": {"key": "url", "type": "str"}, - "onboarding_state": {"key": "onboardingState", "type": "str"}, - } - - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, - onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword provisioning_state: The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", - "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". - :paramtype provisioning_state: str or - ~azure.mgmt.security.v2024_04_01.models.DevOpsProvisioningState - :keyword onboarding_state: Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. - This is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. Known values - are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". - :paramtype onboarding_state: str or ~azure.mgmt.security.v2024_04_01.models.OnboardingState - """ - super().__init__(**kwargs) - self.provisioning_status_message = None - self.provisioning_status_update_time_utc = None - self.provisioning_state = provisioning_state - self.fully_qualified_name = None - self.fully_qualified_friendly_name = None - self.fully_qualified_parent_group_name = None - self.url = None - self.onboarding_state = onboarding_state - - -class OperationStatusResult(_serialization.Model): - """The current status of an async operation. - - 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 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.security.v2024_04_01.models.OperationStatusResult] - :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.security.v2024_04_01.models.ErrorDetail - """ - - _validation = { - "status": {"required": True}, - "percent_complete": {"maximum": 100, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "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.security.v2024_04_01.models.OperationStatusResult] - :keyword error: If present, details of the operation error. - :paramtype error: ~azure.mgmt.security.v2024_04_01.models.ErrorDetail - """ - super().__init__(**kwargs) - self.id = id - 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 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.security.v2024_04_01.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.security.v2024_04_01.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.security.v2024_04_01.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.security.v2024_04_01.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 TargetBranchConfiguration(_serialization.Model): - """Repository branch configuration for PR Annotations. - - :ivar branch_names: Gets or sets branches that should have annotations. - :vartype branch_names: list[str] - :ivar annotate_default_branch: Configuration of PR Annotations on default branch. - - Enabled - PR Annotations are enabled on the resource's default branch. - Disabled - PR Annotations are disabled on the resource's default branch. Known values are: - "Disabled" and "Enabled". - :vartype annotate_default_branch: str or - ~azure.mgmt.security.v2024_04_01.models.AnnotateDefaultBranchState - """ - - _attribute_map = { - "branch_names": {"key": "branchNames", "type": "[str]"}, - "annotate_default_branch": {"key": "annotateDefaultBranch", "type": "str"}, - } - - def __init__( - self, - *, - branch_names: Optional[List[str]] = None, - annotate_default_branch: Optional[Union[str, "_models.AnnotateDefaultBranchState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword branch_names: Gets or sets branches that should have annotations. - :paramtype branch_names: list[str] - :keyword annotate_default_branch: Configuration of PR Annotations on default branch. - - Enabled - PR Annotations are enabled on the resource's default branch. - Disabled - PR Annotations are disabled on the resource's default branch. Known values are: - "Disabled" and "Enabled". - :paramtype annotate_default_branch: str or - ~azure.mgmt.security.v2024_04_01.models.AnnotateDefaultBranchState - """ - super().__init__(**kwargs) - self.branch_names = branch_names - self.annotate_default_branch = annotate_default_branch diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/_security_center_enums.py deleted file mode 100644 index 3744941c0212..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/models/_security_center_enums.py +++ /dev/null @@ -1,123 +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 ActionableRemediationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ActionableRemediation Setting. - None - the setting was never set. - Enabled - ActionableRemediation is enabled. - Disabled - ActionableRemediation is disabled. - """ - - NONE = "None" - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class AnnotateDefaultBranchState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Configuration of PR Annotations on default branch. - - Enabled - PR Annotations are enabled on the resource's default branch. - Disabled - PR Annotations are disabled on the resource's default branch. - """ - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class AutoDiscovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AutoDiscovery states.""" - - DISABLED = "Disabled" - ENABLED = "Enabled" - NOT_APPLICABLE = "NotApplicable" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class DesiredOnboardingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Onboarding states.""" - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class DevOpsProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state of the resource. - - Pending - Provisioning pending. - Failed - Provisioning failed. - Succeeded - Successful provisioning. - Canceled - Provisioning canceled. - PendingDeletion - Deletion pending. - DeletionSuccess - Deletion successful. - DeletionFailure - Deletion failure. - """ - - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - PENDING = "Pending" - PENDING_DELETION = "PendingDeletion" - DELETION_SUCCESS = "DeletionSuccess" - DELETION_FAILURE = "DeletionFailure" - - -class InheritFromParentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Update Settings. - - Enabled - Resource should inherit configurations from parent. - Disabled - Resource should not inherit configurations from parent. - """ - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class OnboardingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Details about resource onboarding status across all connectors. - - OnboardedByOtherConnector - this resource has already been onboarded to another connector. This - is only applicable to top-level resources. - Onboarded - this resource has already been onboarded by the specified connector. - NotOnboarded - this resource has not been onboarded to any connector. - NotApplicable - the onboarding state is not applicable to the current endpoint. - """ - - NOT_APPLICABLE = "NotApplicable" - ONBOARDED_BY_OTHER_CONNECTOR = "OnboardedByOtherConnector" - ONBOARDED = "Onboarded" - NOT_ONBOARDED = "NotOnboarded" - - -class RuleCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule categories. - Code - code scanning results. - Artifact scanning results. - Dependencies scanning results. - IaC results. - Secrets scanning results. - Container scanning results. - """ - - CODE = "Code" - ARTIFACTS = "Artifacts" - DEPENDENCIES = "Dependencies" - SECRETS = "Secrets" - IA_C = "IaC" - CONTAINERS = "Containers" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/__init__.py deleted file mode 100644 index f7948e9fc6d4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/__init__.py +++ /dev/null @@ -1,37 +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 ._azure_dev_ops_orgs_operations import AzureDevOpsOrgsOperations -from ._azure_dev_ops_projects_operations import AzureDevOpsProjectsOperations -from ._azure_dev_ops_repos_operations import AzureDevOpsReposOperations -from ._dev_ops_configurations_operations import DevOpsConfigurationsOperations -from ._git_hub_owners_operations import GitHubOwnersOperations -from ._git_hub_repos_operations import GitHubReposOperations -from ._git_lab_groups_operations import GitLabGroupsOperations -from ._git_lab_subgroups_operations import GitLabSubgroupsOperations -from ._git_lab_projects_operations import GitLabProjectsOperations -from ._dev_ops_operation_results_operations import DevOpsOperationResultsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDevOpsOrgsOperations", - "AzureDevOpsProjectsOperations", - "AzureDevOpsReposOperations", - "DevOpsConfigurationsOperations", - "GitHubOwnersOperations", - "GitHubReposOperations", - "GitLabGroupsOperations", - "GitLabSubgroupsOperations", - "GitLabProjectsOperations", - "DevOpsOperationResultsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_azure_dev_ops_orgs_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_azure_dev_ops_orgs_operations.py deleted file mode 100644 index 911a2ce7f409..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_azure_dev_ops_orgs_operations.py +++ /dev/null @@ -1,878 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_available_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableAzureDevOpsOrgs", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( - resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_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) - - -class AzureDevOpsOrgsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`azure_dev_ops_orgs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.AzureDevOpsOrgListResponse: - """Returns a list of all Azure DevOps organizations accessible by the user token consumed by the - connector. - - Returns a list of all Azure DevOps organizations accessible by the user token consumed by the - connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: AzureDevOpsOrgListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrgListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> Iterable["_models.AzureDevOpsOrg"]: - """Returns a list of Azure DevOps organizations onboarded to the connector. - - Returns a list of Azure DevOps organizations onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either AzureDevOpsOrg or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrgListResponse", 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, security_connector_name: str, org_name: str, **kwargs: Any - ) -> _models.AzureDevOpsOrg: - """Returns a monitored Azure DevOps organization resource. - - Returns a monitored Azure DevOps organization resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :return: AzureDevOpsOrg or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsOrg: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_org, (IOBase, bytes)): - _content = azure_dev_ops_org - else: - _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: _models.AzureDevOpsOrg, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg - :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 AzureDevOpsOrg or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Creates or updates monitored Azure DevOps organization details. - - Creates or updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a - AzureDevOpsOrg type or a IO[bytes] type. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg or IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsOrg or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - azure_dev_ops_org=azure_dev_ops_org, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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.AzureDevOpsOrg].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsOrg]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsOrg: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_org, (IOBase, bytes)): - _content = azure_dev_ops_org - else: - _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: _models.AzureDevOpsOrg, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg - :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 AzureDevOpsOrg or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. - :type azure_dev_ops_org: 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 AzureDevOpsOrg or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsOrg]: - """Updates monitored Azure DevOps organization details. - - Updates monitored Azure DevOps organization details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a - AzureDevOpsOrg type or a IO[bytes] type. Required. - :type azure_dev_ops_org: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg or IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsOrg or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsOrg] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsOrg] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - azure_dev_ops_org=azure_dev_ops_org, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsOrg", pipeline_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.AzureDevOpsOrg].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsOrg]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_azure_dev_ops_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_azure_dev_ops_projects_operations.py deleted file mode 100644 index 61564504ae63..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_azure_dev_ops_projects_operations.py +++ /dev/null @@ -1,840 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_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_get_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_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) - - -class AzureDevOpsProjectsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`azure_dev_ops_projects` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, org_name: str, **kwargs: Any - ) -> Iterable["_models.AzureDevOpsProject"]: - """Returns a list of Azure DevOps projects onboarded to the connector. - - Returns a list of Azure DevOps projects onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :return: An iterator like instance of either AzureDevOpsProject or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsProjectListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProjectListResponse", 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, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any - ) -> _models.AzureDevOpsProject: - """Returns a monitored Azure DevOps project resource. - - Returns a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: AzureDevOpsProject or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsProject: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_project, (IOBase, bytes)): - _content = azure_dev_ops_project - else: - _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: _models.AzureDevOpsProject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject - :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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Creates or updates a monitored Azure DevOps project resource. - - Creates or updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a - AzureDevOpsProject type or a IO[bytes] type. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject or - IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - azure_dev_ops_project=azure_dev_ops_project, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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.AzureDevOpsProject].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsProject]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsProject: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_project, (IOBase, bytes)): - _content = azure_dev_ops_project - else: - _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: _models.AzureDevOpsProject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject - :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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. - :type azure_dev_ops_project: 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 AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsProject]: - """Updates a monitored Azure DevOps project resource. - - Updates a monitored Azure DevOps project resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a - AzureDevOpsProject type or a IO[bytes] type. Required. - :type azure_dev_ops_project: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject or - IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsProject or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsProject] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsProject] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - azure_dev_ops_project=azure_dev_ops_project, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsProject", pipeline_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.AzureDevOpsProject].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsProject]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_azure_dev_ops_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_azure_dev_ops_repos_operations.py deleted file mode 100644 index c6f066ecae4a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_azure_dev_ops_repos_operations.py +++ /dev/null @@ -1,889 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_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_get_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "orgName": _SERIALIZER.url("org_name", org_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "repoName": _SERIALIZER.url("repo_name", repo_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) - - -class AzureDevOpsReposOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`azure_dev_ops_repos` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any - ) -> Iterable["_models.AzureDevOpsRepository"]: - """Returns a list of Azure DevOps repositories onboarded to the connector. - - Returns a list of Azure DevOps repositories onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: An iterator like instance of either AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsRepositoryListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepositoryListResponse", 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, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - """Returns a monitored Azure DevOps repository resource. - - Returns a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :return: AzureDevOpsRepository or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_repository, (IOBase, bytes)): - _content = azure_dev_ops_repository - else: - _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: _models.AzureDevOpsRepository, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - :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 AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Creates or updates a monitored Azure DevOps repository resource. - - Creates or updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a - AzureDevOpsRepository type or a IO[bytes] type. Required. - :type azure_dev_ops_repository: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - or IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - azure_dev_ops_repository=azure_dev_ops_repository, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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.AzureDevOpsRepository].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsRepository]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> _models.AzureDevOpsRepository: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_dev_ops_repository, (IOBase, bytes)): - _content = azure_dev_ops_repository - else: - _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: _models.AzureDevOpsRepository, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - :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 AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. - :type azure_dev_ops_repository: 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 AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - org_name: str, - project_name: str, - repo_name: str, - azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureDevOpsRepository]: - """Updates a monitored Azure DevOps repository resource. - - Updates a monitored Azure DevOps repository resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param org_name: The Azure DevOps organization name. Required. - :type org_name: str - :param project_name: The project name. Required. - :type project_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a - AzureDevOpsRepository type or a IO[bytes] type. Required. - :type azure_dev_ops_repository: ~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository - or IO[bytes] - :return: An instance of LROPoller that returns either AzureDevOpsRepository or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.AzureDevOpsRepository] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureDevOpsRepository] = 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, - security_connector_name=security_connector_name, - org_name=org_name, - project_name=project_name, - repo_name=repo_name, - azure_dev_ops_repository=azure_dev_ops_repository, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AzureDevOpsRepository", pipeline_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.AzureDevOpsRepository].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureDevOpsRepository]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_dev_ops_configurations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_dev_ops_configurations_operations.py deleted file mode 100644 index 91c14227c528..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_dev_ops_configurations_operations.py +++ /dev/null @@ -1,892 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DevOpsConfigurationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`dev_ops_configurations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> Iterable["_models.DevOpsConfiguration"]: - """List DevOps Configurations. - - List DevOps Configurations. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either DevOpsConfiguration or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.DevOpsConfigurationListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DevOpsConfigurationListResponse", 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, security_connector_name: str, **kwargs: Any) -> _models.DevOpsConfiguration: - """Gets a DevOps Configuration. - - Gets a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: DevOpsConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.DevOpsConfiguration: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(dev_ops_configuration, (IOBase, bytes)): - _content = dev_ops_configuration - else: - _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: _models.DevOpsConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration - :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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: 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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Creates or updates a DevOps Configuration. - - Creates or updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Is either a - DevOpsConfiguration type or a IO[bytes] type. Required. - :type dev_ops_configuration: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration or - IO[bytes] - :return: An instance of LROPoller that returns either DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = 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, - security_connector_name=security_connector_name, - dev_ops_configuration=dev_ops_configuration, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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.DevOpsConfiguration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DevOpsConfiguration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.DevOpsConfiguration: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(dev_ops_configuration, (IOBase, bytes)): - _content = dev_ops_configuration - else: - _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") - - _request = build_update_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: _models.DevOpsConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration - :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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Required. - :type dev_ops_configuration: 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 DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - security_connector_name: str, - dev_ops_configuration: Union[_models.DevOpsConfiguration, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DevOpsConfiguration]: - """Updates a DevOps Configuration. - - Updates a DevOps Configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param dev_ops_configuration: The DevOps configuration resource payload. Is either a - DevOpsConfiguration type or a IO[bytes] type. Required. - :type dev_ops_configuration: ~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration or - IO[bytes] - :return: An instance of LROPoller that returns either DevOpsConfiguration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.security.v2024_04_01.models.DevOpsConfiguration] - :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._api_version or "2024-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevOpsConfiguration] = 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, - security_connector_name=security_connector_name, - dev_ops_configuration=dev_ops_configuration, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DevOpsConfiguration", pipeline_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.DevOpsConfiguration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DevOpsConfiguration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a DevOps Connector. - - Deletes a DevOps Connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_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._api_version or "2024-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_dev_ops_operation_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_dev_ops_operation_results_operations.py deleted file mode 100644 index b775b0429442..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_dev_ops_operation_results_operations.py +++ /dev/null @@ -1,162 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - security_connector_name: str, - operation_result_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", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/operationResults/{operationResultId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "operationResultId": _SERIALIZER.url("operation_result_id", operation_result_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) - - -class DevOpsOperationResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`dev_ops_operation_results` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, resource_group_name: str, security_connector_name: str, operation_result_id: str, **kwargs: Any - ) -> _models.OperationStatusResult: - """Get devops long running operation result. - - Get devops long running operation result. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param operation_result_id: The operation result Id. Required. - :type operation_result_id: str - :return: OperationStatusResult or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.OperationStatusResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - operation_result_id=operation_result_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatusResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_hub_owners_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_hub_owners_operations.py deleted file mode 100644 index 90ed953a23a3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_hub_owners_operations.py +++ /dev/null @@ -1,375 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_available_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitHubOwners", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( - resource_group_name: str, security_connector_name: str, owner_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "ownerName": _SERIALIZER.url("owner_name", owner_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) - - -class GitHubOwnersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`git_hub_owners` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.GitHubOwnerListResponse: - """Returns a list of all GitHub owners accessible by the user token consumed by the connector. - - Returns a list of all GitHub owners accessible by the user token consumed by the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: GitHubOwnerListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitHubOwnerListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> Iterable["_models.GitHubOwner"]: - """Returns a list of GitHub owners onboarded to the connector. - - Returns a list of GitHub owners onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either GitHubOwner or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2024_04_01.models.GitHubOwner] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GitHubOwnerListResponse", 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, security_connector_name: str, owner_name: str, **kwargs: Any - ) -> _models.GitHubOwner: - """Returns a monitored GitHub owner. - - Returns a monitored GitHub owner. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :return: GitHubOwner or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitHubOwner - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubOwner] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubOwner", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_hub_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_hub_repos_operations.py deleted file mode 100644 index 0b36941eb900..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_hub_repos_operations.py +++ /dev/null @@ -1,294 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, owner_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "ownerName": _SERIALIZER.url("owner_name", owner_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_get_request( - resource_group_name: str, - security_connector_name: str, - owner_name: str, - repo_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos/{repoName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "ownerName": _SERIALIZER.url("owner_name", owner_name, "str"), - "repoName": _SERIALIZER.url("repo_name", repo_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) - - -class GitHubReposOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`git_hub_repos` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, owner_name: str, **kwargs: Any - ) -> Iterable["_models.GitHubRepository"]: - """Returns a list of GitHub repositories onboarded to the connector. - - Returns a list of GitHub repositories onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :return: An iterator like instance of either GitHubRepository or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2024_04_01.models.GitHubRepository] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubRepositoryListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GitHubRepositoryListResponse", 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, security_connector_name: str, owner_name: str, repo_name: str, **kwargs: Any - ) -> _models.GitHubRepository: - """Returns a monitored GitHub repository. - - Returns a monitored GitHub repository. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param owner_name: The GitHub owner name. Required. - :type owner_name: str - :param repo_name: The repository name. Required. - :type repo_name: str - :return: GitHubRepository or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitHubRepository - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitHubRepository] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - owner_name=owner_name, - repo_name=repo_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitHubRepository", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_lab_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_lab_groups_operations.py deleted file mode 100644 index 0fb6cc95a8d7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_lab_groups_operations.py +++ /dev/null @@ -1,375 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_available_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitLabGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_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_get_request( - resource_group_name: str, security_connector_name: str, group_fq_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_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) - - -class GitLabGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`git_lab_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_available( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> _models.GitLabGroupListResponse: - """Returns a list of all GitLab groups accessible by the user token consumed by the connector. - - Returns a list of all GitLab groups accessible by the user token consumed by the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: GitLabGroupListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitLabGroupListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - _request = build_list_available_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, **kwargs: Any - ) -> Iterable["_models.GitLabGroup"]: - """Returns a list of GitLab groups onboarded to the connector. - - Returns a list of GitLab groups onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :return: An iterator like instance of either GitLabGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2024_04_01.models.GitLabGroup] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GitLabGroupListResponse", 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, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> _models.GitLabGroup: - """Returns a monitored GitLab Group resource for a given fully-qualified name. - - Returns a monitored GitLab Group resource for a given fully-qualified name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: GitLabGroup or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitLabGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_lab_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_lab_projects_operations.py deleted file mode 100644 index 2061edd31a4e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_lab_projects_operations.py +++ /dev/null @@ -1,303 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, group_fq_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_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_get_request( - resource_group_name: str, - security_connector_name: str, - group_fq_name: str, - project_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects/{projectName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_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) - - -class GitLabProjectsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`git_lab_projects` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> Iterable["_models.GitLabProject"]: - """Gets a list of GitLab projects that are directly owned by given group and onboarded to the - connector. - - Gets a list of GitLab projects that are directly owned by given group and onboarded to the - connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: An iterator like instance of either GitLabProject or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2024_04_01.models.GitLabProject] - :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._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabProjectListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GitLabProjectListResponse", 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, - security_connector_name: str, - group_fq_name: str, - project_name: str, - **kwargs: Any - ) -> _models.GitLabProject: - """Returns a monitored GitLab Project resource for a given fully-qualified group name and project - name. - - Returns a monitored GitLab Project resource for a given fully-qualified group name and project - name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :param project_name: The project name. Required. - :type project_name: str - :return: GitLabProject or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitLabProject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabProject] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabProject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_lab_subgroups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_lab_subgroups_operations.py deleted file mode 100644 index e0bcc2717d60..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_git_lab_subgroups_operations.py +++ /dev/null @@ -1,158 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, security_connector_name: str, group_fq_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/listSubgroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), - "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class GitLabSubgroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.security.v2024_04_01.SecurityCenter`'s - :attr:`git_lab_subgroups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any - ) -> _models.GitLabGroupListResponse: - """Gets nested subgroups of given GitLab Group which are onboarded to the connector. - - Gets nested subgroups of given GitLab Group which are onboarded to the connector. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param security_connector_name: The security connector name. Required. - :type security_connector_name: str - :param group_fq_name: The GitLab group fully-qualified name. Required. - :type group_fq_name: str - :return: GitLabGroupListResponse or the result of cls(response) - :rtype: ~azure.mgmt.security.v2024_04_01.models.GitLabGroupListResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-04-01")) - cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) - - _request = build_list_request( - resource_group_name=resource_group_name, - security_connector_name=security_connector_name, - group_fq_name=group_fq_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""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 - - -def patch_sdk(): - """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/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2024_04_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/dev_requirements.txt b/sdk/security/azure-mgmt-security/dev_requirements.txt index 7d496b4d1cc1..a4eaf63f2d63 100644 --- a/sdk/security/azure-mgmt-security/dev_requirements.txt +++ b/sdk/security/azure-mgmt-security/dev_requirements.txt @@ -1 +1,2 @@ -e ../../../eng/tools/azure-sdk-tools +aiohttp diff --git a/sdk/security/azure-mgmt-security/generated_samples/advanced_threat_protection/get_advanced_threat_protection_settings_example.py b/sdk/security/azure-mgmt-security/generated_samples/advanced_threat_protection/get_advanced_threat_protection_settings_example.py new file mode 100644 index 000000000000..003c89c17eb6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/advanced_threat_protection/get_advanced_threat_protection_settings_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_advanced_threat_protection_settings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.advanced_threat_protection.get( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-01-01/examples/AdvancedThreatProtection/GetAdvancedThreatProtectionSettings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/advanced_threat_protection/put_advanced_threat_protection_settings_example.py b/sdk/security/azure-mgmt-security/generated_samples/advanced_threat_protection/put_advanced_threat_protection_settings_example.py new file mode 100644 index 000000000000..93c392145486 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/advanced_threat_protection/put_advanced_threat_protection_settings_example.py @@ -0,0 +1,48 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_advanced_threat_protection_settings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.advanced_threat_protection.create( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount", + advanced_threat_protection_setting={ + "id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount/providers/Microsoft.Security/advancedThreatProtectionSettings/current", + "name": "current", + "properties": {"isEnabled": True}, + "type": "Microsoft.Security/advancedThreatProtectionSettings", + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-01-01/examples/AdvancedThreatProtection/PutAdvancedThreatProtectionSettings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alert_resource_group_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alert_resource_group_location_example.py new file mode 100644 index 000000000000..97de2b684b75 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alert_resource_group_location_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_alert_resource_group_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts.get_resource_group_level( + resource_group_name="myRg1", + asc_location="westeurope", + alert_name="2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertResourceGroupLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alert_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alert_subscription_location_example.py new file mode 100644 index 000000000000..68056996dbf6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alert_subscription_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_alert_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts.get_subscription_level( + asc_location="westeurope", + alert_name="2518770965529163669_F144EE95-A3E5-42DA-A279-967D115809AA", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertSubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_resource_group_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_resource_group_example.py new file mode 100644 index 000000000000..db0b407b1235 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_resource_group_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_alerts_resource_group_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts.list_by_resource_group( + resource_group_name="myRg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsResourceGroup_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_resource_group_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_resource_group_location_example.py new file mode 100644 index 000000000000..28eab71cfb87 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_resource_group_location_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_alerts_resource_group_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts.list_resource_group_level_by_region( + asc_location="westeurope", + resource_group_name="myRg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsResourceGroupLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_subscription_example.py new file mode 100644 index 000000000000..f6c7e95188c0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_alerts_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_subscriptions_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_subscriptions_location_example.py new file mode 100644 index 000000000000..9de67872b208 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/get_alerts_subscriptions_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_alerts_subscriptions_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts.list_subscription_level_by_region( + asc_location="westeurope", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsSubscriptionsLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/simulate_alerts_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/simulate_alerts_example.py new file mode 100644 index 000000000000..275aff37e64b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/simulate_alerts_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python simulate_alerts_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts.begin_simulate( + asc_location="centralus", + alert_simulator_request_body={ + "properties": { + "bundles": [ + "AppServices", + "DNS", + "KeyVaults", + "KubernetesService", + "ResourceManager", + "SqlServers", + "StorageAccounts", + "VirtualMachines", + "CosmosDbs", + ], + "kind": "Bundles", + } + }, + ).result() + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/SimulateAlerts_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_activate_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_activate_example.py new file mode 100644 index 000000000000..8a6ce18b3b03 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_activate_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_alert_resource_group_location_activate_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts.update_resource_group_level_state_to_activate( + resource_group_name="myRg2", + asc_location="westeurope", + alert_name="2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertResourceGroupLocation_activate_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_dismiss_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_dismiss_example.py new file mode 100644 index 000000000000..8dbccd8754c8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_dismiss_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_alert_resource_group_location_dismiss_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts.update_resource_group_level_state_to_dismiss( + resource_group_name="myRg2", + asc_location="westeurope", + alert_name="2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertResourceGroupLocation_dismiss_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_in_progress_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_in_progress_example.py new file mode 100644 index 000000000000..475fd53cd86f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_in_progress_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_alert_resource_group_location_in_progress_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts.update_resource_group_level_state_to_in_progress( + resource_group_name="myRg2", + asc_location="westeurope", + alert_name="2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertResourceGroupLocation_inProgress_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_resolve_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_resolve_example.py new file mode 100644 index 000000000000..b16d2d84712e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_resource_group_location_resolve_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_alert_resource_group_location_resolve_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts.update_resource_group_level_state_to_resolve( + resource_group_name="myRg2", + asc_location="westeurope", + alert_name="2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertResourceGroupLocation_resolve_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_activate_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_activate_example.py new file mode 100644 index 000000000000..e8040896ca41 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_activate_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_alert_subscription_location_activate_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts.update_subscription_level_state_to_activate( + asc_location="westeurope", + alert_name="2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertSubscriptionLocation_activate_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_dismiss_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_dismiss_example.py new file mode 100644 index 000000000000..8caeee5a6b1c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_dismiss_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_alert_subscription_location_dismiss_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts.update_subscription_level_state_to_dismiss( + asc_location="westeurope", + alert_name="2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertSubscriptionLocation_dismiss_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_in_progress_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_in_progress_example.py new file mode 100644 index 000000000000..c6e73773d81b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_in_progress_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_alert_subscription_location_in_progress_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts.update_subscription_level_state_to_in_progress( + asc_location="westeurope", + alert_name="2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertSubscriptionLocation_inProgress_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_resolve_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_resolve_example.py new file mode 100644 index 000000000000..e0d8baf8f84c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts/update_alert_subscription_location_resolve_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_alert_subscription_location_resolve_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts.update_subscription_level_state_to_resolve( + asc_location="westeurope", + alert_name="2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertSubscriptionLocation_resolve_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/delete_alerts_suppression_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/delete_alerts_suppression_rule_example.py new file mode 100644 index 000000000000..2bb6a5ffd83d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/delete_alerts_suppression_rule_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_alerts_suppression_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.alerts_suppression_rules.delete( + alerts_suppression_rule_name="dismissIpAnomalyAlerts", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/DeleteAlertsSuppressionRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/get_alerts_suppression_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/get_alerts_suppression_rule_example.py new file mode 100644 index 000000000000..3e024983b194 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/get_alerts_suppression_rule_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_alerts_suppression_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts_suppression_rules.get( + alerts_suppression_rule_name="dismissIpAnomalyAlerts", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/get_alerts_suppression_rules_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/get_alerts_suppression_rules_example.py new file mode 100644 index 000000000000..ddae06063ab2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/get_alerts_suppression_rules_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_alerts_suppression_rules_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts_suppression_rules.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRules_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/get_alerts_suppression_rules_with_alert_type_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/get_alerts_suppression_rules_with_alert_type_example.py new file mode 100644 index 000000000000..e9c69e61297c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/get_alerts_suppression_rules_with_alert_type_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_alerts_suppression_rules_with_alert_type_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts_suppression_rules.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRulesWithAlertType_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/put_alerts_suppression_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/put_alerts_suppression_rule_example.py new file mode 100644 index 000000000000..1d5468522e57 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/alerts_suppression_rules/put_alerts_suppression_rule_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_alerts_suppression_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.alerts_suppression_rules.update( + alerts_suppression_rule_name="dismissIpAnomalyAlerts", + alerts_suppression_rule={ + "properties": { + "alertType": "IpAnomaly", + "comment": "Test VM", + "expirationDateUtc": "2019-12-01T19:50:47.083633Z", + "reason": "FalsePositive", + "state": "Enabled", + "suppressionAlertsScope": { + "allOf": [ + {"field": "entities.ip.address", "in": ["104.215.95.187", "52.164.206.56"]}, + {"contains": "POWERSHELL.EXE", "field": "entities.process.commandline"}, + ] + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/PutAlertsSuppressionRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/allowed_connections/get_allowed_connections_example.py b/sdk/security/azure-mgmt-security/generated_samples/allowed_connections/get_allowed_connections_example.py new file mode 100644 index 000000000000..bd394da631c0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/allowed_connections/get_allowed_connections_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_allowed_connections_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3eeab341-f466-499c-a8be-85427e154bad", + ) + + response = client.allowed_connections.get( + resource_group_name="myResourceGroup", + asc_location="centralus", + connection_type="Internal", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AllowedConnections/GetAllowedConnections_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/allowed_connections/get_allowed_connections_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/allowed_connections/get_allowed_connections_subscription_example.py new file mode 100644 index 000000000000..9d4f5d680080 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/allowed_connections/get_allowed_connections_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_allowed_connections_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3eeab341-f466-499c-a8be-85427e154bad", + ) + + response = client.allowed_connections.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AllowedConnections/GetAllowedConnectionsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/allowed_connections/get_allowed_connections_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/allowed_connections/get_allowed_connections_subscription_location_example.py new file mode 100644 index 000000000000..112b9c144687 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/allowed_connections/get_allowed_connections_subscription_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_allowed_connections_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3eeab341-f466-499c-a8be-85427e154bad", + ) + + response = client.allowed_connections.list_by_home_region( + asc_location="centralus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AllowedConnections/GetAllowedConnectionsSubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_get_by_azure_api_management_service_example.py b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_get_by_azure_api_management_service_example.py new file mode 100644 index 000000000000..5360a927abed --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_get_by_azure_api_management_service_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python api_collections_get_by_azure_api_management_service_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3fa85f64-5717-4562-b3fc-2c963f66afa6", + ) + + response = client.api_collections.get_by_azure_api_management_service( + resource_group_name="rg1", + service_name="apimService1", + api_id="echo-api", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_GetByAzureApiManagementService_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_list_by_azure_api_management_service_example.py b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_list_by_azure_api_management_service_example.py new file mode 100644 index 000000000000..bdc268084538 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_list_by_azure_api_management_service_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python api_collections_list_by_azure_api_management_service_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3fa85f64-5717-4562-b3fc-2c963f66afa6", + ) + + response = client.api_collections.list_by_azure_api_management_service( + resource_group_name="rg1", + service_name="apimService1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListByAzureApiManagementService_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_list_by_resource_group_example.py b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_list_by_resource_group_example.py new file mode 100644 index 000000000000..ab021bce0b8c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_list_by_resource_group_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python api_collections_list_by_resource_group_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3fa85f64-5717-4562-b3fc-2c963f66afa6", + ) + + response = client.api_collections.list_by_resource_group( + resource_group_name="rg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListByResourceGroup_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_list_by_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_list_by_subscription_example.py new file mode 100644 index 000000000000..0c99c1a91486 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_list_by_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python api_collections_list_by_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3fa85f64-5717-4562-b3fc-2c963f66afa6", + ) + + response = client.api_collections.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListBySubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_offboard_azure_api_management_api_example.py b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_offboard_azure_api_management_api_example.py new file mode 100644 index 000000000000..c14168b33da0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_offboard_azure_api_management_api_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python api_collections_offboard_azure_api_management_api_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3fa85f64-5717-4562-b3fc-2c963f66afa6", + ) + + client.api_collections.offboard_azure_api_management_api( + resource_group_name="rg1", + service_name="apimService1", + api_id="echo-api", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_OffboardAzureApiManagementApi_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_onboard_azure_api_management_api_example.py b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_onboard_azure_api_management_api_example.py new file mode 100644 index 000000000000..bbc436a0f937 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/api_collections/api_collections_onboard_azure_api_management_api_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python api_collections_onboard_azure_api_management_api_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3fa85f64-5717-4562-b3fc-2c963f66afa6", + ) + + response = client.api_collections.begin_onboard_azure_api_management_api( + resource_group_name="rg1", + service_name="apimService1", + api_id="echo-api", + ).result() + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_OnboardAzureApiManagementApi_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/applications/delete_application_example.py b/sdk/security/azure-mgmt-security/generated_samples/applications/delete_application_example.py new file mode 100644 index 000000000000..0e697d283f67 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/applications/delete_application_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_application_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.application.delete( + application_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/DeleteApplication_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/applications/delete_security_connector_application_example.py b/sdk/security/azure-mgmt-security/generated_samples/applications/delete_security_connector_application_example.py new file mode 100644 index 000000000000..d82410f67824 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/applications/delete_security_connector_application_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_security_connector_application_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.security_connector_application.delete( + resource_group_name="gcpResourceGroup", + security_connector_name="gcpconnector", + application_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/DeleteSecurityConnectorApplication_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/applications/get_application_example.py b/sdk/security/azure-mgmt-security/generated_samples/applications/get_application_example.py new file mode 100644 index 000000000000..6d2e0a3b17f6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/applications/get_application_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_application_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.application.get( + application_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetApplication_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/applications/get_security_connector_application_example.py b/sdk/security/azure-mgmt-security/generated_samples/applications/get_security_connector_application_example.py new file mode 100644 index 000000000000..6d6ca3c2d717 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/applications/get_security_connector_application_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_connector_application_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_connector_application.get( + resource_group_name="gcpResourceGroup", + security_connector_name="gcpconnector", + application_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetSecurityConnectorApplication_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/applications/list_by_security_connector_applications_example.py b/sdk/security/azure-mgmt-security/generated_samples/applications/list_by_security_connector_applications_example.py new file mode 100644 index 000000000000..c66c126c08e1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/applications/list_by_security_connector_applications_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_security_connector_applications_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_connector_applications.list( + resource_group_name="gcpResourceGroup", + security_connector_name="gcpconnector", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/ListBySecurityConnectorApplications_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/applications/list_by_subscription_applications_example.py b/sdk/security/azure-mgmt-security/generated_samples/applications/list_by_subscription_applications_example.py new file mode 100644 index 000000000000..8b6a016caca3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/applications/list_by_subscription_applications_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_subscription_applications_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.applications.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/ListBySubscriptionApplications_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/applications/put_application_example.py b/sdk/security/azure-mgmt-security/generated_samples/applications/put_application_example.py new file mode 100644 index 000000000000..35b03a10ff41 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/applications/put_application_example.py @@ -0,0 +1,50 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_application_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.application.create_or_update( + application_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + application={ + "properties": { + "conditionSets": [{"conditions": [{"operator": "contains", "property": "$.Id", "value": "-bil-"}]}], + "description": "An application on critical recommendations", + "displayName": "Admin's application", + "sourceResourceType": "Assessments", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutApplication_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/applications/put_security_connector_application_example.py b/sdk/security/azure-mgmt-security/generated_samples/applications/put_security_connector_application_example.py new file mode 100644 index 000000000000..3e09c8e9bffe --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/applications/put_security_connector_application_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_security_connector_application_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_connector_application.create_or_update( + resource_group_name="gcpResourceGroup", + security_connector_name="gcpconnector", + application_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + application={ + "properties": { + "conditionSets": [{"conditions": [{"operator": "contains", "property": "$.Id", "value": "-prod-"}]}], + "description": "An application on critical GCP recommendations", + "displayName": "GCP Admin's application", + "sourceResourceType": "Assessments", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutSecurityConnectorApplication_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments/delete_assessment_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments/delete_assessment_example.py new file mode 100644 index 000000000000..f0ddda8305cf --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments/delete_assessment_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_assessment_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.assessments.delete( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2", + assessment_name="8bb8be0a-6010-4789-812f-e4d661c4ed0e", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/Assessments/DeleteAssessment_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments/get_assessment_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments/get_assessment_example.py new file mode 100644 index 000000000000..d2498c7ab82e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments/get_assessment_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_assessment_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.assessments.get( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2", + assessment_name="21300918-b2e3-0346-785f-c77ff57d243b", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/Assessments/GetAssessment_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments/get_assessment_with_expand_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments/get_assessment_with_expand_example.py new file mode 100644 index 000000000000..3d5e83a46fc9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments/get_assessment_with_expand_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_assessment_with_expand_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.assessments.get( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2", + assessment_name="21300918-b2e3-0346-785f-c77ff57d243b", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/Assessments/GetAssessmentWithExpand_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments/list_assessments_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments/list_assessments_example.py new file mode 100644 index 000000000000..255b82f3ec06 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments/list_assessments_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_assessments_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.assessments.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/Assessments/ListAssessments_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments/put_assessment_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments/put_assessment_example.py new file mode 100644 index 000000000000..d32e8415423a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments/put_assessment_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_assessment_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.assessments.create_or_update( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2", + assessment_name="8bb8be0a-6010-4789-812f-e4d661c4ed0e", + assessment={"properties": {"resourceDetails": {"source": "Azure"}, "status": {"code": "Healthy"}}}, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/Assessments/PutAssessment_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/create_assessments_metadata_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/create_assessments_metadata_subscription_example.py new file mode 100644 index 000000000000..e8f7eaa566cc --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/create_assessments_metadata_subscription_example.py @@ -0,0 +1,53 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_assessments_metadata_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="0980887d-03d6-408c-9566-532f3456804e", + ) + + response = client.assessments_metadata.create_in_subscription( + assessment_metadata_name="ca039e75-a276-4175-aebc-bcd41e4b14b7", + assessment_metadata={ + "properties": { + "assessmentType": "CustomerManaged", + "categories": ["Compute"], + "description": "Install an endpoint protection solution on your virtual machines scale sets, to protect them from threats and vulnerabilities.", + "displayName": "Install endpoint protection solution on virtual machine scale sets", + "remediationDescription": 'To install an endpoint protection solution: 1. Follow the instructions in How do I turn on antimalware in my virtual machine scale set', + "severity": "Medium", + "threats": ["dataExfiltration", "dataSpillage", "maliciousInsider"], + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/AssessmentsMetadata/CreateAssessmentsMetadata_subscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/delete_assessments_metadata_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/delete_assessments_metadata_subscription_example.py new file mode 100644 index 000000000000..01729b228a34 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/delete_assessments_metadata_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_assessments_metadata_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="0980887d-03d6-408c-9566-532f3456804e", + ) + + client.assessments_metadata.delete_in_subscription( + assessment_metadata_name="ca039e75-a276-4175-aebc-bcd41e4b14b7", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/AssessmentsMetadata/DeleteAssessmentsMetadata_subscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/get_assessments_metadata_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/get_assessments_metadata_example.py new file mode 100644 index 000000000000..6a035ed4a1dc --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/get_assessments_metadata_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_assessments_metadata_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.assessments_metadata.get( + assessment_metadata_name="21300918-b2e3-0346-785f-c77ff57d243b", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/AssessmentsMetadata/GetAssessmentsMetadata_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/get_assessments_metadata_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/get_assessments_metadata_subscription_example.py new file mode 100644 index 000000000000..e600de51039a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/get_assessments_metadata_subscription_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_assessments_metadata_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="0980887d-03d6-408c-9566-532f3456804e", + ) + + response = client.assessments_metadata.get_in_subscription( + assessment_metadata_name="21300918-b2e3-0346-785f-c77ff57d243b", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/AssessmentsMetadata/GetAssessmentsMetadata_subscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/list_assessments_metadata_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/list_assessments_metadata_example.py new file mode 100644 index 000000000000..ccb85cac38df --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/list_assessments_metadata_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_assessments_metadata_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.assessments_metadata.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/AssessmentsMetadata/ListAssessmentsMetadata_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/list_assessments_metadata_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/list_assessments_metadata_subscription_example.py new file mode 100644 index 000000000000..13611b354b16 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/assessments_metadata/list_assessments_metadata_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_assessments_metadata_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="0980887d-03d6-408c-9566-532f3456804e", + ) + + response = client.assessments_metadata.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/AssessmentsMetadata/ListAssessmentsMetadata_subscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/auto_provisioning_settings/create_auto_provisioning_settings_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/auto_provisioning_settings/create_auto_provisioning_settings_subscription_example.py new file mode 100644 index 000000000000..eb02f473421a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/auto_provisioning_settings/create_auto_provisioning_settings_subscription_example.py @@ -0,0 +1,48 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_auto_provisioning_settings_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.auto_provisioning_settings.create( + setting_name="default", + setting={ + "id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/autoProvisioningSettings/default", + "name": "default", + "properties": {"autoProvision": "On"}, + "type": "Microsoft.Security/autoProvisioningSettings", + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/CreateAutoProvisioningSettingsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/auto_provisioning_settings/get_auto_provisioning_setting_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/auto_provisioning_settings/get_auto_provisioning_setting_subscription_example.py new file mode 100644 index 000000000000..e7b74fd40ebf --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/auto_provisioning_settings/get_auto_provisioning_setting_subscription_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_auto_provisioning_setting_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.auto_provisioning_settings.get( + setting_name="default", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/GetAutoProvisioningSettingSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/auto_provisioning_settings/get_auto_provisioning_settings_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/auto_provisioning_settings/get_auto_provisioning_settings_subscription_example.py new file mode 100644 index 000000000000..819c5145af97 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/auto_provisioning_settings/get_auto_provisioning_settings_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_auto_provisioning_settings_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.auto_provisioning_settings.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/GetAutoProvisioningSettingsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/automations/delete_automation_example.py b/sdk/security/azure-mgmt-security/generated_samples/automations/delete_automation_example.py new file mode 100644 index 000000000000..99afea229368 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/automations/delete_automation_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_automation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.automations.delete( + resource_group_name="myRg", + automation_name="myAutomationName", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-12-01-preview/examples/Automations/DeleteAutomation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/automations/get_automation_resource_group_example.py b/sdk/security/azure-mgmt-security/generated_samples/automations/get_automation_resource_group_example.py new file mode 100644 index 000000000000..e6d8b02a5fa9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/automations/get_automation_resource_group_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_automation_resource_group_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="a5caac9c-5c04-49af-b3d0-e204f40345d5", + ) + + response = client.automations.get( + resource_group_name="exampleResourceGroup", + automation_name="exampleAutomation", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-12-01-preview/examples/Automations/GetAutomationResourceGroup_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/automations/get_automations_resource_group_example.py b/sdk/security/azure-mgmt-security/generated_samples/automations/get_automations_resource_group_example.py new file mode 100644 index 000000000000..b09581e9b1f7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/automations/get_automations_resource_group_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_automations_resource_group_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="a5caac9c-5c04-49af-b3d0-e204f40345d5", + ) + + response = client.automations.list_by_resource_group( + resource_group_name="exampleResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-12-01-preview/examples/Automations/GetAutomationsResourceGroup_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/automations/get_automations_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/automations/get_automations_subscription_example.py new file mode 100644 index 000000000000..3a7afaac41a5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/automations/get_automations_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_automations_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="a5caac9c-5c04-49af-b3d0-e204f40345d5", + ) + + response = client.automations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-12-01-preview/examples/Automations/GetAutomationsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/compliance_results/get_compliance_results_example.py b/sdk/security/azure-mgmt-security/generated_samples/compliance_results/get_compliance_results_example.py new file mode 100644 index 000000000000..8f250bc08bea --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/compliance_results/get_compliance_results_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_compliance_results_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.compliance_results.get( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + compliance_result_name="DesignateMoreThanOneOwner", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2017-08-01/examples/ComplianceResults/GetComplianceResults_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/compliance_results/list_compliance_results_example.py b/sdk/security/azure-mgmt-security/generated_samples/compliance_results/list_compliance_results_example.py new file mode 100644 index 000000000000..65ec5fbf567e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/compliance_results/list_compliance_results_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_compliance_results_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.compliance_results.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2017-08-01/examples/ComplianceResults/ListComplianceResults_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/compliances/get_compliance_example.py b/sdk/security/azure-mgmt-security/generated_samples/compliances/get_compliance_example.py new file mode 100644 index 000000000000..06c6d565e1fd --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/compliances/get_compliance_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_compliance_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.compliances.get( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + compliance_name="2018-01-01Z", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/Compliances/GetCompliance_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/compliances/get_compliances_example.py b/sdk/security/azure-mgmt-security/generated_samples/compliances/get_compliances_example.py new file mode 100644 index 000000000000..1b4916a41c9d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/compliances/get_compliances_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_compliances_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.compliances.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/Compliances/GetCompliances_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/connectors/create_update_aws_assume_role_connector_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/connectors/create_update_aws_assume_role_connector_subscription_example.py new file mode 100644 index 000000000000..be3ade7c0b49 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/connectors/create_update_aws_assume_role_connector_subscription_example.py @@ -0,0 +1,58 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_update_aws_assume_role_connector_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.connectors.create_or_update( + connector_name="aws_dev2", + connector_setting={ + "properties": { + "authenticationDetails": { + "authenticationType": "awsAssumeRole", + "awsAssumeRoleArn": "arn:aws:iam::81231569658:role/AscConnector", + "awsExternalId": "20ff7fc3-e762-44dd-bd96-b71116dcdc23", + }, + "hybridComputeSettings": { + "autoProvision": "On", + "proxyServer": {"ip": "167.220.197.140", "port": "34"}, + "region": "West US 2", + "resourceGroupName": "AwsConnectorRG", + "servicePrincipal": {"applicationId": "ad9bcd79-be9c-45ab-abd8-80ca1654a7d1", "secret": ""}, + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsAssumeRoleConnectorSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/connectors/create_update_aws_cred_connector_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/connectors/create_update_aws_cred_connector_subscription_example.py new file mode 100644 index 000000000000..ac583cffc298 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/connectors/create_update_aws_cred_connector_subscription_example.py @@ -0,0 +1,58 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_update_aws_cred_connector_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.connectors.create_or_update( + connector_name="aws_dev1", + connector_setting={ + "properties": { + "authenticationDetails": { + "authenticationType": "awsCreds", + "awsAccessKeyId": "", + "awsSecretAccessKey": "", + }, + "hybridComputeSettings": { + "autoProvision": "On", + "proxyServer": {"ip": "167.220.197.140", "port": "34"}, + "region": "West US 2", + "resourceGroupName": "AwsConnectorRG", + "servicePrincipal": {"applicationId": "ad9bcd79-be9c-45ab-abd8-80ca1654a7d1", "secret": ""}, + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsCredConnectorSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/connectors/create_update_gcp_credentials_connector_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/connectors/create_update_gcp_credentials_connector_subscription_example.py new file mode 100644 index 000000000000..6656127c5f0d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/connectors/create_update_gcp_credentials_connector_subscription_example.py @@ -0,0 +1,61 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_update_gcp_credentials_connector_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.connectors.create_or_update( + connector_name="gcp_dev", + connector_setting={ + "properties": { + "authenticationDetails": { + "authProviderX509CertUrl": "https://www.googleapis.com/oauth2/v1/certs", + "authUri": "https://accounts.google.com/o/oauth2/auth", + "authenticationType": "gcpCredentials", + "clientEmail": "asc-135@asc-project-1234.iam.gserviceaccount.com", + "clientId": "105889053725632919854", + "clientX509CertUrl": "https://www.googleapis.com/robot/v1/metadata/x509/asc-135%40asc-project-1234.iam.gserviceaccount.com", + "organizationId": "AscDemoOrg", + "privateKey": "******", + "privateKeyId": "6efg587hra2568as34d22326b044cc20dc2af", + "projectId": "asc-project-1234", + "tokenUri": "https://oauth2.googleapis.com/token", + "type": "service_account", + }, + "hybridComputeSettings": {"autoProvision": "Off"}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateGcpCredentialsConnectorSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/connectors/delete_connector_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/connectors/delete_connector_subscription_example.py new file mode 100644 index 000000000000..f773ca4d8d32 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/connectors/delete_connector_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_connector_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.connectors.delete( + connector_name="aws_dev1", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/DeleteConnectorSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/connectors/get_connector_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/connectors/get_connector_subscription_example.py new file mode 100644 index 000000000000..c900f2ae3d19 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/connectors/get_connector_subscription_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_connector_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.connectors.get( + connector_name="aws_dev1", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetConnectorSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/connectors/get_list_connector_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/connectors/get_list_connector_subscription_example.py new file mode 100644 index 000000000000..ba7bbfedbbf4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/connectors/get_list_connector_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_list_connector_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.connectors.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetListConnectorSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_create_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_create_example.py new file mode 100644 index 000000000000..3e8bc687bd1c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_create_example.py @@ -0,0 +1,53 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_assessment_automation_create_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.custom_assessment_automations.create( + resource_group_name="TestResourceGroup", + custom_assessment_automation_name="MyCustomAssessmentAutomation", + custom_assessment_automation_body={ + "properties": { + "compressedQuery": "DQAKAEkAYQBtAF8ARwByAG8AdQBwAA0ACgB8ACAAZQB4AHQAZQBuAGQAIABIAGUAYQBsAHQAaABTAHQAYQB0AHUAcwAgAD0AIABpAGYAZgAoAHQAbwBzAHQAcgBpAG4AZwAoAFIAZQBjAG8AcgBkAC4AVQBzAGUAcgBOAGEAbQBlACkAIABjAG8AbgB0AGEAaQBuAHMAIAAnAHUAcwBlAHIAJwAsACAAJwBVAE4ASABFAEEATABUAEgAWQAnACwAIAAnAEgARQBBAEwAVABIAFkAJwApAA0ACgA=", + "description": "Data should be encrypted", + "displayName": "Password Policy", + "remediationDescription": "Encrypt store by...", + "severity": "Medium", + "supportedCloud": "AWS", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationCreate_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_delete_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_delete_example.py new file mode 100644 index 000000000000..74e54ccee8fb --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_delete_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_assessment_automation_delete_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + client.custom_assessment_automations.delete( + resource_group_name="TestResourceGroup", + custom_assessment_automation_name="MyCustomAssessmentAutomation", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationDelete_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_get_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_get_example.py new file mode 100644 index 000000000000..05fb075ea32c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_get_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_assessment_automation_get_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.custom_assessment_automations.get( + resource_group_name="TestResourceGroup", + custom_assessment_automation_name="MyCustomAssessmentAutomation", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationGet_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_list_by_resource_group_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_list_by_resource_group_example.py new file mode 100644 index 000000000000..8f9cd96807c9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_list_by_resource_group_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_assessment_automation_list_by_resource_group_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.custom_assessment_automations.list_by_resource_group( + resource_group_name="TestResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationListByResourceGroup_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_list_by_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_list_by_subscription_example.py new file mode 100644 index 000000000000..51934ba4ca9e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_assessment_automations/custom_assessment_automation_list_by_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_assessment_automation_list_by_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.custom_assessment_automations.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationListBySubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_create_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_create_example.py new file mode 100644 index 000000000000..c1fe30e55023 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_create_example.py @@ -0,0 +1,48 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_entity_store_assignment_create_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.custom_entity_store_assignments.create( + resource_group_name="TestResourceGroup", + custom_entity_store_assignment_name="33e7cc6e-a139-4723-a0e5-76993aee0771", + custom_entity_store_assignment_request_body={ + "properties": { + "principal": "aaduser=f3923a3e-ad57-4752-b1a9-fbf3c8e5e082;72f988bf-86f1-41af-91ab-2d7cd011db47" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentCreate_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_delete_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_delete_example.py new file mode 100644 index 000000000000..73590ce1f2c9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_delete_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_entity_store_assignment_delete_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + client.custom_entity_store_assignments.delete( + resource_group_name="TestResourceGroup", + custom_entity_store_assignment_name="33e7cc6e-a139-4723-a0e5-76993aee0771", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentDelete_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_get_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_get_example.py new file mode 100644 index 000000000000..286f27602f8a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_get_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_entity_store_assignment_get_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.custom_entity_store_assignments.get( + resource_group_name="TestResourceGroup", + custom_entity_store_assignment_name="33e7cc6e-a139-4723-a0e5-76993aee0771", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentGet_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_list_by_resource_group_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_list_by_resource_group_example.py new file mode 100644 index 000000000000..1ba042e38f44 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_list_by_resource_group_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_entity_store_assignment_list_by_resource_group_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.custom_entity_store_assignments.list_by_resource_group( + resource_group_name="TestResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentListByResourceGroup_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_list_by_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_list_by_subscription_example.py new file mode 100644 index 000000000000..485dda12c544 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_entity_store_assignments/custom_entity_store_assignment_list_by_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python custom_entity_store_assignment_list_by_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.custom_entity_store_assignments.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentListBySubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/delete_by_management_group_custom_recommendation_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/delete_by_management_group_custom_recommendation_example.py new file mode 100644 index 000000000000..820fe253658b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/delete_by_management_group_custom_recommendation_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_by_management_group_custom_recommendation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.custom_recommendations.delete( + scope="providers/Microsoft.Management/managementGroups/contoso", + custom_recommendation_name="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/DeleteByManagementGroupCustomRecommendation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/delete_by_security_connector_custom_recommendation_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/delete_by_security_connector_custom_recommendation_example.py new file mode 100644 index 000000000000..741b8e6c80b3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/delete_by_security_connector_custom_recommendation_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_by_security_connector_custom_recommendation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.custom_recommendations.delete( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + custom_recommendation_name="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/DeleteBySecurityConnectorCustomRecommendation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/delete_by_subscription_custom_recommendation_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/delete_by_subscription_custom_recommendation_example.py new file mode 100644 index 000000000000..3b457515d42e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/delete_by_subscription_custom_recommendation_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_by_subscription_custom_recommendation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.custom_recommendations.delete( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + custom_recommendation_name="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/DeleteBySubscriptionCustomRecommendation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/get_by_management_group_custom_recommendation_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/get_by_management_group_custom_recommendation_example.py new file mode 100644 index 000000000000..ca11d01a7b1c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/get_by_management_group_custom_recommendation_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_by_management_group_custom_recommendation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.custom_recommendations.get( + scope="providers/Microsoft.Management/managementGroups/contoso", + custom_recommendation_name="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/GetByManagementGroupCustomRecommendation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/get_by_security_connector_custom_recommendation_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/get_by_security_connector_custom_recommendation_example.py new file mode 100644 index 000000000000..4cbcf88c26d1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/get_by_security_connector_custom_recommendation_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_by_security_connector_custom_recommendation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.custom_recommendations.get( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + custom_recommendation_name="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/GetBySecurityConnectorCustomRecommendation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/get_by_subscription_custom_recommendation_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/get_by_subscription_custom_recommendation_example.py new file mode 100644 index 000000000000..afc61dfc4fa6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/get_by_subscription_custom_recommendation_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_by_subscription_custom_recommendation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.custom_recommendations.get( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + custom_recommendation_name="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/GetBySubscriptionCustomRecommendation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/list_by_management_group_custom_recommendations_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/list_by_management_group_custom_recommendations_example.py new file mode 100644 index 000000000000..702be79f89e2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/list_by_management_group_custom_recommendations_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_management_group_custom_recommendations_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.custom_recommendations.list( + scope="providers/Microsoft.Management/managementGroups/contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/ListByManagementGroupCustomRecommendations_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/list_by_security_connector_custom_recommendations_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/list_by_security_connector_custom_recommendations_example.py new file mode 100644 index 000000000000..a913429e2852 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/list_by_security_connector_custom_recommendations_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_security_connector_custom_recommendations_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.custom_recommendations.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/ListBySecurityConnectorCustomRecommendations_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/list_by_subscription_custom_recommendations_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/list_by_subscription_custom_recommendations_example.py new file mode 100644 index 000000000000..524da2f8b40c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/list_by_subscription_custom_recommendations_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_subscription_custom_recommendations_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.custom_recommendations.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/ListBySubscriptionCustomRecommendations_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/put_by_management_group_custom_recommendation_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/put_by_management_group_custom_recommendation_example.py new file mode 100644 index 000000000000..224619249085 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/put_by_management_group_custom_recommendation_example.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_by_management_group_custom_recommendation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.custom_recommendations.create_or_update( + scope="providers/Microsoft.Management/managementGroups/contoso", + custom_recommendation_name="33e7cc6e-a139-4723-a0e5-76993aee0771", + custom_recommendation_body={ + "properties": { + "cloudProviders": ["AWS"], + "description": "organization passwords policy", + "displayName": "Password Policy", + "query": "RawEntityMetadata | where Environment == 'GCP' and Identifiers.Type == 'compute.firewalls' | extend IslogConfigEnabled = tobool(Record.logConfig.enable) | extend HealthStatus = iff(IslogConfigEnabled, 'HEALTHY', 'UNHEALTHY')", + "remediationDescription": "Change password policy to...", + "securityIssue": "Vulnerability", + "severity": "Medium", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/PutByManagementGroupCustomRecommendation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/put_by_security_connector_custom_recommendation_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/put_by_security_connector_custom_recommendation_example.py new file mode 100644 index 000000000000..0590b833b2b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/put_by_security_connector_custom_recommendation_example.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_by_security_connector_custom_recommendation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.custom_recommendations.create_or_update( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + custom_recommendation_name="33e7cc6e-a139-4723-a0e5-76993aee0771", + custom_recommendation_body={ + "properties": { + "cloudProviders": ["AWS"], + "description": "organization passwords policy", + "displayName": "Password Policy", + "query": "RawEntityMetadata | where Environment == 'GCP' and Identifiers.Type == 'compute.firewalls' | extend IslogConfigEnabled = tobool(Record.logConfig.enable) | extend HealthStatus = iff(IslogConfigEnabled, 'HEALTHY', 'UNHEALTHY')", + "remediationDescription": "Change password policy to...", + "securityIssue": "Vulnerability", + "severity": "Medium", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/PutBySecurityConnectorCustomRecommendation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/put_by_subscription_custom_recommendation_example.py b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/put_by_subscription_custom_recommendation_example.py new file mode 100644 index 000000000000..96912d15d9eb --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/custom_recommendations/put_by_subscription_custom_recommendation_example.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_by_subscription_custom_recommendation_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.custom_recommendations.create_or_update( + scope="subscriptions/e5d1b86c-3051-44d5-8802-aa65d45a279b", + custom_recommendation_name="33e7cc6e-a139-4723-a0e5-76993aee0771", + custom_recommendation_body={ + "properties": { + "cloudProviders": ["AWS"], + "description": "organization passwords policy", + "displayName": "Password Policy", + "query": "RawEntityMetadata | where Environment == 'GCP' and Identifiers.Type == 'compute.firewalls' | extend IslogConfigEnabled = tobool(Record.logConfig.enable) | extend HealthStatus = iff(IslogConfigEnabled, 'HEALTHY', 'UNHEALTHY')", + "remediationDescription": "Change password policy to...", + "securityIssue": "Vulnerability", + "severity": "Medium", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/CustomRecommendations/PutBySubscriptionCustomRecommendation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/cancel_malware_scan_example.py b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/cancel_malware_scan_example.py new file mode 100644 index 000000000000..af501dff9533 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/cancel_malware_scan_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python cancel_malware_scan_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.defender_for_storage.cancel_malware_scan( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount", + setting_name="current", + scan_id="latest", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-02-01-preview/examples/DefenderForStorage/CancelMalwareScan_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/get_defender_for_storage_settings_example.py b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/get_defender_for_storage_settings_example.py new file mode 100644 index 000000000000..00d395627cc2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/get_defender_for_storage_settings_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_defender_for_storage_settings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.defender_for_storage.get( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount", + setting_name="current", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-02-01-preview/examples/DefenderForStorage/GetDefenderForStorageSettings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/get_malware_scan_example.py b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/get_malware_scan_example.py new file mode 100644 index 000000000000..b2340d2aa6e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/get_malware_scan_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_malware_scan_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.defender_for_storage.get_malware_scan( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount", + setting_name="current", + scan_id="latest", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-02-01-preview/examples/DefenderForStorage/GetMalwareScan_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/put_defender_for_storage_settings_example.py b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/put_defender_for_storage_settings_example.py new file mode 100644 index 000000000000..e5bd1beec4bc --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/put_defender_for_storage_settings_example.py @@ -0,0 +1,62 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_defender_for_storage_settings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.defender_for_storage.create( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount", + setting_name="current", + defender_for_storage_setting={ + "properties": { + "isEnabled": True, + "malwareScanning": { + "onUpload": { + "capGBPerMonth": -1, + "filters": { + "excludeBlobsLargerThan": 1024, + "excludeBlobsWithPrefix": ["unscanned-container", "sample-container/logs"], + "excludeBlobsWithSuffix": [".log", ".jpg"], + }, + "isEnabled": True, + }, + "scanResultsEventGridTopicResourceId": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.EventGrid/topics/sampletopic", + }, + "overrideSubscriptionLevelSettings": True, + "sensitiveDataDiscovery": {"isEnabled": True}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-02-01-preview/examples/DefenderForStorage/PutDefenderForStorageSettings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/start_malware_scan_example.py b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/start_malware_scan_example.py new file mode 100644 index 000000000000..5d1b2886deb3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/defender_for_storage/start_malware_scan_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python start_malware_scan_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.defender_for_storage.start_malware_scan( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount", + setting_name="current", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-02-01-preview/examples/DefenderForStorage/StartMalwareScan_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/delete_device_security_groups_example.py b/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/delete_device_security_groups_example.py new file mode 100644 index 000000000000..c0b62d9ab6b9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/delete_device_security_groups_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_device_security_groups_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.device_security_groups.delete( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub", + device_security_group_name="samplesecuritygroup", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/DeleteDeviceSecurityGroups_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/get_device_security_groups_example.py b/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/get_device_security_groups_example.py new file mode 100644 index 000000000000..a7fd35f85eab --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/get_device_security_groups_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_device_security_groups_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.device_security_groups.get( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub", + device_security_group_name="samplesecuritygroup", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/GetDeviceSecurityGroups_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/list_device_security_groups_example.py b/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/list_device_security_groups_example.py new file mode 100644 index 000000000000..26e2912c4289 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/list_device_security_groups_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_device_security_groups_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.device_security_groups.list( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/ListDeviceSecurityGroups_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/put_device_security_groups_example.py b/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/put_device_security_groups_example.py new file mode 100644 index 000000000000..152af48895fb --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/device_security_groups/put_device_security_groups_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_device_security_groups_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.device_security_groups.create_or_update( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub", + device_security_group_name="samplesecuritygroup", + device_security_group={ + "properties": { + "timeWindowRules": [ + { + "isEnabled": True, + "maxThreshold": 30, + "minThreshold": 0, + "ruleType": "ActiveConnectionsNotInAllowedRange", + "timeWindowSize": "PT05M", + } + ] + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/PutDeviceSecurityGroups_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/discovered_security_solutions/get_discovered_security_solution_resource_group_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/discovered_security_solutions/get_discovered_security_solution_resource_group_location_example.py new file mode 100644 index 000000000000..9ffd7095d13b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/discovered_security_solutions/get_discovered_security_solution_resource_group_location_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_discovered_security_solution_resource_group_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.discovered_security_solutions.get( + resource_group_name="myRg2", + asc_location="centralus", + discovered_security_solution_name="paloalto7", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/DiscoveredSecuritySolutions/GetDiscoveredSecuritySolutionResourceGroupLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/discovered_security_solutions/get_discovered_security_solutions_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/discovered_security_solutions/get_discovered_security_solutions_subscription_example.py new file mode 100644 index 000000000000..25c838a1d450 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/discovered_security_solutions/get_discovered_security_solutions_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_discovered_security_solutions_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.discovered_security_solutions.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/DiscoveredSecuritySolutions/GetDiscoveredSecuritySolutionsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/discovered_security_solutions/get_discovered_security_solutions_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/discovered_security_solutions/get_discovered_security_solutions_subscription_location_example.py new file mode 100644 index 000000000000..6846eeba2bf4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/discovered_security_solutions/get_discovered_security_solutions_subscription_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_discovered_security_solutions_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.discovered_security_solutions.list_by_home_region( + asc_location="centralus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/DiscoveredSecuritySolutions/GetDiscoveredSecuritySolutionsSubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/external_security_solutions/get_external_security_solution_example.py b/sdk/security/azure-mgmt-security/generated_samples/external_security_solutions/get_external_security_solution_example.py new file mode 100644 index 000000000000..ff85fe44a093 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/external_security_solutions/get_external_security_solution_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_external_security_solution_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.external_security_solutions.get( + resource_group_name="defaultresourcegroup-eus", + asc_location="centralus", + external_security_solutions_name="aad_defaultworkspace-20ff7fc3-e762-44dd-bd96-b71116dcdc23-eus", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ExternalSecuritySolutions/GetExternalSecuritySolution_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/external_security_solutions/get_external_security_solutions_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/external_security_solutions/get_external_security_solutions_subscription_example.py new file mode 100644 index 000000000000..e995cdc4805f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/external_security_solutions/get_external_security_solutions_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_external_security_solutions_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.external_security_solutions.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ExternalSecuritySolutions/GetExternalSecuritySolutionsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/external_security_solutions/get_external_security_solutions_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/external_security_solutions/get_external_security_solutions_subscription_location_example.py new file mode 100644 index 000000000000..e247838a4b99 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/external_security_solutions/get_external_security_solutions_subscription_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_external_security_solutions_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.external_security_solutions.list_by_home_region( + asc_location="centralus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ExternalSecuritySolutions/GetExternalSecuritySolutionsSubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_cloud_posture_example.py b/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_cloud_posture_example.py deleted file mode 100644 index 8017397a433d..000000000000 --- a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_cloud_posture_example.py +++ /dev/null @@ -1,40 +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 azure.identity import DefaultAzureCredential -from azure.mgmt.security import SecurityCenter - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-security -# USAGE - python get_pricing_by_name_cloud_posture_example.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 = SecurityCenter( - credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", - ) - - response = client.pricings.get( - pricing_name="CloudPosture", - ) - print(response) - - -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameCloudPosture_example.json -if __name__ == "__main__": - main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_containers_example.py b/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_containers_example.py deleted file mode 100644 index ce6d86c97096..000000000000 --- a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_containers_example.py +++ /dev/null @@ -1,40 +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 azure.identity import DefaultAzureCredential -from azure.mgmt.security import SecurityCenter - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-security -# USAGE - python get_pricing_by_name_containers_example.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 = SecurityCenter( - credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", - ) - - response = client.pricings.get( - pricing_name="Containers", - ) - print(response) - - -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameContainers_example.json -if __name__ == "__main__": - main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_dns_example.py b/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_dns_example.py deleted file mode 100644 index 2e11fb0479eb..000000000000 --- a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_dns_example.py +++ /dev/null @@ -1,40 +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 azure.identity import DefaultAzureCredential -from azure.mgmt.security import SecurityCenter - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-security -# USAGE - python get_pricing_by_name_dns_example.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 = SecurityCenter( - credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", - ) - - response = client.pricings.get( - pricing_name="Dns", - ) - print(response) - - -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameDns_example.json -if __name__ == "__main__": - main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_storage_accounts_example.py b/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_storage_accounts_example.py deleted file mode 100644 index 270278401b8c..000000000000 --- a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_storage_accounts_example.py +++ /dev/null @@ -1,40 +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 azure.identity import DefaultAzureCredential -from azure.mgmt.security import SecurityCenter - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-security -# USAGE - python get_pricing_by_name_storage_accounts_example.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 = SecurityCenter( - credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", - ) - - response = client.pricings.get( - pricing_name="StorageAccounts", - ) - print(response) - - -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameStorageAccounts_example.json -if __name__ == "__main__": - main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_virtual_machines_example.py b/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_virtual_machines_example.py deleted file mode 100644 index 8e2dfa237042..000000000000 --- a/sdk/security/azure-mgmt-security/generated_samples/get_pricing_by_name_virtual_machines_example.py +++ /dev/null @@ -1,40 +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 azure.identity import DefaultAzureCredential -from azure.mgmt.security import SecurityCenter - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-security -# USAGE - python get_pricing_by_name_virtual_machines_example.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 = SecurityCenter( - credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", - ) - - response = client.pricings.get( - pricing_name="VirtualMachines", - ) - print(response) - - -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json -if __name__ == "__main__": - main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/delete_governance_assignment_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/delete_governance_assignment_example.py new file mode 100644 index 000000000000..4480bdd69e66 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/delete_governance_assignment_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_governance_assignment_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.governance_assignments.delete( + scope="subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012", + assessment_name="6b9421dd-5555-2251-9b3d-2be58e2f82cd", + assignment_key="6634ff9f-127b-4bf2-8e6e-b1737f5e789c", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/DeleteGovernanceAssignment_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/get_governance_assignment_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/get_governance_assignment_example.py new file mode 100644 index 000000000000..a83ec7cd8607 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/get_governance_assignment_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_governance_assignment_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_assignments.get( + scope="subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012", + assessment_name="6b9421dd-5555-2251-9b3d-2be58e2f82cd", + assignment_key="6634ff9f-127b-4bf2-8e6e-b1737f5e789c", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/GetGovernanceAssignment_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/list_governance_assignments_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/list_governance_assignments_example.py new file mode 100644 index 000000000000..8f669f7a878b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/list_governance_assignments_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_governance_assignments_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_assignments.list( + scope="subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd", + assessment_name="6b9421dd-5555-2251-9b3d-2be58e2f82cd", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/ListGovernanceAssignments_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/put_governance_assignment_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/put_governance_assignment_example.py new file mode 100644 index 000000000000..7213ffcd7916 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_assignments/put_governance_assignment_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_governance_assignment_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_assignments.create_or_update( + scope="subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012", + assessment_name="6b9421dd-5555-2251-9b3d-2be58e2f82cd", + assignment_key="6634ff9f-127b-4bf2-8e6e-b1737f5e789c", + governance_assignment={ + "properties": { + "additionalData": {"ticketLink": "https://snow.com", "ticketNumber": 123123, "ticketStatus": "Active"}, + "governanceEmailNotification": { + "disableManagerEmailNotification": False, + "disableOwnerEmailNotification": False, + }, + "isGracePeriod": True, + "owner": "user@contoso.com", + "remediationDueDate": "2022-01-07T13:00:00.0000000Z", + "remediationEta": {"eta": "2022-01-08T13:00:00.0000000Z", "justification": "Justification of ETA"}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/PutGovernanceAssignment_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/delete_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/delete_governance_rule_example.py new file mode 100644 index 000000000000..068145c5500d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/delete_governance_rule_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.governance_rules.begin_delete( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ).result() + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/delete_management_group_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/delete_management_group_governance_rule_example.py new file mode 100644 index 000000000000..dd646d8790e3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/delete_management_group_governance_rule_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_management_group_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.governance_rules.begin_delete( + scope="providers/Microsoft.Management/managementGroups/contoso", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ).result() + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteManagementGroupGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/delete_security_connector_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/delete_security_connector_governance_rule_example.py new file mode 100644 index 000000000000..f347ff78f8f4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/delete_security_connector_governance_rule_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_security_connector_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.governance_rules.begin_delete( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ).result() + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteSecurityConnectorGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_governance_rule_example.py new file mode 100644 index 000000000000..05836478efc8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_governance_rule_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.get( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_governance_rule_execute_status_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_governance_rule_execute_status_example.py new file mode 100644 index 000000000000..fe822de8c9bc --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_governance_rule_execute_status_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_governance_rule_execute_status_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.operation_results( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + operation_id="58b33f4f-c8c7-4b01-99cc-d437db4d40dd", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetGovernanceRuleExecuteStatus_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_management_group_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_management_group_governance_rule_example.py new file mode 100644 index 000000000000..9043c7621aee --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_management_group_governance_rule_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_management_group_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.get( + scope="providers/Microsoft.Management/managementGroups/contoso", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetManagementGroupGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_management_group_governance_rule_execute_status_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_management_group_governance_rule_execute_status_example.py new file mode 100644 index 000000000000..d5ca4f60290e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_management_group_governance_rule_execute_status_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_management_group_governance_rule_execute_status_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.operation_results( + scope="providers/Microsoft.Management/managementGroups/contoso", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + operation_id="58b33f4f-c8c7-4b01-99cc-d437db4d40dd", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetManagementGroupGovernanceRuleExecuteStatus_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_security_connector_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_security_connector_governance_rule_example.py new file mode 100644 index 000000000000..b43a43a01c41 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_security_connector_governance_rule_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_connector_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.get( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_security_connector_governance_rule_execute_status_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_security_connector_governance_rule_execute_status_example.py new file mode 100644 index 000000000000..448bba62adc7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/get_security_connector_governance_rule_execute_status_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_connector_governance_rule_execute_status_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.operation_results( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + operation_id="58b33f4f-c8c7-4b01-99cc-d437db4d40dd", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRuleExecuteStatus_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/list_by_management_group_governance_rules_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/list_by_management_group_governance_rules_example.py new file mode 100644 index 000000000000..fc5856b6d76f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/list_by_management_group_governance_rules_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_management_group_governance_rules_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.list( + scope="providers/Microsoft.Management/managementGroups/contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListByManagementGroupGovernanceRules_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/list_by_security_connector_governance_rules_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/list_by_security_connector_governance_rules_example.py new file mode 100644 index 000000000000..ebf85040d74e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/list_by_security_connector_governance_rules_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_security_connector_governance_rules_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListBySecurityConnectorGovernanceRules_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/list_by_subscription_governance_rules_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/list_by_subscription_governance_rules_example.py new file mode 100644 index 000000000000..3e6ab5b4af0a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/list_by_subscription_governance_rules_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_subscription_governance_rules_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListBySubscriptionGovernanceRules_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/post_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/post_governance_rule_example.py new file mode 100644 index 000000000000..49eea7dea041 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/post_governance_rule_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python post_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.governance_rules.begin_execute( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ).result() + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PostGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/post_management_group_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/post_management_group_governance_rule_example.py new file mode 100644 index 000000000000..6e8ad77e8499 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/post_management_group_governance_rule_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python post_management_group_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.governance_rules.begin_execute( + scope="providers/Microsoft.Management/managementGroups/contoso", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ).result() + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PostManagementGroupGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/post_security_connector_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/post_security_connector_governance_rule_example.py new file mode 100644 index 000000000000..b34845570e50 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/post_security_connector_governance_rule_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python post_security_connector_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.governance_rules.begin_execute( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ).result() + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PostSecurityConnectorGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/put_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/put_governance_rule_example.py new file mode 100644 index 000000000000..c3476d5cfe5c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/put_governance_rule_example.py @@ -0,0 +1,71 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.create_or_update( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + governance_rule={ + "properties": { + "conditionSets": [ + { + "conditions": [ + { + "operator": "In", + "property": "$.AssessmentKey", + "value": '["b1cd27e0-4ecc-4246-939f-49c426d9d72f", "fe83f80b-073d-4ccf-93d9-6797eb870201"]', + } + ] + } + ], + "description": "A rule for critical recommendations", + "displayName": "Admin's rule", + "governanceEmailNotification": { + "disableManagerEmailNotification": False, + "disableOwnerEmailNotification": False, + }, + "isDisabled": False, + "isGracePeriod": True, + "ownerSource": {"type": "Manually", "value": "user@contoso.com"}, + "remediationTimeframe": "7.00:00:00", + "rulePriority": 200, + "ruleType": "Integrated", + "sourceResourceType": "Assessments", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/put_management_group_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/put_management_group_governance_rule_example.py new file mode 100644 index 000000000000..8bafe7d86c21 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/put_management_group_governance_rule_example.py @@ -0,0 +1,72 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_management_group_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.create_or_update( + scope="providers/Microsoft.Management/managementGroups/contoso", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + governance_rule={ + "properties": { + "conditionSets": [ + { + "conditions": [ + { + "operator": "In", + "property": "$.AssessmentKey", + "value": '["b1cd27e0-4ecc-4246-939f-49c426d9d72f", "fe83f80b-073d-4ccf-93d9-6797eb870201"]', + } + ] + } + ], + "description": "A rule for a management group", + "displayName": "Management group rule", + "excludedScopes": ["/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"], + "governanceEmailNotification": { + "disableManagerEmailNotification": True, + "disableOwnerEmailNotification": False, + }, + "isDisabled": False, + "isGracePeriod": True, + "ownerSource": {"type": "Manually", "value": "user@contoso.com"}, + "remediationTimeframe": "7.00:00:00", + "rulePriority": 200, + "ruleType": "Integrated", + "sourceResourceType": "Assessments", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutManagementGroupGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/governance_rules/put_security_connector_governance_rule_example.py b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/put_security_connector_governance_rule_example.py new file mode 100644 index 000000000000..ff307969e3cc --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/governance_rules/put_security_connector_governance_rule_example.py @@ -0,0 +1,71 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_security_connector_governance_rule_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.governance_rules.create_or_update( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + rule_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + governance_rule={ + "properties": { + "conditionSets": [ + { + "conditions": [ + { + "operator": "In", + "property": "$.AssessmentKey", + "value": '["b1cd27e0-4ecc-4246-939f-49c426d9d72f", "fe83f80b-073d-4ccf-93d9-6797eb870201"]', + } + ] + } + ], + "description": "A rule on critical GCP recommendations", + "displayName": "GCP Admin's rule", + "governanceEmailNotification": { + "disableManagerEmailNotification": True, + "disableOwnerEmailNotification": False, + }, + "isDisabled": False, + "isGracePeriod": True, + "ownerSource": {"type": "Manually", "value": "user@contoso.com"}, + "remediationTimeframe": "7.00:00:00", + "rulePriority": 200, + "ruleType": "Integrated", + "sourceResourceType": "Assessments", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutSecurityConnectorGovernanceRule_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/health_reports/get_health_reports_example.py b/sdk/security/azure-mgmt-security/generated_samples/health_reports/get_health_reports_example.py new file mode 100644 index 000000000000..524f146d43e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/health_reports/get_health_reports_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_health_reports_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.health_reports.get( + resource_id="subscriptions/a1efb6ca-fbc5-4782-9aaa-5c7daded1ce2/resourcegroups/E2E-IBB0WX/providers/Microsoft.Security/securityconnectors/AwsConnectorAllOfferings", + health_report_name="909c629a-bf39-4521-8e4f-10b443a0bc02", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-05-01-preview/examples/HealthReports/GetHealthReports_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/health_reports/list_health_reports_example.py b/sdk/security/azure-mgmt-security/generated_samples/health_reports/list_health_reports_example.py new file mode 100644 index 000000000000..79709a75e016 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/health_reports/list_health_reports_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_health_reports_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.health_reports.list( + scope="subscriptions/a1efb6ca-fbc5-4782-9aaa-5c7daded1ce2", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-05-01-preview/examples/HealthReports/ListHealthReports_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/create_or_update_information_protection_policy_example.py b/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/create_or_update_information_protection_policy_example.py new file mode 100644 index 000000000000..91621c7e59a4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/create_or_update_information_protection_policy_example.py @@ -0,0 +1,74 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_or_update_information_protection_policy_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.information_protection_policies.create_or_update( + scope="providers/Microsoft.Management/managementGroups/148059f7-faf3-49a6-ba35-85122112291e", + information_protection_policy_name="custom", + information_protection_policy={ + "properties": { + "informationTypes": { + "3bf35491-99b8-41f2-86d5-c1200a7df658": { + "custom": True, + "displayName": "Custom", + "enabled": True, + "keywords": [{"canBeNumeric": True, "custom": True, "pattern": "%custom%"}], + "order": 1400, + "recommendedLabelId": "7aa516c7-5a53-4857-bc6e-6808c6acd542", + }, + "7fb9419d-2473-4ad8-8e11-b25cc8cf6a07": { + "custom": False, + "displayName": "Networking", + "enabled": True, + "keywords": [{"canBeNumeric": False, "custom": True, "pattern": "%networking%"}], + "order": 100, + "recommendedLabelId": "575739d2-3d53-4df0-9042-4c7772d5c7b1", + }, + }, + "labels": { + "1345da73-bc5a-4a8f-b7dd-3820eb713da8": {"displayName": "Public", "enabled": True, "order": 100}, + "575739d2-3d53-4df0-9042-4c7772d5c7b1": { + "displayName": "Confidential", + "enabled": True, + "order": 300, + }, + "7aa516c7-5a53-4857-bc6e-6808c6acd542": {"displayName": "General", "enabled": True, "order": 200}, + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/InformationProtectionPolicies/CreateOrUpdateInformationProtectionPolicy_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/get_custom_information_protection_policy_example.py b/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/get_custom_information_protection_policy_example.py new file mode 100644 index 000000000000..d46036146e4a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/get_custom_information_protection_policy_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_custom_information_protection_policy_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.information_protection_policies.get( + scope="providers/Microsoft.Management/managementGroups/148059f7-faf3-49a6-ba35-85122112291e", + information_protection_policy_name="custom", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/InformationProtectionPolicies/GetCustomInformationProtectionPolicy_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/get_effective_information_protection_policy_example.py b/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/get_effective_information_protection_policy_example.py new file mode 100644 index 000000000000..b971c28f2be7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/get_effective_information_protection_policy_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_effective_information_protection_policy_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.information_protection_policies.get( + scope="providers/Microsoft.Management/managementGroups/148059f7-faf3-49a6-ba35-85122112291e", + information_protection_policy_name="effective", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/InformationProtectionPolicies/GetEffectiveInformationProtectionPolicy_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/list_information_protection_policies_example.py b/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/list_information_protection_policies_example.py new file mode 100644 index 000000000000..2144778d4156 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/information_protection_policies/list_information_protection_policies_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_information_protection_policies_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.information_protection_policies.list( + scope="providers/Microsoft.Management/managementGroups/148059f7-faf3-49a6-ba35-85122112291e", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/InformationProtectionPolicies/ListInformationProtectionPolicies_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/create_io_tsecurity_solution.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/create_io_tsecurity_solution.py new file mode 100644 index 000000000000..054f2856a68a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/create_io_tsecurity_solution.py @@ -0,0 +1,66 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_io_tsecurity_solution.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solution.create_or_update( + resource_group_name="MyGroup", + solution_name="default", + iot_security_solution_data={ + "location": "East Us", + "properties": { + "disabledDataSources": [], + "displayName": "Solution Default", + "export": [], + "iotHubs": [ + "/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub" + ], + "recommendationsConfiguration": [ + {"recommendationType": "IoT_OpenPorts", "status": "Disabled"}, + {"recommendationType": "IoT_SharedCredentials", "status": "Disabled"}, + ], + "status": "Enabled", + "unmaskedIpLoggingStatus": "Enabled", + "userDefinedResources": { + "query": 'where type != "microsoft.devices/iothubs" | where name contains "iot"', + "querySubscriptions": ["075423e9-7d33-4166-8bdf-3920b04e3735"], + }, + "workspace": "/subscriptions/c4930e90-cd72-4aa5-93e9-2d081d129569/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace1", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/CreateIoTSecuritySolution.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/delete_io_tsecurity_solution.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/delete_io_tsecurity_solution.py new file mode 100644 index 000000000000..398cd251f204 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/delete_io_tsecurity_solution.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_io_tsecurity_solution.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.iot_security_solution.delete( + resource_group_name="MyGroup", + solution_name="default", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/DeleteIoTSecuritySolution.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solution.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solution.py new file mode 100644 index 000000000000..c1c9a1e71dc9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solution.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solution.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solution.get( + resource_group_name="MyGroup", + solution_name="default", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolution.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list.py new file mode 100644 index 000000000000..5ed41fce8450 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solution.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsList.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list_by_iot_hub.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list_by_iot_hub.py new file mode 100644 index 000000000000..7190cbb8966d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list_by_iot_hub.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_list_by_iot_hub.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solution.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByIotHub.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list_by_iot_hub_and_rg.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list_by_iot_hub_and_rg.py new file mode 100644 index 000000000000..9c74b906e7dc --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list_by_iot_hub_and_rg.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_list_by_iot_hub_and_rg.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solution.list_by_resource_group( + resource_group_name="MyRg", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByIotHubAndRg.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list_by_rg.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list_by_rg.py new file mode 100644 index 000000000000..19ec5fcfb0b5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/get_io_tsecurity_solutions_list_by_rg.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_list_by_rg.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solution.list_by_resource_group( + resource_group_name="MyGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByRg.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/update_io_tsecurity_solution.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/update_io_tsecurity_solution.py new file mode 100644 index 000000000000..0896c6b6132f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions/update_io_tsecurity_solution.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_io_tsecurity_solution.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solution.update( + resource_group_name="myRg", + solution_name="default", + update_iot_security_solution_data={ + "properties": { + "recommendationsConfiguration": [ + {"recommendationType": "IoT_OpenPorts", "status": "Disabled"}, + {"recommendationType": "IoT_SharedCredentials", "status": "Disabled"}, + ], + "userDefinedResources": { + "query": 'where type != "microsoft.devices/iothubs" | where name contains "v2"', + "querySubscriptions": ["075423e9-7d33-4166-8bdf-3920b04e3735"], + }, + }, + "tags": {"foo": "bar"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/UpdateIoTSecuritySolution.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_aggregated_alert.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_aggregated_alert.py new file mode 100644 index 000000000000..63994c0f1bad --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_aggregated_alert.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_security_aggregated_alert.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solutions_analytics_aggregated_alert.get( + resource_group_name="MyGroup", + solution_name="default", + aggregated_alert_name="IoT_Bruteforce_Fail/2019-02-02", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAggregatedAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_aggregated_alert_list.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_aggregated_alert_list.py new file mode 100644 index 000000000000..0c2cf430bac0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_aggregated_alert_list.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_security_aggregated_alert_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solutions_analytics_aggregated_alert.list( + resource_group_name="MyGroup", + solution_name="default", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAggregatedAlertList.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_analytics.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_analytics.py new file mode 100644 index 000000000000..5577063f6f37 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_analytics.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_security_analytics.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solution_analytics.get( + resource_group_name="MyGroup", + solution_name="default", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAnalytics.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_analytics_list.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_analytics_list.py new file mode 100644 index 000000000000..c5e7bc5c7122 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_analytics_list.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_security_analytics_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.iot_security_solution_analytics.list( + resource_group_name="MyGroup", + solution_name="default", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAnalyticsList.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_recommendation.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_recommendation.py new file mode 100644 index 000000000000..2eb17b70c17f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_recommendation.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_security_recommendation.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="075423e9-7d33-4166-8bdf-3920b04e3735", + ) + + response = client.iot_security_solutions_analytics_recommendation.get( + resource_group_name="IoTEdgeResources", + solution_name="default", + aggregated_recommendation_name="OpenPortsOnDevice", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityRecommendation.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_recommendation_list.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_recommendation_list.py new file mode 100644 index 000000000000..d70d5f957601 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/get_io_tsecurity_solutions_security_recommendation_list.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_io_tsecurity_solutions_security_recommendation_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="075423e9-7d33-4166-8bdf-3920b04e3735", + ) + + response = client.iot_security_solutions_analytics_recommendation.list( + resource_group_name="IoTEdgeResources", + solution_name="default", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityRecommendationList.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/post_io_tsecurity_solutions_security_aggregated_alert_dismiss.py b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/post_io_tsecurity_solutions_security_aggregated_alert_dismiss.py new file mode 100644 index 000000000000..d9c1e6751c75 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/io_tsecurity_solutions_analytics/post_io_tsecurity_solutions_security_aggregated_alert_dismiss.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python post_io_tsecurity_solutions_security_aggregated_alert_dismiss.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.iot_security_solutions_analytics_aggregated_alert.dismiss( + resource_group_name="IoTEdgeResources", + solution_name="default", + aggregated_alert_name="IoT_Bruteforce_Fail/2019-02-02/dismiss", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/PostIoTSecuritySolutionsSecurityAggregatedAlertDismiss.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/create_jit_network_access_policy_example.py b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/create_jit_network_access_policy_example.py new file mode 100644 index 000000000000..98164ed99615 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/create_jit_network_access_policy_example.py @@ -0,0 +1,93 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_jit_network_access_policy_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.jit_network_access_policies.create_or_update( + resource_group_name="myRg1", + asc_location="westeurope", + jit_network_access_policy_name="default", + body={ + "id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Security/locations/westeurope/jitNetworkAccessPolicies/default", + "kind": "Basic", + "location": "westeurope", + "name": "default", + "properties": { + "provisioningState": "Succeeded", + "requests": [ + { + "requestor": "barbara@contoso.com", + "startTimeUtc": "2018-05-17T08:06:45.5691611Z", + "virtualMachines": [ + { + "id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1", + "ports": [ + { + "allowedSourceAddressPrefix": "192.127.0.2", + "endTimeUtc": "2018-05-17T09:06:45.5691611Z", + "number": 3389, + "status": "Initiated", + "statusReason": "UserRequested", + } + ], + } + ], + } + ], + "virtualMachines": [ + { + "id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1", + "ports": [ + { + "allowedSourceAddressPrefix": "*", + "maxRequestAccessDuration": "PT3H", + "number": 22, + "protocol": "*", + }, + { + "allowedSourceAddressPrefix": "*", + "maxRequestAccessDuration": "PT3H", + "number": 3389, + "protocol": "*", + }, + ], + } + ], + }, + "type": "Microsoft.Security/locations/jitNetworkAccessPolicies", + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/CreateJitNetworkAccessPolicy_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/delete_jit_network_access_policy_example.py b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/delete_jit_network_access_policy_example.py new file mode 100644 index 000000000000..d4098031855d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/delete_jit_network_access_policy_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_jit_network_access_policy_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.jit_network_access_policies.delete( + resource_group_name="myRg1", + asc_location="westeurope", + jit_network_access_policy_name="default", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/DeleteJitNetworkAccessPolicy_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_resource_group_example.py b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_resource_group_example.py new file mode 100644 index 000000000000..ee6f6219805c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_resource_group_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_jit_network_access_policies_resource_group_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.jit_network_access_policies.list_by_resource_group( + resource_group_name="myRg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesResourceGroup_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_resource_group_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_resource_group_location_example.py new file mode 100644 index 000000000000..754c42050c3d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_resource_group_location_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_jit_network_access_policies_resource_group_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.jit_network_access_policies.list_by_resource_group_and_region( + resource_group_name="myRg1", + asc_location="westeurope", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesResourceGroupLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_subscription_example.py new file mode 100644 index 000000000000..789e98abae95 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_jit_network_access_policies_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.jit_network_access_policies.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_subscription_location_example.py new file mode 100644 index 000000000000..f54678df0ebc --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policies_subscription_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_jit_network_access_policies_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.jit_network_access_policies.list_by_region( + asc_location="westeurope", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesSubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policy_example.py b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policy_example.py new file mode 100644 index 000000000000..7b76c71f10cd --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/get_jit_network_access_policy_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_jit_network_access_policy_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.jit_network_access_policies.get( + resource_group_name="myRg1", + asc_location="westeurope", + jit_network_access_policy_name="default", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPolicy_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/initiate_jit_network_access_policy_example.py b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/initiate_jit_network_access_policy_example.py new file mode 100644 index 000000000000..2ebff49d820f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/jit_network_access_policies/initiate_jit_network_access_policy_example.py @@ -0,0 +1,53 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python initiate_jit_network_access_policy_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.jit_network_access_policies.initiate( + resource_group_name="myRg1", + asc_location="westeurope", + jit_network_access_policy_name="default", + body={ + "justification": "testing a new version of the product", + "virtualMachines": [ + { + "id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1", + "ports": [{"allowedSourceAddressPrefix": "192.127.0.2", "duration": "PT1H", "number": 3389}], + } + ], + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/InitiateJitNetworkAccessPolicy_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/list_pricings_example.py b/sdk/security/azure-mgmt-security/generated_samples/list_pricings_example.py deleted file mode 100644 index dd7a40416371..000000000000 --- a/sdk/security/azure-mgmt-security/generated_samples/list_pricings_example.py +++ /dev/null @@ -1,38 +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 azure.identity import DefaultAzureCredential -from azure.mgmt.security import SecurityCenter - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-security -# USAGE - python list_pricings_example.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 = SecurityCenter( - credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", - ) - - response = client.pricings.list() - print(response) - - -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/ListPricings_example.json -if __name__ == "__main__": - main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/locations/get_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/locations/get_location_example.py new file mode 100644 index 000000000000..7b2bf8eeee19 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/locations/get_location_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.locations.get( + asc_location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Locations/GetLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/locations/get_locations_example.py b/sdk/security/azure-mgmt-security/generated_samples/locations/get_locations_example.py new file mode 100644 index 000000000000..de97b70bd0b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/locations/get_locations_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_locations_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.locations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Locations/GetLocations_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/mde_onboardings/get_mde_onboardings_example.py b/sdk/security/azure-mgmt-security/generated_samples/mde_onboardings/get_mde_onboardings_example.py new file mode 100644 index 000000000000..51bfaedee672 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/mde_onboardings/get_mde_onboardings_example.py @@ -0,0 +1,40 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_mde_onboardings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.mde_onboardings.get() + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-10-01-preview/examples/MdeOnboardings/GetMdeOnboardings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/mde_onboardings/list_mde_onboardings_example.py b/sdk/security/azure-mgmt-security/generated_samples/mde_onboardings/list_mde_onboardings_example.py new file mode 100644 index 000000000000..bbd14099b418 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/mde_onboardings/list_mde_onboardings_example.py @@ -0,0 +1,40 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_mde_onboardings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.mde_onboardings.list() + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-10-01-preview/examples/MdeOnboardings/ListMdeOnboardings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/operations/list_operations_example.py b/sdk/security/azure-mgmt-security/generated_samples/operations/list_operations_example.py new file mode 100644 index 000000000000..1ad19dbced1a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/operations/list_operations_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_operations_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-05-04-preview/examples/Operations/ListOperations_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/delete_resource_pricing_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/delete_resource_pricing_example.py new file mode 100644 index 000000000000..0a6cb16d8c4d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/delete_resource_pricing_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_resource_pricing_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.pricings.delete( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/DEMO/providers/Microsoft.Compute/virtualMachines/VM-1", + pricing_name="VirtualMachines", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/DeleteResourcePricing_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_cloud_posture_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_cloud_posture_example.py index 8017397a433d..437bce772428 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_cloud_posture_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_cloud_posture_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.security import SecurityCenter """ @@ -26,15 +28,16 @@ def main(): client = SecurityCenter( credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + subscription_id="SUBSCRIPTION_ID", ) response = client.pricings.get( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", pricing_name="CloudPosture", ) print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameCloudPosture_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/GetPricingByNameCloudPosture_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_containers_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_containers_example.py index ce6d86c97096..08775b1dda22 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_containers_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_containers_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.security import SecurityCenter """ @@ -26,15 +28,16 @@ def main(): client = SecurityCenter( credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + subscription_id="SUBSCRIPTION_ID", ) response = client.pricings.get( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", pricing_name="Containers", ) print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameContainers_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/GetPricingByNameContainers_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_dns_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_dns_example.py index 2e11fb0479eb..d131c835a2fa 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_dns_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_dns_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.security import SecurityCenter """ @@ -26,15 +28,16 @@ def main(): client = SecurityCenter( credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + subscription_id="SUBSCRIPTION_ID", ) response = client.pricings.get( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", pricing_name="Dns", ) print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameDns_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/GetPricingByNameDns_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_storage_accounts_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_storage_accounts_example.py index 270278401b8c..afae6062ba22 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_storage_accounts_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_storage_accounts_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.security import SecurityCenter """ @@ -26,15 +28,16 @@ def main(): client = SecurityCenter( credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + subscription_id="SUBSCRIPTION_ID", ) response = client.pricings.get( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", pricing_name="StorageAccounts", ) print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameStorageAccounts_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/GetPricingByNameStorageAccounts_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_virtual_machines_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_virtual_machines_example.py index 8e2dfa237042..ce1a1964dc76 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_virtual_machines_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_virtual_machines_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.security import SecurityCenter """ @@ -26,15 +28,16 @@ def main(): client = SecurityCenter( credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + subscription_id="SUBSCRIPTION_ID", ) response = client.pricings.get( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", pricing_name="VirtualMachines", ) print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_resource_pricing_by_name_virtual_machines_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_resource_pricing_by_name_virtual_machines_example.py new file mode 100644 index 000000000000..3f84638bd8f2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_resource_pricing_by_name_virtual_machines_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_resource_pricing_by_name_virtual_machines_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pricings.get( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/DEMO/providers/Microsoft.Compute/virtualMachines/VM-1", + pricing_name="VirtualMachines", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/GetResourcePricingByNameVirtualMachines_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_example.py index dd7a40416371..bb4e45e3b749 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.security import SecurityCenter """ @@ -26,13 +28,15 @@ def main(): client = SecurityCenter( credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + subscription_id="SUBSCRIPTION_ID", ) - response = client.pricings.list() + response = client.pricings.list( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/ListPricings_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/ListPricings_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_with_plan_filter_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_with_plan_filter_example.py new file mode 100644 index 000000000000..e2a152e7f1b0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_with_plan_filter_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_pricings_with_plan_filter_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pricings.list( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/ListPricingsWithPlanFilter_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/list_resource_pricings_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/list_resource_pricings_example.py new file mode 100644 index 000000000000..74471b5f6acf --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/list_resource_pricings_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_resource_pricings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pricings.list( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/DEMO/providers/Microsoft.Compute/virtualMachines/VM-1", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/ListResourcePricings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_example.py index 031f255e6107..55083dac52f2 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.security import SecurityCenter """ @@ -26,16 +28,17 @@ def main(): client = SecurityCenter( credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + subscription_id="SUBSCRIPTION_ID", ) response = client.pricings.update( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", pricing_name="CloudPosture", pricing={"properties": {"pricingTier": "Standard"}}, ) print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByName_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/PutPricingByName_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_partial_success_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_partial_success_example.py index add40d31d217..3e99d8e75e5d 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_partial_success_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_partial_success_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.security import SecurityCenter """ @@ -26,16 +28,17 @@ def main(): client = SecurityCenter( credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + subscription_id="SUBSCRIPTION_ID", ) response = client.pricings.update( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", pricing_name="CloudPosture", pricing={"properties": {"pricingTier": "Standard"}}, ) print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByNamePartialSuccess_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/PutPricingByNamePartialSuccess_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_vms_by_name_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_vms_by_name_example.py new file mode 100644 index 000000000000..793612594d0a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_vms_by_name_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_pricing_vms_by_name_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pricings.update( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + pricing_name="VirtualMachines", + pricing={"properties": {"enforce": "True", "pricingTier": "Standard", "subPlan": "P2"}}, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/PutPricingVMsByName_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/put_resource_pricing_by_name_virtual_machines_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_resource_pricing_by_name_virtual_machines_example.py new file mode 100644 index 000000000000..ed4ce74a7ace --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_resource_pricing_by_name_virtual_machines_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_resource_pricing_by_name_virtual_machines_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pricings.update( + scope_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/DEMO/providers/Microsoft.Compute/virtualMachines/VM-1", + pricing_name="virtualMachines", + pricing={"properties": {"pricingTier": "Standard", "subPlan": "P1"}}, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-01-01/examples/Pricings/PutResourcePricingByNameVirtualMachines_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/private_links/private_links_list.py b/sdk/security/azure-mgmt-security/generated_samples/private_links/private_links_list.py new file mode 100644 index 000000000000..50e4594cc1f2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/private_links/private_links_list.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python private_links_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.private_links.list( + resource_group_name="rg", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-09-01-preview/examples/PrivateLinks/PrivateLinks_List.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/private_links/private_links_list_by_subscription.py b/sdk/security/azure-mgmt-security/generated_samples/private_links/private_links_list_by_subscription.py new file mode 100644 index 000000000000..a8a1a2b0d80c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/private_links/private_links_list_by_subscription.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python private_links_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.private_links.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2025-09-01-preview/examples/PrivateLinks/PrivateLinks_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/put_pricing_by_name_example.py b/sdk/security/azure-mgmt-security/generated_samples/put_pricing_by_name_example.py deleted file mode 100644 index 031f255e6107..000000000000 --- a/sdk/security/azure-mgmt-security/generated_samples/put_pricing_by_name_example.py +++ /dev/null @@ -1,41 +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 azure.identity import DefaultAzureCredential -from azure.mgmt.security import SecurityCenter - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-security -# USAGE - python put_pricing_by_name_example.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 = SecurityCenter( - credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", - ) - - response = client.pricings.update( - pricing_name="CloudPosture", - pricing={"properties": {"pricingTier": "Standard"}}, - ) - print(response) - - -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByName_example.json -if __name__ == "__main__": - main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/put_pricing_by_name_partial_success_example.py b/sdk/security/azure-mgmt-security/generated_samples/put_pricing_by_name_partial_success_example.py deleted file mode 100644 index add40d31d217..000000000000 --- a/sdk/security/azure-mgmt-security/generated_samples/put_pricing_by_name_partial_success_example.py +++ /dev/null @@ -1,41 +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 azure.identity import DefaultAzureCredential -from azure.mgmt.security import SecurityCenter - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-security -# USAGE - python put_pricing_by_name_partial_success_example.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 = SecurityCenter( - credential=DefaultAzureCredential(), - subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", - ) - - response = client.pricings.update( - pricing_name="CloudPosture", - pricing={"properties": {"pricingTier": "Standard"}}, - ) - print(response) - - -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByNamePartialSuccess_example.json -if __name__ == "__main__": - main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_assessment_example.py b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_assessment_example.py new file mode 100644 index 000000000000..e4f462564dae --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_assessment_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_regulatory_compliance_assessment_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.regulatory_compliance_assessments.get( + regulatory_compliance_standard_name="PCI-DSS-3.2", + regulatory_compliance_control_name="1.1", + regulatory_compliance_assessment_name="968548cb-02b3-8cd2-11f8-0cf64ab1a347", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceAssessment_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_assessment_list_example.py b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_assessment_list_example.py new file mode 100644 index 000000000000..1656464fa38b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_assessment_list_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_regulatory_compliance_assessment_list_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.regulatory_compliance_assessments.list( + regulatory_compliance_standard_name="PCI-DSS-3.2", + regulatory_compliance_control_name="1.1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceAssessmentList_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_control_example.py b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_control_example.py new file mode 100644 index 000000000000..90bf2b6f709f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_control_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_regulatory_compliance_control_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.regulatory_compliance_controls.get( + regulatory_compliance_standard_name="PCI-DSS-3.2", + regulatory_compliance_control_name="1.1", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceControl_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_control_list_example.py b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_control_list_example.py new file mode 100644 index 000000000000..eebee579227b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_control_list_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_regulatory_compliance_control_list_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.regulatory_compliance_controls.list( + regulatory_compliance_standard_name="PCI-DSS-3.2", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceControlList_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_standard_example.py new file mode 100644 index 000000000000..3ea8314c9dd9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_standard_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_regulatory_compliance_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.regulatory_compliance_standards.get( + regulatory_compliance_standard_name="PCI-DSS-3.2", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_standard_list_example.py b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_standard_list_example.py new file mode 100644 index 000000000000..79f20148c1f7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/regulatory_compliance/get_regulatory_compliance_standard_list_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_regulatory_compliance_standard_list_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.regulatory_compliance_standards.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceStandardList_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/secure_score_control_definitions/list_secure_score_control_definitions_example.py b/sdk/security/azure-mgmt-security/generated_samples/secure_score_control_definitions/list_secure_score_control_definitions_example.py new file mode 100644 index 000000000000..61e4176f3b0c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/secure_score_control_definitions/list_secure_score_control_definitions_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_secure_score_control_definitions_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.secure_score_control_definitions.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScoreControlDefinitions/ListSecureScoreControlDefinitions_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/secure_score_control_definitions/list_secure_score_control_definitions_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/secure_score_control_definitions/list_secure_score_control_definitions_subscription_example.py new file mode 100644 index 000000000000..be2c87e57fc8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/secure_score_control_definitions/list_secure_score_control_definitions_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_secure_score_control_definitions_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.secure_score_control_definitions.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScoreControlDefinitions/ListSecureScoreControlDefinitions_subscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/secure_scores/get_secure_scores_single_example.py b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/get_secure_scores_single_example.py new file mode 100644 index 000000000000..cfda9e3e7583 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/get_secure_scores_single_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_secure_scores_single_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.secure_scores.get( + secure_score_name="ascScore", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/GetSecureScoresSingle_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_score_controls_example.py b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_score_controls_example.py new file mode 100644 index 000000000000..c161b647db42 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_score_controls_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_secure_score_controls_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.secure_score_controls.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScoreControls_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_score_controls_for_name_builtin_example.py b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_score_controls_for_name_builtin_example.py new file mode 100644 index 000000000000..d305dd18ed28 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_score_controls_for_name_builtin_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_secure_score_controls_for_name_builtin_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.secure_score_controls.list_by_secure_score( + secure_score_name="ascScore", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScoreControlsForName_builtin_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_score_controls_for_name_with_expand_builtin_example.py b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_score_controls_for_name_with_expand_builtin_example.py new file mode 100644 index 000000000000..edd008d1f7c4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_score_controls_for_name_with_expand_builtin_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_secure_score_controls_for_name_with_expand_builtin_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.secure_score_controls.list_by_secure_score( + secure_score_name="ascScore", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScoreControlsForNameWithExpand_builtin_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_scores_example.py b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_scores_example.py new file mode 100644 index 000000000000..407020cfd897 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/secure_scores/list_secure_scores_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_secure_scores_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.secure_scores.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScores_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors/delete_security_connector_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/delete_security_connector_example.py new file mode 100644 index 000000000000..fe8681f55d7d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/delete_security_connector_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_security_connector_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.security_connectors.delete( + resource_group_name="myRg", + security_connector_name="mySecurityConnectorName", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2024-08-01-preview/examples/SecurityConnectors/DeleteSecurityConnector_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors/get_security_connector_single_resource_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/get_security_connector_single_resource_example.py new file mode 100644 index 000000000000..0b6978479619 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/get_security_connector_single_resource_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_connector_single_resource_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="a5caac9c-5c04-49af-b3d0-e204f40345d5", + ) + + response = client.security_connectors.get( + resource_group_name="exampleResourceGroup", + security_connector_name="exampleSecurityConnectorName", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2024-08-01-preview/examples/SecurityConnectors/GetSecurityConnectorSingleResource_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors/get_security_connectors_resource_group_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/get_security_connectors_resource_group_example.py new file mode 100644 index 000000000000..cd2df5ff6baa --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/get_security_connectors_resource_group_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_connectors_resource_group_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="a5caac9c-5c04-49af-b3d0-e204f40345d5", + ) + + response = client.security_connectors.list_by_resource_group( + resource_group_name="exampleResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2024-08-01-preview/examples/SecurityConnectors/GetSecurityConnectorsResourceGroup_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors/get_security_connectors_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/get_security_connectors_subscription_example.py new file mode 100644 index 000000000000..b89938f20d55 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/get_security_connectors_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_connectors_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="a5caac9c-5c04-49af-b3d0-e204f40345d5", + ) + + response = client.security_connectors.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2024-08-01-preview/examples/SecurityConnectors/GetSecurityConnectorsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors/patch_security_connector_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/patch_security_connector_example.py new file mode 100644 index 000000000000..5c7c732eeb7a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/patch_security_connector_example.py @@ -0,0 +1,59 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python patch_security_connector_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="a5caac9c-5c04-49af-b3d0-e204f40345d5", + ) + + response = client.security_connectors.update( + resource_group_name="exampleResourceGroup", + security_connector_name="exampleSecurityConnectorName", + security_connector={ + "etag": "etag value (must be supplied for update)", + "location": "Central US", + "properties": { + "environmentData": {"environmentType": "AwsAccount"}, + "environmentName": "AWS", + "hierarchyIdentifier": "exampleHierarchyId", + "offerings": [ + { + "nativeCloudConnection": {"cloudRoleArn": "arn:aws:iam::00000000:role/ASCMonitor"}, + "offeringType": "CspmMonitorAws", + } + ], + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2024-08-01-preview/examples/SecurityConnectors/PatchSecurityConnector_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors/put_security_connector_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/put_security_connector_example.py new file mode 100644 index 000000000000..43b78fdf9c02 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors/put_security_connector_example.py @@ -0,0 +1,59 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_security_connector_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="a5caac9c-5c04-49af-b3d0-e204f40345d5", + ) + + response = client.security_connectors.create_or_update( + resource_group_name="exampleResourceGroup", + security_connector_name="exampleSecurityConnectorName", + security_connector={ + "etag": "etag value (must be supplied for update)", + "location": "Central US", + "properties": { + "environmentData": {"environmentType": "AwsAccount", "scanInterval": 4}, + "environmentName": "AWS", + "hierarchyIdentifier": "exampleHierarchyId", + "offerings": [ + { + "nativeCloudConnection": {"cloudRoleArn": "arn:aws:iam::00000000:role/ASCMonitor"}, + "offeringType": "CspmMonitorAws", + } + ], + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2024-08-01-preview/examples/SecurityConnectors/PutSecurityConnector_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_orgs_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_orgs_example.py index 9fbbd258177d..609a3c4652d5 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_orgs_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_orgs_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsOrgs_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsOrgs_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_projects_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_projects_example.py index 5d3caf1d7e12..a88d1c5213ef 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_projects_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_projects_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -44,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsProjects_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsProjects_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_repos_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_repos_example.py index 6f4330bdb841..bc8528da33ec 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_repos_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_azure_dev_ops_repos_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -45,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsRepos_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsRepos_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_current_and_future_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_current_and_future_example.py index a57aeebb3030..c6ea2727a7be 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_current_and_future_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_current_and_future_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardCurrentAndFuture_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardCurrentAndFuture_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_current_only_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_current_only_example.py index 74713ec661fd..ff84896f2318 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_current_only_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_current_only_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardCurrentOnly_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardCurrentOnly_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_selected_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_selected_example.py index 6e3481796ad3..e9e650b25b1c 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_selected_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_onboard_selected_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -46,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardSelected_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardSelected_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_with_agentless_configurations_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_with_agentless_configurations_example.py new file mode 100644 index 000000000000..2c5c730054c7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/create_or_update_dev_ops_configurations_with_agentless_configurations_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_or_update_dev_ops_configurations_with_agentless_configurations_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="0806e1cd-cfda-4ff8-b99c-2b0af42cffd3", + ) + + response = client.dev_ops_configurations.begin_create_or_update( + resource_group_name="myRg", + security_connector_name="mySecurityConnectorName", + dev_ops_configuration={ + "properties": { + "agentlessConfiguration": { + "agentlessAutoDiscovery": "Disabled", + "agentlessEnabled": "Enabled", + "inventoryList": [{"inventoryKind": "AzureDevOpsOrganization", "value": "org1"}], + "inventoryListType": "Inclusion", + "scanners": ["scanner1", "scanner2"], + }, + "authorization": {"code": "00000000000000000000"}, + "autoDiscovery": "Enabled", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsWithAgentlessConfigurations_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/delete_dev_ops_configurations_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/delete_dev_ops_configurations_example.py index 6dc5b1c3b731..3611efb2643d 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/delete_dev_ops_configurations_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/delete_dev_ops_configurations_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/DeleteDevOpsConfigurations_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/DeleteDevOpsConfigurations_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_orgs_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_orgs_example.py index c17491fb751a..117acc1e63c1 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_orgs_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_orgs_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetAzureDevOpsOrgs_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetAzureDevOpsOrgs_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_projects_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_projects_example.py index c368e9a51780..b4971e525861 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_projects_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_projects_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetAzureDevOpsProjects_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetAzureDevOpsProjects_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_repos_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_repos_example.py index fd583291bd48..79f10b84ba02 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_repos_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_azure_dev_ops_repos_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetAzureDevOpsRepos_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetAzureDevOpsRepos_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_example.py index 3cc33135989c..94d61bce651a 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetDevOpsConfigurations_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetDevOpsConfigurations_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_with_agentless_configurations_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_with_agentless_configurations_example.py new file mode 100644 index 000000000000..ee7b8d14f5b2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_with_agentless_configurations_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_dev_ops_configurations_with_agentless_configurations_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="0806e1cd-cfda-4ff8-b99c-2b0af42cffd3", + ) + + response = client.dev_ops_configurations.get( + resource_group_name="myRg", + security_connector_name="mySecurityConnectorName", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetDevOpsConfigurationsWithAgentlessConfigurations_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_with_capabilities_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_with_capabilities_example.py index 1f28c9eae41e..8650ef8e0332 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_with_capabilities_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_configurations_with_capabilities_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetDevOpsConfigurationsWithCapabilities_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetDevOpsConfigurationsWithCapabilities_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_operation_results_failed_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_operation_results_failed_example.py index 6472f0d53aed..ec29f488421a 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_operation_results_failed_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_operation_results_failed_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetDevOpsOperationResultsFailed_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetDevOpsOperationResultsFailed_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_operation_results_succeeded_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_operation_results_succeeded_example.py index 9a884bdb1642..1f3adcde94a0 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_operation_results_succeeded_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_dev_ops_operation_results_succeeded_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetDevOpsOperationResultsSucceeded_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetDevOpsOperationResultsSucceeded_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_hub_owners_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_hub_owners_example.py index 463f181f51e3..577392b1d252 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_hub_owners_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_hub_owners_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetGitHubOwners_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetGitHubOwners_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_hub_repos_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_hub_repos_example.py index 5cb57ab3aa1e..c53233a24f4e 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_hub_repos_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_hub_repos_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetGitHubRepos_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetGitHubRepos_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_lab_groups_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_lab_groups_example.py index 5114c24c0b97..1d4e885abddd 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_lab_groups_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_lab_groups_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetGitLabGroups_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetGitLabGroups_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_lab_projects_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_lab_projects_example.py index 37eff11125da..1845a1032065 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_lab_projects_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/get_git_lab_projects_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/GetGitLabProjects_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/GetGitLabProjects_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_azure_dev_ops_orgs_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_azure_dev_ops_orgs_example.py index 7d498d8ec3f4..3fde78c0b459 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_azure_dev_ops_orgs_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_azure_dev_ops_orgs_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListAvailableAzureDevOpsOrgs_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListAvailableAzureDevOpsOrgs_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_git_hub_owners_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_git_hub_owners_example.py index e5b963768d4b..b6edbd90f9b3 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_git_hub_owners_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_git_hub_owners_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListAvailableGitHubOwners_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListAvailableGitHubOwners_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_git_lab_groups_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_git_lab_groups_example.py index 185388ed7c2c..af89bf662006 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_git_lab_groups_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_available_git_lab_groups_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListAvailableGitLabGroups_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListAvailableGitLabGroups_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_orgs_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_orgs_example.py index a0b7129e2275..e3ea6da5baa6 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_orgs_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_orgs_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListAzureDevOpsOrgs_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListAzureDevOpsOrgs_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_projects_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_projects_example.py index 96ac290992e3..bfad06c620f9 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_projects_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_projects_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListAzureDevOpsProjects_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListAzureDevOpsProjects_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_repos_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_repos_example.py index d24655902e01..17405bec73f5 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_repos_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_azure_dev_ops_repos_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListAzureDevOpsRepos_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListAzureDevOpsRepos_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_dev_ops_configurations_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_dev_ops_configurations_example.py index 4e001f930400..cd3b218ff269 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_dev_ops_configurations_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_dev_ops_configurations_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListDevOpsConfigurations_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListDevOpsConfigurations_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_hub_owners_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_hub_owners_example.py index 9fcd0e80f432..ae016dbf8d3b 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_hub_owners_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_hub_owners_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListGitHubOwners_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListGitHubOwners_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_hub_repos_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_hub_repos_example.py index 66eac2744b61..a66451d839af 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_hub_repos_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_hub_repos_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListGitHubRepos_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListGitHubRepos_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_groups_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_groups_example.py index 05288a8163bc..9071849fb0db 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_groups_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_groups_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListGitLabGroups_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListGitLabGroups_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_projects_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_projects_example.py index cd8f378e0372..9ebb2dddb34a 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_projects_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_projects_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListGitLabProjects_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListGitLabProjects_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_subgroups_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_subgroups_example.py index 557c0cfd324f..d5e4745c9bcf 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_subgroups_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/list_git_lab_subgroups_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/ListGitLabSubgroups_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/ListGitLabSubgroups_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_orgs_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_orgs_example.py index 0b6f93d77d51..761b3d0a2a5e 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_orgs_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_orgs_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/UpdateAzureDevOpsOrgs_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/UpdateAzureDevOpsOrgs_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_projects_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_projects_example.py index 45996194877a..5ecdbc1fd644 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_projects_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_projects_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -44,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/UpdateAzureDevOpsProjects_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/UpdateAzureDevOpsProjects_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_repos_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_repos_example.py index f8d6963089ba..2038bd13d339 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_repos_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_azure_dev_ops_repos_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -45,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/UpdateAzureDevOpsRepos_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/UpdateAzureDevOpsRepos_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_dev_ops_configurations_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_dev_ops_configurations_example.py index 7098b8c472b0..40290a05528f 100644 --- a/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_dev_ops_configurations_example.py +++ b/sdk/security/azure-mgmt-security/generated_samples/security_connectors_dev_ops/update_dev_ops_configurations_example.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.security import SecurityCenter @@ -35,11 +34,22 @@ def main(): response = client.dev_ops_configurations.begin_update( resource_group_name="myRg", security_connector_name="mySecurityConnectorName", - dev_ops_configuration={"properties": {"autoDiscovery": "Enabled"}}, + dev_ops_configuration={ + "properties": { + "agentlessConfiguration": { + "agentlessAutoDiscovery": "Disabled", + "agentlessEnabled": "Enabled", + "inventoryList": [{"inventoryKind": "AzureDevOpsOrganization", "value": "org1"}], + "inventoryListType": "Inclusion", + "scanners": ["scanner1", "scanner2"], + }, + "autoDiscovery": "Enabled", + } + }, ).result() print(response) -# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-04-01/examples/SecurityConnectorsDevOps/UpdateDevOpsConfigurations_example.json +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2025-03-01/examples/SecurityConnectorsDevOps/UpdateDevOpsConfigurations_example.json if __name__ == "__main__": main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_contacts/create_security_contact_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_contacts/create_security_contact_example.py new file mode 100644 index 000000000000..13179a7e18d6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_contacts/create_security_contact_example.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_security_contact_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_contacts.create( + security_contact_name="default", + security_contact={ + "properties": { + "emails": "john@contoso.com;jane@contoso.com", + "isEnabled": True, + "notificationsByRole": {"roles": ["Owner"], "state": "On"}, + "notificationsSources": [ + {"minimalRiskLevel": "Critical", "sourceType": "AttackPath"}, + {"minimalSeverity": "Medium", "sourceType": "Alert"}, + ], + "phone": "(214)275-4038", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-12-01-preview/examples/SecurityContacts/CreateSecurityContact_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_contacts/delete_security_contact_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_contacts/delete_security_contact_example.py new file mode 100644 index 000000000000..faf36517a3b0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_contacts/delete_security_contact_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_security_contact_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.security_contacts.delete( + security_contact_name="default", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-12-01-preview/examples/SecurityContacts/DeleteSecurityContact_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_contacts/get_security_contact_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_contacts/get_security_contact_example.py new file mode 100644 index 000000000000..b629c94f69f4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_contacts/get_security_contact_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_contact_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_contacts.get( + security_contact_name="default", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-12-01-preview/examples/SecurityContacts/GetSecurityContact_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_contacts/get_security_contacts_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_contacts/get_security_contacts_subscription_example.py new file mode 100644 index 000000000000..a8030b2d1387 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_contacts/get_security_contacts_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_contacts_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_contacts.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-12-01-preview/examples/SecurityContacts/GetSecurityContactsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_operators/delete_security_operator_by_name_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_operators/delete_security_operator_by_name_example.py new file mode 100644 index 000000000000..3e1641165ddb --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_operators/delete_security_operator_by_name_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_security_operator_by_name_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.security_operators.delete( + pricing_name="CloudPosture", + security_operator_name="DefenderCSPMSecurityOperator", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/DeleteSecurityOperatorByName_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_operators/get_security_operator_by_name_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_operators/get_security_operator_by_name_example.py new file mode 100644 index 000000000000..8e5f4cd9b276 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_operators/get_security_operator_by_name_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_operator_by_name_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_operators.get( + pricing_name="CloudPosture", + security_operator_name="DefenderCSPMSecurityOperator", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/GetSecurityOperatorByName_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_operators/list_security_operators_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_operators/list_security_operators_example.py new file mode 100644 index 000000000000..ddfca8424dd3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_operators/list_security_operators_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_security_operators_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_operators.list( + pricing_name="CloudPosture", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/ListSecurityOperators_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_operators/put_security_operator_by_name_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_operators/put_security_operator_by_name_example.py new file mode 100644 index 000000000000..ec41edb37312 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_operators/put_security_operator_by_name_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_security_operator_by_name_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_operators.create_or_update( + pricing_name="CloudPosture", + security_operator_name="DefenderCSPMSecurityOperator", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/PutSecurityOperatorByName_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_solutions/get_security_solutions_resource_group_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_solutions/get_security_solutions_resource_group_location_example.py new file mode 100644 index 000000000000..9419072312ac --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_solutions/get_security_solutions_resource_group_location_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_solutions_resource_group_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_solutions.get( + resource_group_name="myRg2", + asc_location="centralus", + security_solution_name="paloalto7", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/SecuritySolutions/GetSecuritySolutionsResourceGroupLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_solutions/get_security_solutions_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_solutions/get_security_solutions_subscription_example.py new file mode 100644 index 000000000000..29fbffedb270 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_solutions/get_security_solutions_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_solutions_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_solutions.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/SecuritySolutions/GetSecuritySolutionsSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_solutions_reference_data/get_security_solutions_reference_data_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_solutions_reference_data/get_security_solutions_reference_data_subscription_example.py new file mode 100644 index 000000000000..2c5426f6da7d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_solutions_reference_data/get_security_solutions_reference_data_subscription_example.py @@ -0,0 +1,40 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_solutions_reference_data_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_solutions_reference_data.list() + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/SecuritySolutionsReferenceData/GetSecuritySolutionsReferenceDataSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_solutions_reference_data/get_security_solutions_reference_data_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_solutions_reference_data/get_security_solutions_reference_data_subscription_location_example.py new file mode 100644 index 000000000000..d6f05f0ff9cd --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_solutions_reference_data/get_security_solutions_reference_data_subscription_location_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_security_solutions_reference_data_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.security_solutions_reference_data.list_by_home_region( + asc_location="westcentralus", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/SecuritySolutionsReferenceData/GetSecuritySolutionsReferenceDataSubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/delete_by_management_group_security_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/delete_by_management_group_security_standard_example.py new file mode 100644 index 000000000000..2fafa94950f5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/delete_by_management_group_security_standard_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_by_management_group_security_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.security_standards.delete( + scope="providers/Microsoft.Management/managementGroups/contoso", + standard_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/DeleteByManagementGroupSecurityStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/delete_by_security_connector_security_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/delete_by_security_connector_security_standard_example.py new file mode 100644 index 000000000000..a7ebe3114361 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/delete_by_security_connector_security_standard_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_by_security_connector_security_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.security_standards.delete( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + standard_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/DeleteBySecurityConnectorSecurityStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/delete_by_subscription_security_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/delete_by_subscription_security_standard_example.py new file mode 100644 index 000000000000..067d53523c89 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/delete_by_subscription_security_standard_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_by_subscription_security_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.security_standards.delete( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + standard_id="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/DeleteBySubscriptionSecurityStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/get_by_management_group_security_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/get_by_management_group_security_standard_example.py new file mode 100644 index 000000000000..a4f9f540b537 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/get_by_management_group_security_standard_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_by_management_group_security_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.security_standards.get( + scope="providers/Microsoft.Management/managementGroups/contoso", + standard_id="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/GetByManagementGroupSecurityStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/get_by_security_connector_security_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/get_by_security_connector_security_standard_example.py new file mode 100644 index 000000000000..8a96cb25d7f5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/get_by_security_connector_security_standard_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_by_security_connector_security_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.security_standards.get( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + standard_id="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/GetBySecurityConnectorSecurityStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/get_by_subscription_security_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/get_by_subscription_security_standard_example.py new file mode 100644 index 000000000000..d2b85c6812e9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/get_by_subscription_security_standard_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_by_subscription_security_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.security_standards.get( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + standard_id="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/GetBySubscriptionSecurityStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/list_by_management_group_security_standards_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/list_by_management_group_security_standards_example.py new file mode 100644 index 000000000000..7a9d96f3ad0d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/list_by_management_group_security_standards_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_management_group_security_standards_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.security_standards.list( + scope="providers/Microsoft.Management/managementGroups/contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/ListByManagementGroupSecurityStandards_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/list_by_security_connector_security_standards_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/list_by_security_connector_security_standards_example.py new file mode 100644 index 000000000000..9afcdc64f57c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/list_by_security_connector_security_standards_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_security_connector_security_standards_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.security_standards.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/ListBySecurityConnectorSecurityStandards_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/list_by_subscription_security_standards_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/list_by_subscription_security_standards_example.py new file mode 100644 index 000000000000..6eee9e338e28 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/list_by_subscription_security_standards_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_subscription_security_standards_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.security_standards.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/ListBySubscriptionSecurityStandards_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/put_by_management_group_security_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/put_by_management_group_security_standard_example.py new file mode 100644 index 000000000000..e34c5e8a3832 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/put_by_management_group_security_standard_example.py @@ -0,0 +1,55 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_by_management_group_security_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.security_standards.create_or_update( + scope="providers/Microsoft.Management/managementGroups/contoso", + standard_id="8bb8be0a-6010-4789-812f-e4d661c4ed0e", + standard={ + "properties": { + "assessments": [ + {"assessmentKey": "1195afff-c881-495e-9bc5-1486211ae03f"}, + {"assessmentKey": "dbd0cb49-b563-45e7-9724-889e799fa648"}, + ], + "cloudProviders": ["GCP"], + "description": "description of Azure Test Security Standard 1", + "displayName": "Azure Test Security Standard 1", + "policySetDefinitionId": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Authorization/policySetDefinitions/patchorchestration-applicationversions", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/PutByManagementGroupSecurityStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/put_by_security_connector_security_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/put_by_security_connector_security_standard_example.py new file mode 100644 index 000000000000..89940620c10f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/put_by_security_connector_security_standard_example.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_by_security_connector_security_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.security_standards.create_or_update( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + standard_id="8bb8be0a-6010-4789-812f-e4d661c4ed0e", + standard={ + "properties": { + "assessments": [ + {"assessmentKey": "1195afff-c881-495e-9bc5-1486211ae03f"}, + {"assessmentKey": "dbd0cb49-b563-45e7-9724-889e799fa648"}, + ], + "cloudProviders": ["GCP"], + "description": "description of Azure Test Security Standard 1", + "displayName": "Azure Test Security Standard 1", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/PutBySecurityConnectorSecurityStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/security_standards/put_by_subscription_security_standard_example.py b/sdk/security/azure-mgmt-security/generated_samples/security_standards/put_by_subscription_security_standard_example.py new file mode 100644 index 000000000000..37d991c651be --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/security_standards/put_by_subscription_security_standard_example.py @@ -0,0 +1,55 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_by_subscription_security_standard_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.security_standards.create_or_update( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + standard_id="8bb8be0a-6010-4789-812f-e4d661c4ed0e", + standard={ + "properties": { + "assessments": [ + {"assessmentKey": "1195afff-c881-495e-9bc5-1486211ae03f"}, + {"assessmentKey": "dbd0cb49-b563-45e7-9724-889e799fa648"}, + ], + "cloudProviders": ["GCP"], + "description": "description of Azure Test Security Standard 1", + "displayName": "Azure Test Security Standard 1", + "policySetDefinitionId": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Authorization/policySetDefinitions/patchorchestration-applicationversions", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/SecurityStandards/PutBySubscriptionSecurityStandard_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sensitivity_settings/get_sensitivity_settings_example.py b/sdk/security/azure-mgmt-security/generated_samples/sensitivity_settings/get_sensitivity_settings_example.py new file mode 100644 index 000000000000..307bf94c6cf4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sensitivity_settings/get_sensitivity_settings_example.py @@ -0,0 +1,40 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_sensitivity_settings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sensitivity_settings.get() + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-15-preview/examples/SensitivitySettings/GetSensitivitySettings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sensitivity_settings/get_sensitivity_settings_list_example.py b/sdk/security/azure-mgmt-security/generated_samples/sensitivity_settings/get_sensitivity_settings_list_example.py new file mode 100644 index 000000000000..f7c783ecc818 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sensitivity_settings/get_sensitivity_settings_list_example.py @@ -0,0 +1,40 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_sensitivity_settings_list_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sensitivity_settings.list() + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-15-preview/examples/SensitivitySettings/GetSensitivitySettingsList_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sensitivity_settings/put_sensitivity_settings_example.py b/sdk/security/azure-mgmt-security/generated_samples/sensitivity_settings/put_sensitivity_settings_example.py new file mode 100644 index 000000000000..77ba6282462d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sensitivity_settings/put_sensitivity_settings_example.py @@ -0,0 +1,50 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_sensitivity_settings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sensitivity_settings.create_or_update( + sensitivity_settings={ + "sensitiveInfoTypesIds": [ + "f2f8a7a1-28c0-404b-9ab4-30a0a7af18cb", + "b452f22b-f87d-4f48-8490-ecf0873325b5", + "d59ee8b6-2618-404b-a5e7-aa377cd67543", + ], + "sensitivityThresholdLabelId": "f2f8a7a1-28c0-404b-9ab4-30a0a7af18cb", + "sensitivityThresholdLabelOrder": 2, + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-15-preview/examples/SensitivitySettings/PutSensitivitySettings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/create_server_vulnerability_assessments_example.py b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/create_server_vulnerability_assessments_example.py new file mode 100644 index 000000000000..bac9bf416aba --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/create_server_vulnerability_assessments_example.py @@ -0,0 +1,45 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_server_vulnerability_assessments_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.server_vulnerability_assessment.create_or_update( + resource_group_name="rg1", + resource_namespace="Microsoft.Compute", + resource_type="virtualMachines", + resource_name="vm1", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/CreateServerVulnerabilityAssessments_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/delete_server_vulnerability_assessments_example.py b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/delete_server_vulnerability_assessments_example.py new file mode 100644 index 000000000000..084ed118c14f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/delete_server_vulnerability_assessments_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_server_vulnerability_assessments_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.server_vulnerability_assessment.begin_delete( + resource_group_name="rg1", + resource_namespace="Microsoft.Compute", + resource_type="virtualMachines", + resource_name="vm1", + ).result() + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/DeleteServerVulnerabilityAssessments_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/get_server_vulnerability_assessments_example.py b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/get_server_vulnerability_assessments_example.py new file mode 100644 index 000000000000..22075042a509 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/get_server_vulnerability_assessments_example.py @@ -0,0 +1,45 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_server_vulnerability_assessments_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.server_vulnerability_assessment.get( + resource_group_name="rg1", + resource_namespace="Microsoft.Compute", + resource_type="virtualMachines", + resource_name="vm1", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/GetServerVulnerabilityAssessments_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/list_by_extended_resource_server_vulnerability_assessments_example.py b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/list_by_extended_resource_server_vulnerability_assessments_example.py new file mode 100644 index 000000000000..653f1c223c1e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments/list_by_extended_resource_server_vulnerability_assessments_example.py @@ -0,0 +1,45 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_extended_resource_server_vulnerability_assessments_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.server_vulnerability_assessment.list_by_extended_resource( + resource_group_name="rg1", + resource_namespace="Microsoft.Compute", + resource_type="virtualMachines", + resource_name="vm1", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/ListByExtendedResourceServerVulnerabilityAssessments_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/delete_server_vulnerability_assessments_setting_example.py b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/delete_server_vulnerability_assessments_setting_example.py new file mode 100644 index 000000000000..e345fc99a8fd --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/delete_server_vulnerability_assessments_setting_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_server_vulnerability_assessments_setting_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.server_vulnerability_assessments_settings.delete( + setting_kind="azureServersSetting", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/DeleteServerVulnerabilityAssessmentsSetting_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/get_server_vulnerability_assessments_setting_example.py b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/get_server_vulnerability_assessments_setting_example.py new file mode 100644 index 000000000000..8c2dfb26f9ca --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/get_server_vulnerability_assessments_setting_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_server_vulnerability_assessments_setting_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.server_vulnerability_assessments_settings.get( + setting_kind="azureServersSetting", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/GetServerVulnerabilityAssessmentsSetting_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/list_server_vulnerability_assessments_settings_example.py b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/list_server_vulnerability_assessments_settings_example.py new file mode 100644 index 000000000000..639248c894ac --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/list_server_vulnerability_assessments_settings_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_server_vulnerability_assessments_settings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.server_vulnerability_assessments_settings.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/ListServerVulnerabilityAssessmentsSettings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/put_server_vulnerability_assessments_setting_example.py b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/put_server_vulnerability_assessments_setting_example.py new file mode 100644 index 000000000000..7b28ccbf0023 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/server_vulnerability_assessments_settings/put_server_vulnerability_assessments_setting_example.py @@ -0,0 +1,46 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_server_vulnerability_assessments_setting_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.server_vulnerability_assessments_settings.create_or_update( + setting_kind="azureServersSetting", + server_vulnerability_assessments_setting={ + "kind": "AzureServersSetting", + "properties": {"selectedProvider": "MdeTvm"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/PutServerVulnerabilityAssessmentsSetting_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/settings/get_setting_example.py b/sdk/security/azure-mgmt-security/generated_samples/settings/get_setting_example.py new file mode 100644 index 000000000000..dbba23658887 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/settings/get_setting_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_setting_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.settings.get( + setting_name="WDATP", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSetting_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/settings/get_settings_example.py b/sdk/security/azure-mgmt-security/generated_samples/settings/get_settings_example.py new file mode 100644 index 000000000000..cc983e75b59b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/settings/get_settings_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_settings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.settings.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSettings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/settings/update_setting_example.py b/sdk/security/azure-mgmt-security/generated_samples/settings/update_setting_example.py new file mode 100644 index 000000000000..5d29470ec142 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/settings/update_setting_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_setting_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.settings.update( + setting_name="WDATP", + setting={"kind": "DataExportSettings", "properties": {"enabled": True}}, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/UpdateSetting_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/software_inventories/get_software_example.py b/sdk/security/azure-mgmt-security/generated_samples/software_inventories/get_software_example.py new file mode 100644 index 000000000000..7ee62c182095 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/software_inventories/get_software_example.py @@ -0,0 +1,46 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_software_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.software_inventories.get( + resource_group_name="EITAN-TESTS", + resource_namespace="Microsoft.Compute", + resource_type="virtualMachines", + resource_name="Eitan-Test1", + software_name="outlook_16.0.10371.20060", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/GetSoftware_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/software_inventories/list_by_extended_resource_software_inventories_example.py b/sdk/security/azure-mgmt-security/generated_samples/software_inventories/list_by_extended_resource_software_inventories_example.py new file mode 100644 index 000000000000..c2108dd3119d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/software_inventories/list_by_extended_resource_software_inventories_example.py @@ -0,0 +1,46 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_extended_resource_software_inventories_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.software_inventories.list_by_extended_resource( + resource_group_name="EITAN-TESTS", + resource_namespace="Microsoft.Compute", + resource_type="virtualMachines", + resource_name="Eitan-Test1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/ListByExtendedResourceSoftwareInventories_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/software_inventories/list_by_subscription_software_inventories_example.py b/sdk/security/azure-mgmt-security/generated_samples/software_inventories/list_by_subscription_software_inventories_example.py new file mode 100644 index 000000000000..b55e4903b782 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/software_inventories/list_by_subscription_software_inventories_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_by_subscription_software_inventories_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="e5d1b86c-3051-44d5-8802-aa65d45a279b", + ) + + response = client.software_inventories.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/ListBySubscriptionSoftwareInventories_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessment_scan_operations/arc_machine_scans_get.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessment_scan_operations/arc_machine_scans_get.py new file mode 100644 index 000000000000..b5463c16c8d7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessment_scan_operations/arc_machine_scans_get.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_scans_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_scans.get( + scan_id="Scheduled-20200623", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessment_scan_operations/arc_machine_scans_get_latest.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessment_scan_operations/arc_machine_scans_get_latest.py new file mode 100644 index 000000000000..7c320ceb60f8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessment_scan_operations/arc_machine_scans_get_latest.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_scans_get_latest.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_scans.get( + scan_id="latest", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_GetLatest.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessment_scan_operations/arc_machine_scans_list.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessment_scan_operations/arc_machine_scans_list.py new file mode 100644 index 000000000000..a0ee845eb3dd --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessment_scan_operations/arc_machine_scans_list.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_scans_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_scans.list( + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_List.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_add.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_add.py new file mode 100644 index 000000000000..c69a82f91931 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_add.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_baseline_rules_add.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_baseline_rules.add( + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Add.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_add_latest.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_add_latest.py new file mode 100644 index 000000000000..ef1125ba7218 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_add_latest.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_baseline_rules_add_latest.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_baseline_rules.add( + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_AddLatest.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_delete.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_delete.py new file mode 100644 index 000000000000..e601a400b8e8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_delete.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_baseline_rules_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.sql_vulnerability_assessment_baseline_rules.delete( + rule_id="VA1234", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_get.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_get.py new file mode 100644 index 000000000000..c7cb0fb709b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_get.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_baseline_rules_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_baseline_rules.get( + rule_id="VA1234", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_list.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_list.py new file mode 100644 index 000000000000..cb48730f9926 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_list.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_baseline_rules_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_baseline_rules.list( + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_List.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_put.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_put.py new file mode 100644 index 000000000000..f6007dc93607 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_put.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_baseline_rules_put.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_baseline_rules.create_or_update( + rule_id="VA1234", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_put_latest.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_put_latest.py new file mode 100644 index 000000000000..32aeb439d00e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_baseline_rule_operations/arc_machine_baseline_rules_put_latest.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_baseline_rules_put_latest.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_baseline_rules.create_or_update( + rule_id="VA1234", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_PutLatest.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_get.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_get.py new file mode 100644 index 000000000000..50c7ac1f0d91 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_get.py @@ -0,0 +1,45 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_scan_results_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_scan_results.get( + scan_id="Scheduled-20200623", + scan_result_id="VA2063", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsScanResultsOperations/ArcMachineScanResults_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_get_latest.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_get_latest.py new file mode 100644 index 000000000000..7b447af16a9f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_get_latest.py @@ -0,0 +1,45 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_scan_results_get_latest.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_scan_results.get( + scan_id="latest", + scan_result_id="VA2063", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsScanResultsOperations/ArcMachineScanResults_GetLatest.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_list.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_list.py new file mode 100644 index 000000000000..91e7ec1a3d15 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_list.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_scan_results_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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_scan_results.list( + scan_id="Scheduled-20200623", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsScanResultsOperations/ArcMachineScanResults_List.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_list_latest.py b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_list_latest.py new file mode 100644 index 000000000000..b8755dfeb1e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sql_vulnerability_assessments_scan_results_operations/arc_machine_scan_results_list_latest.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python arc_machine_scan_results_list_latest.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sql_vulnerability_assessment_scan_results.list( + scan_id="latest", + workspace_id="55555555-6666-7777-8888-999999999999", + resource_id="subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsScanResultsOperations/ArcMachineScanResults_ListLatest.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/delete_standard_assignment.py b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/delete_standard_assignment.py new file mode 100644 index 000000000000..d8079f39e23d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/delete_standard_assignment.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_standard_assignment.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.standard_assignments.delete( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + standard_assignment_name="ad9a8e26-29d9-4829-bb30-e597a58cdbb8", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/StandardAssignments/DeleteStandardAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/get_standard_assignment.py b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/get_standard_assignment.py new file mode 100644 index 000000000000..fd661162a018 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/get_standard_assignment.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_standard_assignment.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.standard_assignments.get( + resource_id="providers/Microsoft.Management/managementGroups/contoso", + standard_assignment_name="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/StandardAssignments/GetStandardAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/list_standard_assignments.py b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/list_standard_assignments.py new file mode 100644 index 000000000000..de98ecb64ff6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/list_standard_assignments.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_standard_assignments.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.standard_assignments.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/StandardAssignments/ListStandardAssignments.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/put_exemption_standard_assignment.py b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/put_exemption_standard_assignment.py new file mode 100644 index 000000000000..ed8486bd4524 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/put_exemption_standard_assignment.py @@ -0,0 +1,58 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_exemption_standard_assignment.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.standard_assignments.create( + resource_id="subscriptions/212f9889-769e-45ae-ab43-6da33674bd26/resourceGroups/ANAT_TEST_RG/providers/Microsoft.Compute/virtualMachines/anatTestE2LA", + standard_assignment_name="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + standard_assignment={ + "properties": { + "assignedStandard": { + "id": "/providers/Microsoft.Security/securityStandards/1f3afdf9-d0c9-4c3d-847f-89da613e70a8" + }, + "description": "Exemption description", + "displayName": "Test exemption", + "effect": "Exempt", + "exemptionData": { + "assignedAssessment": {"assessmentKey": "1195afff-c881-495e-9bc5-1486211ae03f"}, + "exemptionCategory": "waiver", + }, + "expiresOn": "2022-05-01T19:50:47.083633Z", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/StandardAssignments/PutExemptionStandardAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/put_standard_assignment.py b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/put_standard_assignment.py new file mode 100644 index 000000000000..0e9c0831b637 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/standard_assignments/put_standard_assignment.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_standard_assignment.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.standard_assignments.create( + resource_id="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + standard_assignment_name="1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + standard_assignment={ + "properties": { + "assignedStandard": { + "id": "/providers/Microsoft.Security/securityStandards/1f3afdf9-d0c9-4c3d-847f-89da613e70a8" + }, + "description": "Set of policies monitored by Azure Security Center for cross cloud", + "displayName": "ASC Default", + "effect": "Audit", + "excludedScopes": [], + } + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2024-08-01/examples/StandardAssignments/PutStandardAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sub_assessments/get_sub_assessment_example.py b/sdk/security/azure-mgmt-security/generated_samples/sub_assessments/get_sub_assessment_example.py new file mode 100644 index 000000000000..1d8214301d38 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sub_assessments/get_sub_assessment_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_sub_assessment_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sub_assessments.get( + scope="subscriptions/212f9889-769e-45ae-ab43-6da33674bd26/resourceGroups/DEMORG/providers/Microsoft.Compute/virtualMachines/vm2", + assessment_name="1195afff-c881-495e-9bc5-1486211ae03f", + sub_assessment_name="95f7da9c-a2a4-1322-0758-fcd24ef09b85", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/GetSubAssessment_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sub_assessments/list_sub_assessments_example.py b/sdk/security/azure-mgmt-security/generated_samples/sub_assessments/list_sub_assessments_example.py new file mode 100644 index 000000000000..f29cdb4c6a25 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sub_assessments/list_sub_assessments_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_sub_assessments_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sub_assessments.list( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + assessment_name="82e20e14-edc5-4373-bfc4-f13121257c37", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/ListSubAssessments_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/sub_assessments/list_subscription_sub_assessments_example.py b/sdk/security/azure-mgmt-security/generated_samples/sub_assessments/list_subscription_sub_assessments_example.py new file mode 100644 index 000000000000..b9a134ee7f27 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/sub_assessments/list_subscription_sub_assessments_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_subscription_sub_assessments_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sub_assessments.list_all( + scope="subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/ListSubscriptionSubAssessments_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/tasks/get_task_resource_group_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_task_resource_group_location_example.py new file mode 100644 index 000000000000..ac4e1d3a98f2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_task_resource_group_location_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_task_resource_group_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.tasks.get_resource_group_level_task( + resource_group_name="myRg", + asc_location="westeurope", + task_name="d55b4dc0-779c-c66c-33e5-d7bce24c4222", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTaskResourceGroupLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/tasks/get_task_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_task_subscription_location_example.py new file mode 100644 index 000000000000..321027b79721 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_task_subscription_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_task_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.tasks.get_subscription_level_task( + asc_location="westeurope", + task_name="62609ee7-d0a5-8616-9fe4-1df5cca7758d", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTaskSubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/tasks/get_tasks_resource_group_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_tasks_resource_group_location_example.py new file mode 100644 index 000000000000..de9627d6d855 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_tasks_resource_group_location_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_tasks_resource_group_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.tasks.list_by_resource_group( + resource_group_name="myRg", + asc_location="westeurope", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksResourceGroupLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/tasks/get_tasks_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_tasks_subscription_example.py new file mode 100644 index 000000000000..5053a811163c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_tasks_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_tasks_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.tasks.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksSubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/tasks/get_tasks_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_tasks_subscription_location_example.py new file mode 100644 index 000000000000..2cde4fb644f2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/tasks/get_tasks_subscription_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_tasks_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.tasks.list_by_home_region( + asc_location="westeurope", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksSubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/tasks/update_task_resource_group_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/tasks/update_task_resource_group_location_example.py new file mode 100644 index 000000000000..8e3832b6558a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/tasks/update_task_resource_group_location_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_task_resource_group_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.tasks.update_resource_group_level_task_state( + resource_group_name="myRg", + asc_location="westeurope", + task_name="d55b4dc0-779c-c66c-33e5-d7bce24c4222", + task_update_action_type="Dismiss", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/UpdateTaskResourceGroupLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/tasks/update_task_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/tasks/update_task_subscription_location_example.py new file mode 100644 index 000000000000..eaae0f41b8f1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/tasks/update_task_subscription_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_task_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.tasks.update_subscription_level_task_state( + asc_location="westeurope", + task_name="62609ee7-d0a5-8616-9fe4-1df5cca7758d", + task_update_action_type="Dismiss", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/UpdateTaskSubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/topology/get_topology_example.py b/sdk/security/azure-mgmt-security/generated_samples/topology/get_topology_example.py new file mode 100644 index 000000000000..9296a841fe8b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/topology/get_topology_example.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_topology_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3eeab341-f466-499c-a8be-85427e154bad", + ) + + response = client.topology.get( + resource_group_name="myservers", + asc_location="centralus", + topology_resource_name="vnets", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/Topology/GetTopology_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/topology/get_topology_subscription_example.py b/sdk/security/azure-mgmt-security/generated_samples/topology/get_topology_subscription_example.py new file mode 100644 index 000000000000..8528dc4a3b56 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/topology/get_topology_subscription_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_topology_subscription_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3eeab341-f466-499c-a8be-85427e154bad", + ) + + response = client.topology.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/Topology/GetTopologySubscription_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/topology/get_topology_subscription_location_example.py b/sdk/security/azure-mgmt-security/generated_samples/topology/get_topology_subscription_location_example.py new file mode 100644 index 000000000000..0851dcb13f06 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/topology/get_topology_subscription_location_example.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_topology_subscription_location_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="3eeab341-f466-499c-a8be-85427e154bad", + ) + + response = client.topology.list_by_home_region( + asc_location="centralus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/Topology/GetTopologySubscriptionLocation_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/create_workspace_setting_example.py b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/create_workspace_setting_example.py new file mode 100644 index 000000000000..bd23eb305eb1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/create_workspace_setting_example.py @@ -0,0 +1,51 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python create_workspace_setting_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.workspace_settings.create( + workspace_setting_name="default", + workspace_setting={ + "id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/workspaceSettings/default", + "name": "default", + "properties": { + "scope": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + "workspaceId": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace", + }, + "type": "Microsoft.Security/workspaceSettings", + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/CreateWorkspaceSetting_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/delete_workspace_setting_example.py b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/delete_workspace_setting_example.py new file mode 100644 index 000000000000..3d7399f83461 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/delete_workspace_setting_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python delete_workspace_setting_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + client.workspace_settings.delete( + workspace_setting_name="default", + ) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/DeleteWorkspaceSetting_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/get_workspace_setting_example.py b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/get_workspace_setting_example.py new file mode 100644 index 000000000000..b34ff3adf05f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/get_workspace_setting_example.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_workspace_setting_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.workspace_settings.get( + workspace_setting_name="default", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/GetWorkspaceSetting_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/get_workspace_settings_example.py b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/get_workspace_settings_example.py new file mode 100644 index 000000000000..14e4ee89da17 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/get_workspace_settings_example.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_workspace_settings_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.workspace_settings.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/GetWorkspaceSettings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/update_workspace_setting_example.py b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/update_workspace_setting_example.py new file mode 100644 index 000000000000..c9da3f9c3cbf --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/workspace_settings/update_workspace_setting_example.py @@ -0,0 +1,50 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python update_workspace_setting_example.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 = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.workspace_settings.update( + workspace_setting_name="default", + workspace_setting={ + "id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/workspaceSettings/default", + "name": "default", + "properties": { + "workspaceId": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace" + }, + "type": "Microsoft.Security/workspaceSettings", + }, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/UpdateWorkspaceSetting_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_tests/conftest.py b/sdk/security/azure-mgmt-security/generated_tests/conftest.py new file mode 100644 index 000000000000..597418983477 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + securitycenter_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + securitycenter_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + securitycenter_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + securitycenter_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=securitycenter_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=securitycenter_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=securitycenter_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=securitycenter_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_advanced_threat_protection_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_advanced_threat_protection_operations.py new file mode 100644 index 000000000000..a9273462c31d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_advanced_threat_protection_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAdvancedThreatProtectionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_advanced_threat_protection_get(self, resource_group): + response = self.client.advanced_threat_protection.get( + resource_id="str", + api_version="2019-01-01", + setting_name="current", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_advanced_threat_protection_create(self, resource_group): + response = self.client.advanced_threat_protection.create( + resource_id="str", + advanced_threat_protection_setting={"id": "str", "isEnabled": bool, "name": "str", "type": "str"}, + api_version="2019-01-01", + setting_name="current", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_advanced_threat_protection_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_advanced_threat_protection_operations_async.py new file mode 100644 index 000000000000..fd3ff38edd7b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_advanced_threat_protection_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAdvancedThreatProtectionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_advanced_threat_protection_get(self, resource_group): + response = await self.client.advanced_threat_protection.get( + resource_id="str", + api_version="2019-01-01", + setting_name="current", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_advanced_threat_protection_create(self, resource_group): + response = await self.client.advanced_threat_protection.create( + resource_id="str", + advanced_threat_protection_setting={"id": "str", "isEnabled": bool, "name": "str", "type": "str"}, + api_version="2019-01-01", + setting_name="current", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_operations.py new file mode 100644 index 000000000000..8ea72fd60eb2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_operations.py @@ -0,0 +1,200 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAlertsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_list(self, resource_group): + response = self.client.alerts.list( + api_version="2022-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_alerts_list_by_resource_group(self, resource_group): + response = self.client.alerts.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2022-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_alerts_list_subscription_level_by_region(self, resource_group): + response = self.client.alerts.list_subscription_level_by_region( + asc_location="str", + api_version="2022-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_alerts_list_resource_group_level_by_region(self, resource_group): + response = self.client.alerts.list_resource_group_level_by_region( + asc_location="str", + resource_group_name=resource_group.name, + api_version="2022-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_alerts_get_subscription_level(self, resource_group): + response = self.client.alerts.get_subscription_level( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_get_resource_group_level(self, resource_group): + response = self.client.alerts.get_resource_group_level( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_update_subscription_level_state_to_dismiss(self, resource_group): + response = self.client.alerts.update_subscription_level_state_to_dismiss( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_update_subscription_level_state_to_resolve(self, resource_group): + response = self.client.alerts.update_subscription_level_state_to_resolve( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_update_subscription_level_state_to_activate(self, resource_group): + response = self.client.alerts.update_subscription_level_state_to_activate( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_update_subscription_level_state_to_in_progress(self, resource_group): + response = self.client.alerts.update_subscription_level_state_to_in_progress( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_update_resource_group_level_state_to_resolve(self, resource_group): + response = self.client.alerts.update_resource_group_level_state_to_resolve( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_update_resource_group_level_state_to_dismiss(self, resource_group): + response = self.client.alerts.update_resource_group_level_state_to_dismiss( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_update_resource_group_level_state_to_activate(self, resource_group): + response = self.client.alerts.update_resource_group_level_state_to_activate( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_update_resource_group_level_state_to_in_progress(self, resource_group): + response = self.client.alerts.update_resource_group_level_state_to_in_progress( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_begin_simulate(self, resource_group): + response = self.client.alerts.begin_simulate( + asc_location="str", + alert_simulator_request_body={"properties": "alert_simulator_request_properties"}, + api_version="2022-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_operations_async.py new file mode 100644 index 000000000000..b2b8e3d21e75 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_operations_async.py @@ -0,0 +1,203 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAlertsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_list(self, resource_group): + response = self.client.alerts.list( + api_version="2022-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_alerts_list_by_resource_group(self, resource_group): + response = self.client.alerts.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2022-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_alerts_list_subscription_level_by_region(self, resource_group): + response = self.client.alerts.list_subscription_level_by_region( + asc_location="str", + api_version="2022-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_alerts_list_resource_group_level_by_region(self, resource_group): + response = self.client.alerts.list_resource_group_level_by_region( + asc_location="str", + resource_group_name=resource_group.name, + api_version="2022-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_alerts_get_subscription_level(self, resource_group): + response = await self.client.alerts.get_subscription_level( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_get_resource_group_level(self, resource_group): + response = await self.client.alerts.get_resource_group_level( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_update_subscription_level_state_to_dismiss(self, resource_group): + response = await self.client.alerts.update_subscription_level_state_to_dismiss( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_update_subscription_level_state_to_resolve(self, resource_group): + response = await self.client.alerts.update_subscription_level_state_to_resolve( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_update_subscription_level_state_to_activate(self, resource_group): + response = await self.client.alerts.update_subscription_level_state_to_activate( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_update_subscription_level_state_to_in_progress(self, resource_group): + response = await self.client.alerts.update_subscription_level_state_to_in_progress( + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_update_resource_group_level_state_to_resolve(self, resource_group): + response = await self.client.alerts.update_resource_group_level_state_to_resolve( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_update_resource_group_level_state_to_dismiss(self, resource_group): + response = await self.client.alerts.update_resource_group_level_state_to_dismiss( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_update_resource_group_level_state_to_activate(self, resource_group): + response = await self.client.alerts.update_resource_group_level_state_to_activate( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_update_resource_group_level_state_to_in_progress(self, resource_group): + response = await self.client.alerts.update_resource_group_level_state_to_in_progress( + resource_group_name=resource_group.name, + asc_location="str", + alert_name="str", + api_version="2022-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_begin_simulate(self, resource_group): + response = await ( + await self.client.alerts.begin_simulate( + asc_location="str", + alert_simulator_request_body={"properties": "alert_simulator_request_properties"}, + api_version="2022-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_suppression_rules_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_suppression_rules_operations.py new file mode 100644 index 000000000000..df3490905e61 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_suppression_rules_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAlertsSuppressionRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_suppression_rules_list(self, resource_group): + response = self.client.alerts_suppression_rules.list( + api_version="2019-01-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_suppression_rules_get(self, resource_group): + response = self.client.alerts_suppression_rules.get( + alerts_suppression_rule_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_suppression_rules_update(self, resource_group): + response = self.client.alerts_suppression_rules.update( + alerts_suppression_rule_name="str", + alerts_suppression_rule={ + "alertType": "str", + "comment": "str", + "expirationDateUtc": "2020-02-20 00:00:00", + "id": "str", + "lastModifiedUtc": "2020-02-20 00:00:00", + "name": "str", + "reason": "str", + "state": "str", + "suppressionAlertsScope": {"allOf": [{"field": "str"}]}, + "type": "str", + }, + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_suppression_rules_delete(self, resource_group): + response = self.client.alerts_suppression_rules.delete( + alerts_suppression_rule_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_suppression_rules_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_suppression_rules_operations_async.py new file mode 100644 index 000000000000..5c877335b7be --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_alerts_suppression_rules_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAlertsSuppressionRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_suppression_rules_list(self, resource_group): + response = self.client.alerts_suppression_rules.list( + api_version="2019-01-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_suppression_rules_get(self, resource_group): + response = await self.client.alerts_suppression_rules.get( + alerts_suppression_rule_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_suppression_rules_update(self, resource_group): + response = await self.client.alerts_suppression_rules.update( + alerts_suppression_rule_name="str", + alerts_suppression_rule={ + "alertType": "str", + "comment": "str", + "expirationDateUtc": "2020-02-20 00:00:00", + "id": "str", + "lastModifiedUtc": "2020-02-20 00:00:00", + "name": "str", + "reason": "str", + "state": "str", + "suppressionAlertsScope": {"allOf": [{"field": "str"}]}, + "type": "str", + }, + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_suppression_rules_delete(self, resource_group): + response = await self.client.alerts_suppression_rules.delete( + alerts_suppression_rule_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_allowed_connections_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_allowed_connections_operations.py new file mode 100644 index 000000000000..538d4ad52922 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_allowed_connections_operations.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAllowedConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_allowed_connections_list(self, resource_group): + response = self.client.allowed_connections.list( + api_version="2020-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_allowed_connections_list_by_home_region(self, resource_group): + response = self.client.allowed_connections.list_by_home_region( + asc_location="str", + api_version="2020-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_allowed_connections_get(self, resource_group): + response = self.client.allowed_connections.get( + resource_group_name=resource_group.name, + asc_location="str", + connection_type="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_allowed_connections_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_allowed_connections_operations_async.py new file mode 100644 index 000000000000..e8a944b4f9c5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_allowed_connections_operations_async.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAllowedConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_allowed_connections_list(self, resource_group): + response = self.client.allowed_connections.list( + api_version="2020-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_allowed_connections_list_by_home_region(self, resource_group): + response = self.client.allowed_connections.list_by_home_region( + asc_location="str", + api_version="2020-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_allowed_connections_get(self, resource_group): + response = await self.client.allowed_connections.get( + resource_group_name=resource_group.name, + asc_location="str", + connection_type="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_api_collections_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_api_collections_operations.py new file mode 100644 index 000000000000..52bd83ff10fe --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_api_collections_operations.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAPICollectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_collections_list_by_subscription(self, resource_group): + response = self.client.api_collections.list_by_subscription( + api_version="2023-11-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_collections_list_by_resource_group(self, resource_group): + response = self.client.api_collections.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-11-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_collections_list_by_azure_api_management_service(self, resource_group): + response = self.client.api_collections.list_by_azure_api_management_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2023-11-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_collections_get_by_azure_api_management_service(self, resource_group): + response = self.client.api_collections.get_by_azure_api_management_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2023-11-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_collections_begin_onboard_azure_api_management_api(self, resource_group): + response = self.client.api_collections.begin_onboard_azure_api_management_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2023-11-15", + ).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_api_collections_offboard_azure_api_management_api(self, resource_group): + response = self.client.api_collections.offboard_azure_api_management_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2023-11-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_api_collections_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_api_collections_operations_async.py new file mode 100644 index 000000000000..0d92c9c42d70 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_api_collections_operations_async.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAPICollectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_collections_list_by_subscription(self, resource_group): + response = self.client.api_collections.list_by_subscription( + api_version="2023-11-15", + ) + 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_api_collections_list_by_resource_group(self, resource_group): + response = self.client.api_collections.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-11-15", + ) + 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_api_collections_list_by_azure_api_management_service(self, resource_group): + response = self.client.api_collections.list_by_azure_api_management_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2023-11-15", + ) + 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_api_collections_get_by_azure_api_management_service(self, resource_group): + response = await self.client.api_collections.get_by_azure_api_management_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2023-11-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_collections_begin_onboard_azure_api_management_api(self, resource_group): + response = await ( + await self.client.api_collections.begin_onboard_azure_api_management_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2023-11-15", + ) + ).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_api_collections_offboard_azure_api_management_api(self, resource_group): + response = await self.client.api_collections.offboard_azure_api_management_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2023-11-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_application_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_application_operations.py new file mode 100644 index 000000000000..a0ac52274b8b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_application_operations.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterApplicationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_get(self, resource_group): + response = self.client.application.get( + application_id="str", + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_create_or_update(self, resource_group): + response = self.client.application.create_or_update( + application_id="str", + application={ + "conditionSets": [{}], + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "sourceResourceType": "str", + "type": "str", + }, + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_delete(self, resource_group): + response = self.client.application.delete( + application_id="str", + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_application_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_application_operations_async.py new file mode 100644 index 000000000000..3b3908d0c958 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_application_operations_async.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterApplicationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_get(self, resource_group): + response = await self.client.application.get( + application_id="str", + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_create_or_update(self, resource_group): + response = await self.client.application.create_or_update( + application_id="str", + application={ + "conditionSets": [{}], + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "sourceResourceType": "str", + "type": "str", + }, + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_delete(self, resource_group): + response = await self.client.application.delete( + application_id="str", + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_applications_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_applications_operations.py new file mode 100644 index 000000000000..aae3d266da10 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_applications_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterApplicationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_list(self, resource_group): + response = self.client.applications.list( + api_version="2022-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_applications_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_applications_operations_async.py new file mode 100644 index 000000000000..c0b6d9cf6a75 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_applications_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterApplicationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_list(self, resource_group): + response = self.client.applications.list( + api_version="2022-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_metadata_operations.py new file mode 100644 index 000000000000..3b63a91c96f4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_metadata_operations.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAssessmentsMetadataOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_metadata_list(self, resource_group): + response = self.client.assessments_metadata.list( + api_version="2025-05-04-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_metadata_get(self, resource_group): + response = self.client.assessments_metadata.get( + assessment_metadata_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_metadata_list_by_subscription(self, resource_group): + response = self.client.assessments_metadata.list_by_subscription( + api_version="2025-05-04-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_metadata_get_in_subscription(self, resource_group): + response = self.client.assessments_metadata.get_in_subscription( + assessment_metadata_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_metadata_create_in_subscription(self, resource_group): + response = self.client.assessments_metadata.create_in_subscription( + assessment_metadata_name="str", + assessment_metadata={ + "assessmentType": "str", + "categories": ["str"], + "description": "str", + "displayName": "str", + "id": "str", + "implementationEffort": "str", + "name": "str", + "partnerData": {"partnerName": "str", "secret": "str", "productName": "str"}, + "plannedDeprecationDate": "str", + "policyDefinitionId": "str", + "preview": bool, + "publishDates": {"public": "str", "GA": "str"}, + "remediationDescription": "str", + "severity": "str", + "tactics": ["str"], + "techniques": ["str"], + "threats": ["str"], + "type": "str", + "userImpact": "str", + }, + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_metadata_delete_in_subscription(self, resource_group): + response = self.client.assessments_metadata.delete_in_subscription( + assessment_metadata_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_metadata_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_metadata_operations_async.py new file mode 100644 index 000000000000..46c7fc1de5de --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_metadata_operations_async.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAssessmentsMetadataOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_metadata_list(self, resource_group): + response = self.client.assessments_metadata.list( + api_version="2025-05-04-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_metadata_get(self, resource_group): + response = await self.client.assessments_metadata.get( + assessment_metadata_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_metadata_list_by_subscription(self, resource_group): + response = self.client.assessments_metadata.list_by_subscription( + api_version="2025-05-04-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_metadata_get_in_subscription(self, resource_group): + response = await self.client.assessments_metadata.get_in_subscription( + assessment_metadata_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_metadata_create_in_subscription(self, resource_group): + response = await self.client.assessments_metadata.create_in_subscription( + assessment_metadata_name="str", + assessment_metadata={ + "assessmentType": "str", + "categories": ["str"], + "description": "str", + "displayName": "str", + "id": "str", + "implementationEffort": "str", + "name": "str", + "partnerData": {"partnerName": "str", "secret": "str", "productName": "str"}, + "plannedDeprecationDate": "str", + "policyDefinitionId": "str", + "preview": bool, + "publishDates": {"public": "str", "GA": "str"}, + "remediationDescription": "str", + "severity": "str", + "tactics": ["str"], + "techniques": ["str"], + "threats": ["str"], + "type": "str", + "userImpact": "str", + }, + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_metadata_delete_in_subscription(self, resource_group): + response = await self.client.assessments_metadata.delete_in_subscription( + assessment_metadata_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_operations.py new file mode 100644 index 000000000000..1985fb63a10b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_operations.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAssessmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_list(self, resource_group): + response = self.client.assessments.list( + scope="str", + api_version="2025-05-04-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_get(self, resource_group): + response = self.client.assessments.get( + resource_id="str", + assessment_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_create_or_update(self, resource_group): + response = self.client.assessments.create_or_update( + resource_id="str", + assessment_name="str", + assessment={ + "additionalData": {"str": "str"}, + "displayName": "str", + "id": "str", + "links": {"azurePortalUri": "str"}, + "metadata": { + "assessmentType": "str", + "displayName": "str", + "severity": "str", + "categories": ["str"], + "description": "str", + "implementationEffort": "str", + "partnerData": {"partnerName": "str", "secret": "str", "productName": "str"}, + "policyDefinitionId": "str", + "preview": bool, + "remediationDescription": "str", + "threats": ["str"], + "userImpact": "str", + }, + "name": "str", + "partnersData": {"partnerName": "str", "secret": "str"}, + "resourceDetails": "resource_details", + "risk": { + "attackPathsReferences": ["str"], + "isContextualRisk": bool, + "level": "str", + "paths": [ + { + "edges": [{"id": "str", "sourceId": "str", "targetId": "str"}], + "id": "str", + "nodes": [{"id": "str", "nodePropertiesLabel": ["str"]}], + } + ], + "riskFactors": ["str"], + }, + "status": {"code": "str", "cause": "str", "description": "str"}, + "type": "str", + }, + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assessments_delete(self, resource_group): + response = self.client.assessments.delete( + resource_id="str", + assessment_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_operations_async.py new file mode 100644 index 000000000000..1ff1179f8114 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_assessments_operations_async.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAssessmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_list(self, resource_group): + response = self.client.assessments.list( + scope="str", + api_version="2025-05-04-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_get(self, resource_group): + response = await self.client.assessments.get( + resource_id="str", + assessment_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_create_or_update(self, resource_group): + response = await self.client.assessments.create_or_update( + resource_id="str", + assessment_name="str", + assessment={ + "additionalData": {"str": "str"}, + "displayName": "str", + "id": "str", + "links": {"azurePortalUri": "str"}, + "metadata": { + "assessmentType": "str", + "displayName": "str", + "severity": "str", + "categories": ["str"], + "description": "str", + "implementationEffort": "str", + "partnerData": {"partnerName": "str", "secret": "str", "productName": "str"}, + "policyDefinitionId": "str", + "preview": bool, + "remediationDescription": "str", + "threats": ["str"], + "userImpact": "str", + }, + "name": "str", + "partnersData": {"partnerName": "str", "secret": "str"}, + "resourceDetails": "resource_details", + "risk": { + "attackPathsReferences": ["str"], + "isContextualRisk": bool, + "level": "str", + "paths": [ + { + "edges": [{"id": "str", "sourceId": "str", "targetId": "str"}], + "id": "str", + "nodes": [{"id": "str", "nodePropertiesLabel": ["str"]}], + } + ], + "riskFactors": ["str"], + }, + "status": {"code": "str", "cause": "str", "description": "str"}, + "type": "str", + }, + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assessments_delete(self, resource_group): + response = await self.client.assessments.delete( + resource_id="str", + assessment_name="str", + api_version="2025-05-04-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_auto_provisioning_settings_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_auto_provisioning_settings_operations.py new file mode 100644 index 000000000000..a2c0ca5163eb --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_auto_provisioning_settings_operations.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAutoProvisioningSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_auto_provisioning_settings_list(self, resource_group): + response = self.client.auto_provisioning_settings.list( + api_version="2017-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_auto_provisioning_settings_get(self, resource_group): + response = self.client.auto_provisioning_settings.get( + setting_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_auto_provisioning_settings_create(self, resource_group): + response = self.client.auto_provisioning_settings.create( + setting_name="str", + setting={"autoProvision": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_auto_provisioning_settings_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_auto_provisioning_settings_operations_async.py new file mode 100644 index 000000000000..bd4d89f5ac85 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_auto_provisioning_settings_operations_async.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAutoProvisioningSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_auto_provisioning_settings_list(self, resource_group): + response = self.client.auto_provisioning_settings.list( + api_version="2017-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_auto_provisioning_settings_get(self, resource_group): + response = await self.client.auto_provisioning_settings.get( + setting_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_auto_provisioning_settings_create(self, resource_group): + response = await self.client.auto_provisioning_settings.create( + setting_name="str", + setting={"autoProvision": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_automations_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_automations_operations.py new file mode 100644 index 000000000000..4ed80824b7ee --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_automations_operations.py @@ -0,0 +1,184 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAutomationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automations_list(self, resource_group): + response = self.client.automations.list( + api_version="2023-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automations_list_by_resource_group(self, resource_group): + response = self.client.automations.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automations_get(self, resource_group): + response = self.client.automations.get( + resource_group_name=resource_group.name, + automation_name="str", + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automations_create_or_update(self, resource_group): + response = self.client.automations.create_or_update( + resource_group_name=resource_group.name, + automation_name="str", + automation={ + "actions": ["automation_action"], + "description": "str", + "etag": "str", + "id": "str", + "isEnabled": bool, + "kind": "str", + "location": "str", + "name": "str", + "scopes": [{"description": "str", "scopePath": "str"}], + "sources": [ + { + "eventSource": "str", + "ruleSets": [ + { + "rules": [ + { + "expectedValue": "str", + "operator": "str", + "propertyJPath": "str", + "propertyType": "str", + } + ] + } + ], + } + ], + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automations_update(self, resource_group): + response = self.client.automations.update( + resource_group_name=resource_group.name, + automation_name="str", + automation={ + "actions": ["automation_action"], + "description": "str", + "isEnabled": bool, + "scopes": [{"description": "str", "scopePath": "str"}], + "sources": [ + { + "eventSource": "str", + "ruleSets": [ + { + "rules": [ + { + "expectedValue": "str", + "operator": "str", + "propertyJPath": "str", + "propertyType": "str", + } + ] + } + ], + } + ], + "tags": {"str": "str"}, + }, + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automations_delete(self, resource_group): + response = self.client.automations.delete( + resource_group_name=resource_group.name, + automation_name="str", + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automations_validate(self, resource_group): + response = self.client.automations.validate( + resource_group_name=resource_group.name, + automation_name="str", + automation={ + "actions": ["automation_action"], + "description": "str", + "etag": "str", + "id": "str", + "isEnabled": bool, + "kind": "str", + "location": "str", + "name": "str", + "scopes": [{"description": "str", "scopePath": "str"}], + "sources": [ + { + "eventSource": "str", + "ruleSets": [ + { + "rules": [ + { + "expectedValue": "str", + "operator": "str", + "propertyJPath": "str", + "propertyType": "str", + } + ] + } + ], + } + ], + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_automations_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_automations_operations_async.py new file mode 100644 index 000000000000..f8e5cc45e2bf --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_automations_operations_async.py @@ -0,0 +1,185 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAutomationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automations_list(self, resource_group): + response = self.client.automations.list( + api_version="2023-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automations_list_by_resource_group(self, resource_group): + response = self.client.automations.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automations_get(self, resource_group): + response = await self.client.automations.get( + resource_group_name=resource_group.name, + automation_name="str", + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automations_create_or_update(self, resource_group): + response = await self.client.automations.create_or_update( + resource_group_name=resource_group.name, + automation_name="str", + automation={ + "actions": ["automation_action"], + "description": "str", + "etag": "str", + "id": "str", + "isEnabled": bool, + "kind": "str", + "location": "str", + "name": "str", + "scopes": [{"description": "str", "scopePath": "str"}], + "sources": [ + { + "eventSource": "str", + "ruleSets": [ + { + "rules": [ + { + "expectedValue": "str", + "operator": "str", + "propertyJPath": "str", + "propertyType": "str", + } + ] + } + ], + } + ], + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automations_update(self, resource_group): + response = await self.client.automations.update( + resource_group_name=resource_group.name, + automation_name="str", + automation={ + "actions": ["automation_action"], + "description": "str", + "isEnabled": bool, + "scopes": [{"description": "str", "scopePath": "str"}], + "sources": [ + { + "eventSource": "str", + "ruleSets": [ + { + "rules": [ + { + "expectedValue": "str", + "operator": "str", + "propertyJPath": "str", + "propertyType": "str", + } + ] + } + ], + } + ], + "tags": {"str": "str"}, + }, + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automations_delete(self, resource_group): + response = await self.client.automations.delete( + resource_group_name=resource_group.name, + automation_name="str", + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automations_validate(self, resource_group): + response = await self.client.automations.validate( + resource_group_name=resource_group.name, + automation_name="str", + automation={ + "actions": ["automation_action"], + "description": "str", + "etag": "str", + "id": "str", + "isEnabled": bool, + "kind": "str", + "location": "str", + "name": "str", + "scopes": [{"description": "str", "scopePath": "str"}], + "sources": [ + { + "eventSource": "str", + "ruleSets": [ + { + "rules": [ + { + "expectedValue": "str", + "operator": "str", + "propertyJPath": "str", + "propertyType": "str", + } + ] + } + ], + } + ], + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_orgs_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_orgs_operations.py new file mode 100644 index 000000000000..242f29a874fd --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_orgs_operations.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAzureDevOpsOrgsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_orgs_list_available(self, resource_group): + response = self.client.azure_dev_ops_orgs.list_available( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_orgs_list(self, resource_group): + response = self.client.azure_dev_ops_orgs.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_orgs_get(self, resource_group): + response = self.client.azure_dev_ops_orgs.get( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_orgs_begin_create_or_update(self, resource_group): + response = self.client.azure_dev_ops_orgs.begin_create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + azure_dev_ops_org={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_azure_dev_ops_orgs_begin_update(self, resource_group): + response = self.client.azure_dev_ops_orgs.begin_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + azure_dev_ops_org={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_orgs_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_orgs_operations_async.py new file mode 100644 index 000000000000..e44b7fdc7664 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_orgs_operations_async.py @@ -0,0 +1,137 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAzureDevOpsOrgsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_dev_ops_orgs_list_available(self, resource_group): + response = await self.client.azure_dev_ops_orgs.list_available( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_dev_ops_orgs_list(self, resource_group): + response = self.client.azure_dev_ops_orgs.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-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_azure_dev_ops_orgs_get(self, resource_group): + response = await self.client.azure_dev_ops_orgs.get( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_dev_ops_orgs_begin_create_or_update(self, resource_group): + response = await ( + await self.client.azure_dev_ops_orgs.begin_create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + azure_dev_ops_org={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_azure_dev_ops_orgs_begin_update(self, resource_group): + response = await ( + await self.client.azure_dev_ops_orgs.begin_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + azure_dev_ops_org={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_projects_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_projects_operations.py new file mode 100644 index 000000000000..99fdc6aa1546 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_projects_operations.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAzureDevOpsProjectsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_projects_list(self, resource_group): + response = self.client.azure_dev_ops_projects.list( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_projects_get(self, resource_group): + response = self.client.azure_dev_ops_projects.get( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_projects_begin_create_or_update(self, resource_group): + response = self.client.azure_dev_ops_projects.begin_create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + azure_dev_ops_project={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "parentOrgName": "str", + "projectId": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_azure_dev_ops_projects_begin_update(self, resource_group): + response = self.client.azure_dev_ops_projects.begin_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + azure_dev_ops_project={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "parentOrgName": "str", + "projectId": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_projects_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_projects_operations_async.py new file mode 100644 index 000000000000..35e9318095c5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_projects_operations_async.py @@ -0,0 +1,133 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAzureDevOpsProjectsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_dev_ops_projects_list(self, resource_group): + response = self.client.azure_dev_ops_projects.list( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + api_version="2025-03-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_azure_dev_ops_projects_get(self, resource_group): + response = await self.client.azure_dev_ops_projects.get( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_dev_ops_projects_begin_create_or_update(self, resource_group): + response = await ( + await self.client.azure_dev_ops_projects.begin_create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + azure_dev_ops_project={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "parentOrgName": "str", + "projectId": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_azure_dev_ops_projects_begin_update(self, resource_group): + response = await ( + await self.client.azure_dev_ops_projects.begin_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + azure_dev_ops_project={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "parentOrgName": "str", + "projectId": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_repos_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_repos_operations.py new file mode 100644 index 000000000000..a4f796384dc6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_repos_operations.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterAzureDevOpsReposOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_repos_list(self, resource_group): + response = self.client.azure_dev_ops_repos.list( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_repos_get(self, resource_group): + response = self.client.azure_dev_ops_repos.get( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + repo_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_dev_ops_repos_begin_create_or_update(self, resource_group): + response = self.client.azure_dev_ops_repos.begin_create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + repo_name="str", + azure_dev_ops_repository={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "parentOrgName": "str", + "parentProjectName": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + "repoId": "str", + "repoUrl": "str", + "visibility": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_azure_dev_ops_repos_begin_update(self, resource_group): + response = self.client.azure_dev_ops_repos.begin_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + repo_name="str", + azure_dev_ops_repository={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "parentOrgName": "str", + "parentProjectName": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + "repoId": "str", + "repoUrl": "str", + "visibility": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_repos_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_repos_operations_async.py new file mode 100644 index 000000000000..6da2585e8ba5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_azure_dev_ops_repos_operations_async.py @@ -0,0 +1,143 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterAzureDevOpsReposOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_dev_ops_repos_list(self, resource_group): + response = self.client.azure_dev_ops_repos.list( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + api_version="2025-03-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_azure_dev_ops_repos_get(self, resource_group): + response = await self.client.azure_dev_ops_repos.get( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + repo_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_dev_ops_repos_begin_create_or_update(self, resource_group): + response = await ( + await self.client.azure_dev_ops_repos.begin_create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + repo_name="str", + azure_dev_ops_repository={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "parentOrgName": "str", + "parentProjectName": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + "repoId": "str", + "repoUrl": "str", + "visibility": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_azure_dev_ops_repos_begin_update(self, resource_group): + response = await ( + await self.client.azure_dev_ops_repos.begin_update( + resource_group_name=resource_group.name, + security_connector_name="str", + org_name="str", + project_name="str", + repo_name="str", + azure_dev_ops_repository={ + "id": "str", + "name": "str", + "properties": { + "actionableRemediation": { + "branchConfiguration": {"annotateDefaultBranch": "str", "branchNames": ["str"]}, + "categoryConfigurations": [{"category": "str", "minimumSeverityLevel": "str"}], + "inheritFromParentState": "str", + "state": "str", + }, + "onboardingState": "str", + "parentOrgName": "str", + "parentProjectName": "str", + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + "repoId": "str", + "repoUrl": "str", + "visibility": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliance_results_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliance_results_operations.py new file mode 100644 index 000000000000..394fe2241780 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliance_results_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterComplianceResultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_compliance_results_list(self, resource_group): + response = self.client.compliance_results.list( + scope="str", + api_version="2017-08-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_compliance_results_get(self, resource_group): + response = self.client.compliance_results.get( + resource_id="str", + compliance_result_name="str", + api_version="2017-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliance_results_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliance_results_operations_async.py new file mode 100644 index 000000000000..a9d4e2afc1ce --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliance_results_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterComplianceResultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_compliance_results_list(self, resource_group): + response = self.client.compliance_results.list( + scope="str", + api_version="2017-08-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_compliance_results_get(self, resource_group): + response = await self.client.compliance_results.get( + resource_id="str", + compliance_result_name="str", + api_version="2017-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliances_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliances_operations.py new file mode 100644 index 000000000000..5ce15fce3304 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliances_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterCompliancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_compliances_list(self, resource_group): + response = self.client.compliances.list( + scope="str", + api_version="2017-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_compliances_get(self, resource_group): + response = self.client.compliances.get( + scope="str", + compliance_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliances_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliances_operations_async.py new file mode 100644 index 000000000000..0d96846921b4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_compliances_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterCompliancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_compliances_list(self, resource_group): + response = self.client.compliances.list( + scope="str", + api_version="2017-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_compliances_get(self, resource_group): + response = await self.client.compliances.get( + scope="str", + compliance_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_connectors_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_connectors_operations.py new file mode 100644 index 000000000000..23e4cd1e7442 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_connectors_operations.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterConnectorsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_connectors_list(self, resource_group): + response = self.client.connectors.list( + api_version="2020-01-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_connectors_get(self, resource_group): + response = self.client.connectors.get( + connector_name="str", + api_version="2020-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_connectors_create_or_update(self, resource_group): + response = self.client.connectors.create_or_update( + connector_name="str", + connector_setting={ + "authenticationDetails": "authentication_details_properties", + "hybridComputeSettings": { + "autoProvision": "str", + "hybridComputeProvisioningState": "str", + "proxyServer": {"ip": "str", "port": "str"}, + "region": "str", + "resourceGroupName": "str", + "servicePrincipal": {"applicationId": "str", "secret": "str"}, + }, + "id": "str", + "name": "str", + "type": "str", + }, + api_version="2020-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_connectors_delete(self, resource_group): + response = self.client.connectors.delete( + connector_name="str", + api_version="2020-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_connectors_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_connectors_operations_async.py new file mode 100644 index 000000000000..735768ba7d25 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_connectors_operations_async.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterConnectorsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_connectors_list(self, resource_group): + response = self.client.connectors.list( + api_version="2020-01-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_connectors_get(self, resource_group): + response = await self.client.connectors.get( + connector_name="str", + api_version="2020-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_connectors_create_or_update(self, resource_group): + response = await self.client.connectors.create_or_update( + connector_name="str", + connector_setting={ + "authenticationDetails": "authentication_details_properties", + "hybridComputeSettings": { + "autoProvision": "str", + "hybridComputeProvisioningState": "str", + "proxyServer": {"ip": "str", "port": "str"}, + "region": "str", + "resourceGroupName": "str", + "servicePrincipal": {"applicationId": "str", "secret": "str"}, + }, + "id": "str", + "name": "str", + "type": "str", + }, + api_version="2020-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_connectors_delete(self, resource_group): + response = await self.client.connectors.delete( + connector_name="str", + api_version="2020-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_assessment_automations_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_assessment_automations_operations.py new file mode 100644 index 000000000000..089c03226785 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_assessment_automations_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterCustomAssessmentAutomationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_assessment_automations_get(self, resource_group): + response = self.client.custom_assessment_automations.get( + resource_group_name=resource_group.name, + custom_assessment_automation_name="str", + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_assessment_automations_create(self, resource_group): + response = self.client.custom_assessment_automations.create( + resource_group_name=resource_group.name, + custom_assessment_automation_name="str", + custom_assessment_automation_body={ + "compressedQuery": "str", + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "remediationDescription": "str", + "severity": "Low", + "supportedCloud": "AWS", + "type": "str", + }, + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_assessment_automations_delete(self, resource_group): + response = self.client.custom_assessment_automations.delete( + resource_group_name=resource_group.name, + custom_assessment_automation_name="str", + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_assessment_automations_list_by_resource_group(self, resource_group): + response = self.client.custom_assessment_automations.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_assessment_automations_list_by_subscription(self, resource_group): + response = self.client.custom_assessment_automations.list_by_subscription( + api_version="2021-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_assessment_automations_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_assessment_automations_operations_async.py new file mode 100644 index 000000000000..bd791d269655 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_assessment_automations_operations_async.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterCustomAssessmentAutomationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_assessment_automations_get(self, resource_group): + response = await self.client.custom_assessment_automations.get( + resource_group_name=resource_group.name, + custom_assessment_automation_name="str", + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_assessment_automations_create(self, resource_group): + response = await self.client.custom_assessment_automations.create( + resource_group_name=resource_group.name, + custom_assessment_automation_name="str", + custom_assessment_automation_body={ + "compressedQuery": "str", + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "remediationDescription": "str", + "severity": "Low", + "supportedCloud": "AWS", + "type": "str", + }, + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_assessment_automations_delete(self, resource_group): + response = await self.client.custom_assessment_automations.delete( + resource_group_name=resource_group.name, + custom_assessment_automation_name="str", + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_assessment_automations_list_by_resource_group(self, resource_group): + response = self.client.custom_assessment_automations.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_assessment_automations_list_by_subscription(self, resource_group): + response = self.client.custom_assessment_automations.list_by_subscription( + api_version="2021-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_entity_store_assignments_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_entity_store_assignments_operations.py new file mode 100644 index 000000000000..2e1a63607e4b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_entity_store_assignments_operations.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterCustomEntityStoreAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_entity_store_assignments_get(self, resource_group): + response = self.client.custom_entity_store_assignments.get( + resource_group_name=resource_group.name, + custom_entity_store_assignment_name="str", + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_entity_store_assignments_create(self, resource_group): + response = self.client.custom_entity_store_assignments.create( + resource_group_name=resource_group.name, + custom_entity_store_assignment_name="str", + custom_entity_store_assignment_request_body={"principal": "str"}, + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_entity_store_assignments_delete(self, resource_group): + response = self.client.custom_entity_store_assignments.delete( + resource_group_name=resource_group.name, + custom_entity_store_assignment_name="str", + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_entity_store_assignments_list_by_resource_group(self, resource_group): + response = self.client.custom_entity_store_assignments.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_entity_store_assignments_list_by_subscription(self, resource_group): + response = self.client.custom_entity_store_assignments.list_by_subscription( + api_version="2021-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_entity_store_assignments_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_entity_store_assignments_operations_async.py new file mode 100644 index 000000000000..adfd5a4e43ee --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_entity_store_assignments_operations_async.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterCustomEntityStoreAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_entity_store_assignments_get(self, resource_group): + response = await self.client.custom_entity_store_assignments.get( + resource_group_name=resource_group.name, + custom_entity_store_assignment_name="str", + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_entity_store_assignments_create(self, resource_group): + response = await self.client.custom_entity_store_assignments.create( + resource_group_name=resource_group.name, + custom_entity_store_assignment_name="str", + custom_entity_store_assignment_request_body={"principal": "str"}, + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_entity_store_assignments_delete(self, resource_group): + response = await self.client.custom_entity_store_assignments.delete( + resource_group_name=resource_group.name, + custom_entity_store_assignment_name="str", + api_version="2021-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_entity_store_assignments_list_by_resource_group(self, resource_group): + response = self.client.custom_entity_store_assignments.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_entity_store_assignments_list_by_subscription(self, resource_group): + response = self.client.custom_entity_store_assignments.list_by_subscription( + api_version="2021-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_recommendations_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_recommendations_operations.py new file mode 100644 index 000000000000..b386f72e3b30 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_recommendations_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterCustomRecommendationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_recommendations_list(self, resource_group): + response = self.client.custom_recommendations.list( + scope="str", + api_version="2024-08-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_recommendations_get(self, resource_group): + response = self.client.custom_recommendations.get( + scope="str", + custom_recommendation_name="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_recommendations_create_or_update(self, resource_group): + response = self.client.custom_recommendations.create_or_update( + scope="str", + custom_recommendation_name="str", + custom_recommendation_body={ + "assessmentKey": "str", + "cloudProviders": ["str"], + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "query": "str", + "remediationDescription": "str", + "securityIssue": "BestPractices", + "severity": "Low", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_recommendations_delete(self, resource_group): + response = self.client.custom_recommendations.delete( + scope="str", + custom_recommendation_name="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_recommendations_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_recommendations_operations_async.py new file mode 100644 index 000000000000..65b814db137c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_custom_recommendations_operations_async.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterCustomRecommendationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_recommendations_list(self, resource_group): + response = self.client.custom_recommendations.list( + scope="str", + api_version="2024-08-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_custom_recommendations_get(self, resource_group): + response = await self.client.custom_recommendations.get( + scope="str", + custom_recommendation_name="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_recommendations_create_or_update(self, resource_group): + response = await self.client.custom_recommendations.create_or_update( + scope="str", + custom_recommendation_name="str", + custom_recommendation_body={ + "assessmentKey": "str", + "cloudProviders": ["str"], + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "query": "str", + "remediationDescription": "str", + "securityIssue": "BestPractices", + "severity": "Low", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_recommendations_delete(self, resource_group): + response = await self.client.custom_recommendations.delete( + scope="str", + custom_recommendation_name="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_defender_for_storage_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_defender_for_storage_operations.py new file mode 100644 index 000000000000..30c2ec37f785 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_defender_for_storage_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterDefenderForStorageOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_defender_for_storage_get(self, resource_group): + response = self.client.defender_for_storage.get( + resource_id="str", + setting_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_defender_for_storage_create(self, resource_group): + response = self.client.defender_for_storage.create( + resource_id="str", + setting_name="str", + defender_for_storage_setting={ + "id": "str", + "name": "str", + "properties": { + "isEnabled": bool, + "malwareScanning": { + "blobScanResultsOptions": "str", + "onUpload": { + "capGBPerMonth": 0, + "filters": { + "excludeBlobsLargerThan": {}, + "excludeBlobsWithPrefix": ["str"], + "excludeBlobsWithSuffix": ["str"], + }, + "isEnabled": bool, + }, + "operationStatus": {"code": "str", "message": "str"}, + "scanResultsEventGridTopicResourceId": "str", + }, + "overrideSubscriptionLevelSettings": bool, + "sensitiveDataDiscovery": {"isEnabled": bool, "operationStatus": {"code": "str", "message": "str"}}, + }, + "type": "str", + }, + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_defender_for_storage_start_malware_scan(self, resource_group): + response = self.client.defender_for_storage.start_malware_scan( + resource_id="str", + setting_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_defender_for_storage_cancel_malware_scan(self, resource_group): + response = self.client.defender_for_storage.cancel_malware_scan( + resource_id="str", + setting_name="str", + scan_id="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_defender_for_storage_get_malware_scan(self, resource_group): + response = self.client.defender_for_storage.get_malware_scan( + resource_id="str", + setting_name="str", + scan_id="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_defender_for_storage_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_defender_for_storage_operations_async.py new file mode 100644 index 000000000000..f621d08f0d2b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_defender_for_storage_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterDefenderForStorageOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_defender_for_storage_get(self, resource_group): + response = await self.client.defender_for_storage.get( + resource_id="str", + setting_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_defender_for_storage_create(self, resource_group): + response = await self.client.defender_for_storage.create( + resource_id="str", + setting_name="str", + defender_for_storage_setting={ + "id": "str", + "name": "str", + "properties": { + "isEnabled": bool, + "malwareScanning": { + "blobScanResultsOptions": "str", + "onUpload": { + "capGBPerMonth": 0, + "filters": { + "excludeBlobsLargerThan": {}, + "excludeBlobsWithPrefix": ["str"], + "excludeBlobsWithSuffix": ["str"], + }, + "isEnabled": bool, + }, + "operationStatus": {"code": "str", "message": "str"}, + "scanResultsEventGridTopicResourceId": "str", + }, + "overrideSubscriptionLevelSettings": bool, + "sensitiveDataDiscovery": {"isEnabled": bool, "operationStatus": {"code": "str", "message": "str"}}, + }, + "type": "str", + }, + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_defender_for_storage_start_malware_scan(self, resource_group): + response = await self.client.defender_for_storage.start_malware_scan( + resource_id="str", + setting_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_defender_for_storage_cancel_malware_scan(self, resource_group): + response = await self.client.defender_for_storage.cancel_malware_scan( + resource_id="str", + setting_name="str", + scan_id="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_defender_for_storage_get_malware_scan(self, resource_group): + response = await self.client.defender_for_storage.get_malware_scan( + resource_id="str", + setting_name="str", + scan_id="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_configurations_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_configurations_operations.py new file mode 100644 index 000000000000..e1b590100f96 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_configurations_operations.py @@ -0,0 +1,137 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterDevOpsConfigurationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_dev_ops_configurations_list(self, resource_group): + response = self.client.dev_ops_configurations.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_dev_ops_configurations_get(self, resource_group): + response = self.client.dev_ops_configurations.get( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_dev_ops_configurations_begin_create_or_update(self, resource_group): + response = self.client.dev_ops_configurations.begin_create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + dev_ops_configuration={ + "id": "str", + "name": "str", + "properties": { + "agentlessConfiguration": { + "agentlessAutoDiscovery": "str", + "agentlessEnabled": "str", + "inventoryList": [{"inventoryKind": "str", "value": "str"}], + "inventoryListType": "str", + "scanners": ["str"], + }, + "authorization": {"code": "str"}, + "autoDiscovery": "str", + "capabilities": [{"name": "str", "value": "str"}], + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + "topLevelInventoryList": ["str"], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_dev_ops_configurations_begin_update(self, resource_group): + response = self.client.dev_ops_configurations.begin_update( + resource_group_name=resource_group.name, + security_connector_name="str", + dev_ops_configuration={ + "id": "str", + "name": "str", + "properties": { + "agentlessConfiguration": { + "agentlessAutoDiscovery": "str", + "agentlessEnabled": "str", + "inventoryList": [{"inventoryKind": "str", "value": "str"}], + "inventoryListType": "str", + "scanners": ["str"], + }, + "authorization": {"code": "str"}, + "autoDiscovery": "str", + "capabilities": [{"name": "str", "value": "str"}], + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + "topLevelInventoryList": ["str"], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_dev_ops_configurations_begin_delete(self, resource_group): + response = self.client.dev_ops_configurations.begin_delete( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_configurations_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_configurations_operations_async.py new file mode 100644 index 000000000000..6b7f833be113 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_configurations_operations_async.py @@ -0,0 +1,144 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterDevOpsConfigurationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_dev_ops_configurations_list(self, resource_group): + response = self.client.dev_ops_configurations.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-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_dev_ops_configurations_get(self, resource_group): + response = await self.client.dev_ops_configurations.get( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_dev_ops_configurations_begin_create_or_update(self, resource_group): + response = await ( + await self.client.dev_ops_configurations.begin_create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + dev_ops_configuration={ + "id": "str", + "name": "str", + "properties": { + "agentlessConfiguration": { + "agentlessAutoDiscovery": "str", + "agentlessEnabled": "str", + "inventoryList": [{"inventoryKind": "str", "value": "str"}], + "inventoryListType": "str", + "scanners": ["str"], + }, + "authorization": {"code": "str"}, + "autoDiscovery": "str", + "capabilities": [{"name": "str", "value": "str"}], + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + "topLevelInventoryList": ["str"], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_dev_ops_configurations_begin_update(self, resource_group): + response = await ( + await self.client.dev_ops_configurations.begin_update( + resource_group_name=resource_group.name, + security_connector_name="str", + dev_ops_configuration={ + "id": "str", + "name": "str", + "properties": { + "agentlessConfiguration": { + "agentlessAutoDiscovery": "str", + "agentlessEnabled": "str", + "inventoryList": [{"inventoryKind": "str", "value": "str"}], + "inventoryListType": "str", + "scanners": ["str"], + }, + "authorization": {"code": "str"}, + "autoDiscovery": "str", + "capabilities": [{"name": "str", "value": "str"}], + "provisioningState": "str", + "provisioningStatusMessage": "str", + "provisioningStatusUpdateTimeUtc": "2020-02-20 00:00:00", + "topLevelInventoryList": ["str"], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-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_dev_ops_configurations_begin_delete(self, resource_group): + response = await ( + await self.client.dev_ops_configurations.begin_delete( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_operation_results_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_operation_results_operations.py new file mode 100644 index 000000000000..ac4724a71c0d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_operation_results_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterDevOpsOperationResultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_dev_ops_operation_results_get(self, resource_group): + response = self.client.dev_ops_operation_results.get( + resource_group_name=resource_group.name, + security_connector_name="str", + operation_result_id="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_operation_results_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_operation_results_operations_async.py new file mode 100644 index 000000000000..b03580a67e1e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_dev_ops_operation_results_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterDevOpsOperationResultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_dev_ops_operation_results_get(self, resource_group): + response = await self.client.dev_ops_operation_results.get( + resource_group_name=resource_group.name, + security_connector_name="str", + operation_result_id="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_device_security_groups_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_device_security_groups_operations.py new file mode 100644 index 000000000000..663068c45f39 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_device_security_groups_operations.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterDeviceSecurityGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_device_security_groups_list(self, resource_group): + response = self.client.device_security_groups.list( + resource_id="str", + api_version="2019-08-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_device_security_groups_get(self, resource_group): + response = self.client.device_security_groups.get( + resource_id="str", + device_security_group_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_device_security_groups_create_or_update(self, resource_group): + response = self.client.device_security_groups.create_or_update( + resource_id="str", + device_security_group_name="str", + device_security_group={ + "allowlistRules": ["allowlist_custom_alert_rule"], + "denylistRules": [ + { + "denylistValues": ["str"], + "isEnabled": bool, + "ruleType": "DenylistCustomAlertRule", + "description": "str", + "displayName": "str", + "valueType": "str", + } + ], + "id": "str", + "name": "str", + "thresholdRules": ["threshold_custom_alert_rule"], + "timeWindowRules": ["time_window_custom_alert_rule"], + "type": "str", + }, + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_device_security_groups_delete(self, resource_group): + response = self.client.device_security_groups.delete( + resource_id="str", + device_security_group_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_device_security_groups_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_device_security_groups_operations_async.py new file mode 100644 index 000000000000..1d0c2cd01a54 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_device_security_groups_operations_async.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterDeviceSecurityGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_device_security_groups_list(self, resource_group): + response = self.client.device_security_groups.list( + resource_id="str", + api_version="2019-08-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_device_security_groups_get(self, resource_group): + response = await self.client.device_security_groups.get( + resource_id="str", + device_security_group_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_device_security_groups_create_or_update(self, resource_group): + response = await self.client.device_security_groups.create_or_update( + resource_id="str", + device_security_group_name="str", + device_security_group={ + "allowlistRules": ["allowlist_custom_alert_rule"], + "denylistRules": [ + { + "denylistValues": ["str"], + "isEnabled": bool, + "ruleType": "DenylistCustomAlertRule", + "description": "str", + "displayName": "str", + "valueType": "str", + } + ], + "id": "str", + "name": "str", + "thresholdRules": ["threshold_custom_alert_rule"], + "timeWindowRules": ["time_window_custom_alert_rule"], + "type": "str", + }, + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_device_security_groups_delete(self, resource_group): + response = await self.client.device_security_groups.delete( + resource_id="str", + device_security_group_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_discovered_security_solutions_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_discovered_security_solutions_operations.py new file mode 100644 index 000000000000..5a143e1080e5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_discovered_security_solutions_operations.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterDiscoveredSecuritySolutionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_discovered_security_solutions_list(self, resource_group): + response = self.client.discovered_security_solutions.list( + api_version="2020-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_discovered_security_solutions_list_by_home_region(self, resource_group): + response = self.client.discovered_security_solutions.list_by_home_region( + asc_location="str", + api_version="2020-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_discovered_security_solutions_get(self, resource_group): + response = self.client.discovered_security_solutions.get( + resource_group_name=resource_group.name, + asc_location="str", + discovered_security_solution_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_discovered_security_solutions_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_discovered_security_solutions_operations_async.py new file mode 100644 index 000000000000..337211055de9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_discovered_security_solutions_operations_async.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterDiscoveredSecuritySolutionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_discovered_security_solutions_list(self, resource_group): + response = self.client.discovered_security_solutions.list( + api_version="2020-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_discovered_security_solutions_list_by_home_region(self, resource_group): + response = self.client.discovered_security_solutions.list_by_home_region( + asc_location="str", + api_version="2020-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_discovered_security_solutions_get(self, resource_group): + response = await self.client.discovered_security_solutions.get( + resource_group_name=resource_group.name, + asc_location="str", + discovered_security_solution_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_external_security_solutions_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_external_security_solutions_operations.py new file mode 100644 index 000000000000..208caee4fa83 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_external_security_solutions_operations.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterExternalSecuritySolutionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_external_security_solutions_list(self, resource_group): + response = self.client.external_security_solutions.list( + api_version="2020-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_external_security_solutions_list_by_home_region(self, resource_group): + response = self.client.external_security_solutions.list_by_home_region( + asc_location="str", + api_version="2020-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_external_security_solutions_get(self, resource_group): + response = self.client.external_security_solutions.get( + resource_group_name=resource_group.name, + asc_location="str", + external_security_solutions_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_external_security_solutions_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_external_security_solutions_operations_async.py new file mode 100644 index 000000000000..1808ceb22fe3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_external_security_solutions_operations_async.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterExternalSecuritySolutionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_external_security_solutions_list(self, resource_group): + response = self.client.external_security_solutions.list( + api_version="2020-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_external_security_solutions_list_by_home_region(self, resource_group): + response = self.client.external_security_solutions.list_by_home_region( + asc_location="str", + api_version="2020-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_external_security_solutions_get(self, resource_group): + response = await self.client.external_security_solutions.get( + resource_group_name=resource_group.name, + asc_location="str", + external_security_solutions_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_owners_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_owners_operations.py new file mode 100644 index 000000000000..a9a218bced77 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_owners_operations.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterGitHubOwnersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_hub_owners_list_available(self, resource_group): + response = self.client.git_hub_owners.list_available( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_hub_owners_list(self, resource_group): + response = self.client.git_hub_owners.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_hub_owners_get(self, resource_group): + response = self.client.git_hub_owners.get( + resource_group_name=resource_group.name, + security_connector_name="str", + owner_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_owners_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_owners_operations_async.py new file mode 100644 index 000000000000..68fb05af7942 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_owners_operations_async.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterGitHubOwnersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_git_hub_owners_list_available(self, resource_group): + response = await self.client.git_hub_owners.list_available( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_git_hub_owners_list(self, resource_group): + response = self.client.git_hub_owners.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-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_git_hub_owners_get(self, resource_group): + response = await self.client.git_hub_owners.get( + resource_group_name=resource_group.name, + security_connector_name="str", + owner_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_repos_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_repos_operations.py new file mode 100644 index 000000000000..71a6c9847dad --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_repos_operations.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterGitHubReposOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_hub_repos_list(self, resource_group): + response = self.client.git_hub_repos.list( + resource_group_name=resource_group.name, + security_connector_name="str", + owner_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_hub_repos_get(self, resource_group): + response = self.client.git_hub_repos.get( + resource_group_name=resource_group.name, + security_connector_name="str", + owner_name="str", + repo_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_repos_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_repos_operations_async.py new file mode 100644 index 000000000000..b3e4b9022f22 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_hub_repos_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterGitHubReposOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_git_hub_repos_list(self, resource_group): + response = self.client.git_hub_repos.list( + resource_group_name=resource_group.name, + security_connector_name="str", + owner_name="str", + api_version="2025-03-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_git_hub_repos_get(self, resource_group): + response = await self.client.git_hub_repos.get( + resource_group_name=resource_group.name, + security_connector_name="str", + owner_name="str", + repo_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_groups_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_groups_operations.py new file mode 100644 index 000000000000..07bde8d40e31 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_groups_operations.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterGitLabGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_lab_groups_list_available(self, resource_group): + response = self.client.git_lab_groups.list_available( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_lab_groups_list(self, resource_group): + response = self.client.git_lab_groups.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_lab_groups_get(self, resource_group): + response = self.client.git_lab_groups.get( + resource_group_name=resource_group.name, + security_connector_name="str", + group_fq_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_groups_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_groups_operations_async.py new file mode 100644 index 000000000000..e99e754d2a53 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_groups_operations_async.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterGitLabGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_git_lab_groups_list_available(self, resource_group): + response = await self.client.git_lab_groups.list_available( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_git_lab_groups_list(self, resource_group): + response = self.client.git_lab_groups.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2025-03-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_git_lab_groups_get(self, resource_group): + response = await self.client.git_lab_groups.get( + resource_group_name=resource_group.name, + security_connector_name="str", + group_fq_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_projects_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_projects_operations.py new file mode 100644 index 000000000000..0a90e0171bc4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_projects_operations.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterGitLabProjectsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_lab_projects_list(self, resource_group): + response = self.client.git_lab_projects.list( + resource_group_name=resource_group.name, + security_connector_name="str", + group_fq_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_lab_projects_get(self, resource_group): + response = self.client.git_lab_projects.get( + resource_group_name=resource_group.name, + security_connector_name="str", + group_fq_name="str", + project_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_projects_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_projects_operations_async.py new file mode 100644 index 000000000000..95451bc6309e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_projects_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterGitLabProjectsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_git_lab_projects_list(self, resource_group): + response = self.client.git_lab_projects.list( + resource_group_name=resource_group.name, + security_connector_name="str", + group_fq_name="str", + api_version="2025-03-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_git_lab_projects_get(self, resource_group): + response = await self.client.git_lab_projects.get( + resource_group_name=resource_group.name, + security_connector_name="str", + group_fq_name="str", + project_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_subgroups_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_subgroups_operations.py new file mode 100644 index 000000000000..d2c96d831a1e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_subgroups_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterGitLabSubgroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_lab_subgroups_list(self, resource_group): + response = self.client.git_lab_subgroups.list( + resource_group_name=resource_group.name, + security_connector_name="str", + group_fq_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_subgroups_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_subgroups_operations_async.py new file mode 100644 index 000000000000..2380cc2f72c4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_git_lab_subgroups_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterGitLabSubgroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_git_lab_subgroups_list(self, resource_group): + response = await self.client.git_lab_subgroups.list( + resource_group_name=resource_group.name, + security_connector_name="str", + group_fq_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_assignments_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_assignments_operations.py new file mode 100644 index 000000000000..0af095181f48 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_assignments_operations.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterGovernanceAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_assignments_list(self, resource_group): + response = self.client.governance_assignments.list( + scope="str", + assessment_name="str", + api_version="2022-01-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_assignments_get(self, resource_group): + response = self.client.governance_assignments.get( + scope="str", + assessment_name="str", + assignment_key="str", + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_assignments_create_or_update(self, resource_group): + response = self.client.governance_assignments.create_or_update( + scope="str", + assessment_name="str", + assignment_key="str", + governance_assignment={ + "additionalData": {"ticketLink": "str", "ticketNumber": 0, "ticketStatus": "str"}, + "governanceEmailNotification": { + "disableManagerEmailNotification": bool, + "disableOwnerEmailNotification": bool, + }, + "id": "str", + "isGracePeriod": bool, + "name": "str", + "owner": "str", + "remediationDueDate": "2020-02-20 00:00:00", + "remediationEta": {"eta": "2020-02-20 00:00:00", "justification": "str"}, + "type": "str", + }, + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_assignments_delete(self, resource_group): + response = self.client.governance_assignments.delete( + scope="str", + assessment_name="str", + assignment_key="str", + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_assignments_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_assignments_operations_async.py new file mode 100644 index 000000000000..aff8695f12ad --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_assignments_operations_async.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterGovernanceAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_assignments_list(self, resource_group): + response = self.client.governance_assignments.list( + scope="str", + assessment_name="str", + api_version="2022-01-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_assignments_get(self, resource_group): + response = await self.client.governance_assignments.get( + scope="str", + assessment_name="str", + assignment_key="str", + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_assignments_create_or_update(self, resource_group): + response = await self.client.governance_assignments.create_or_update( + scope="str", + assessment_name="str", + assignment_key="str", + governance_assignment={ + "additionalData": {"ticketLink": "str", "ticketNumber": 0, "ticketStatus": "str"}, + "governanceEmailNotification": { + "disableManagerEmailNotification": bool, + "disableOwnerEmailNotification": bool, + }, + "id": "str", + "isGracePeriod": bool, + "name": "str", + "owner": "str", + "remediationDueDate": "2020-02-20 00:00:00", + "remediationEta": {"eta": "2020-02-20 00:00:00", "justification": "str"}, + "type": "str", + }, + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_assignments_delete(self, resource_group): + response = await self.client.governance_assignments.delete( + scope="str", + assessment_name="str", + assignment_key="str", + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_rules_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_rules_operations.py new file mode 100644 index 000000000000..a3280b10e873 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_rules_operations.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterGovernanceRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_rules_list(self, resource_group): + response = self.client.governance_rules.list( + scope="str", + api_version="2022-01-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_rules_get(self, resource_group): + response = self.client.governance_rules.get( + scope="str", + rule_id="str", + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_rules_create_or_update(self, resource_group): + response = self.client.governance_rules.create_or_update( + scope="str", + rule_id="str", + governance_rule={ + "conditionSets": [{}], + "description": "str", + "displayName": "str", + "excludedScopes": ["str"], + "governanceEmailNotification": { + "disableManagerEmailNotification": bool, + "disableOwnerEmailNotification": bool, + }, + "id": "str", + "includeMemberScopes": bool, + "isDisabled": bool, + "isGracePeriod": bool, + "metadata": { + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + "name": "str", + "ownerSource": {"type": "str", "value": "str"}, + "remediationTimeframe": "str", + "rulePriority": 0, + "ruleType": "str", + "sourceResourceType": "str", + "tenantId": "str", + "type": "str", + }, + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_rules_begin_delete(self, resource_group): + response = self.client.governance_rules.begin_delete( + scope="str", + rule_id="str", + api_version="2022-01-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_rules_begin_execute(self, resource_group): + response = self.client.governance_rules.begin_execute( + scope="str", + rule_id="str", + api_version="2022-01-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_governance_rules_operation_results(self, resource_group): + response = self.client.governance_rules.operation_results( + scope="str", + rule_id="str", + operation_id="str", + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_rules_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_rules_operations_async.py new file mode 100644 index 000000000000..46a034d3964d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_governance_rules_operations_async.py @@ -0,0 +1,124 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterGovernanceRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_rules_list(self, resource_group): + response = self.client.governance_rules.list( + scope="str", + api_version="2022-01-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_rules_get(self, resource_group): + response = await self.client.governance_rules.get( + scope="str", + rule_id="str", + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_rules_create_or_update(self, resource_group): + response = await self.client.governance_rules.create_or_update( + scope="str", + rule_id="str", + governance_rule={ + "conditionSets": [{}], + "description": "str", + "displayName": "str", + "excludedScopes": ["str"], + "governanceEmailNotification": { + "disableManagerEmailNotification": bool, + "disableOwnerEmailNotification": bool, + }, + "id": "str", + "includeMemberScopes": bool, + "isDisabled": bool, + "isGracePeriod": bool, + "metadata": { + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + "name": "str", + "ownerSource": {"type": "str", "value": "str"}, + "remediationTimeframe": "str", + "rulePriority": 0, + "ruleType": "str", + "sourceResourceType": "str", + "tenantId": "str", + "type": "str", + }, + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_rules_begin_delete(self, resource_group): + response = await ( + await self.client.governance_rules.begin_delete( + scope="str", + rule_id="str", + api_version="2022-01-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_rules_begin_execute(self, resource_group): + response = await ( + await self.client.governance_rules.begin_execute( + scope="str", + rule_id="str", + api_version="2022-01-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_governance_rules_operation_results(self, resource_group): + response = await self.client.governance_rules.operation_results( + scope="str", + rule_id="str", + operation_id="str", + api_version="2022-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_health_reports_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_health_reports_operations.py new file mode 100644 index 000000000000..d70072453554 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_health_reports_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterHealthReportsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_health_reports_list(self, resource_group): + response = self.client.health_reports.list( + scope="str", + api_version="2023-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_health_reports_get(self, resource_group): + response = self.client.health_reports.get( + resource_id="str", + health_report_name="str", + api_version="2023-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_health_reports_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_health_reports_operations_async.py new file mode 100644 index 000000000000..475c49925cf4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_health_reports_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterHealthReportsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_health_reports_list(self, resource_group): + response = self.client.health_reports.list( + scope="str", + api_version="2023-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_health_reports_get(self, resource_group): + response = await self.client.health_reports.get( + resource_id="str", + health_report_name="str", + api_version="2023-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_information_protection_policies_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_information_protection_policies_operations.py new file mode 100644 index 000000000000..eb09b907ece4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_information_protection_policies_operations.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterInformationProtectionPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_information_protection_policies_get(self, resource_group): + response = self.client.information_protection_policies.get( + scope="str", + information_protection_policy_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_information_protection_policies_create_or_update(self, resource_group): + response = self.client.information_protection_policies.create_or_update( + scope="str", + information_protection_policy_name="str", + information_protection_policy={ + "id": "str", + "informationTypes": { + "str": { + "custom": bool, + "description": "str", + "displayName": "str", + "enabled": bool, + "keywords": [{"canBeNumeric": bool, "custom": bool, "excluded": bool, "pattern": "str"}], + "order": 0, + "recommendedLabelId": "str", + } + }, + "labels": { + "str": {"description": "str", "displayName": "str", "enabled": bool, "order": 0, "rank": "str"} + }, + "lastModifiedUtc": "2020-02-20 00:00:00", + "name": "str", + "type": "str", + "version": "str", + }, + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_information_protection_policies_list(self, resource_group): + response = self.client.information_protection_policies.list( + scope="str", + api_version="2017-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_information_protection_policies_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_information_protection_policies_operations_async.py new file mode 100644 index 000000000000..a33ef2ba0f57 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_information_protection_policies_operations_async.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterInformationProtectionPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_information_protection_policies_get(self, resource_group): + response = await self.client.information_protection_policies.get( + scope="str", + information_protection_policy_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_information_protection_policies_create_or_update(self, resource_group): + response = await self.client.information_protection_policies.create_or_update( + scope="str", + information_protection_policy_name="str", + information_protection_policy={ + "id": "str", + "informationTypes": { + "str": { + "custom": bool, + "description": "str", + "displayName": "str", + "enabled": bool, + "keywords": [{"canBeNumeric": bool, "custom": bool, "excluded": bool, "pattern": "str"}], + "order": 0, + "recommendedLabelId": "str", + } + }, + "labels": { + "str": {"description": "str", "displayName": "str", "enabled": bool, "order": 0, "rank": "str"} + }, + "lastModifiedUtc": "2020-02-20 00:00:00", + "name": "str", + "type": "str", + "version": "str", + }, + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_information_protection_policies_list(self, resource_group): + response = self.client.information_protection_policies.list( + scope="str", + api_version="2017-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_analytics_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_analytics_operations.py new file mode 100644 index 000000000000..1e70d9ae2547 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_analytics_operations.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterIotSecuritySolutionAnalyticsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solution_analytics_list(self, resource_group): + response = self.client.iot_security_solution_analytics.list( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solution_analytics_get(self, resource_group): + response = self.client.iot_security_solution_analytics.get( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_analytics_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_analytics_operations_async.py new file mode 100644 index 000000000000..a7bf8b27a647 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_analytics_operations_async.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterIotSecuritySolutionAnalyticsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solution_analytics_list(self, resource_group): + response = await self.client.iot_security_solution_analytics.list( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solution_analytics_get(self, resource_group): + response = await self.client.iot_security_solution_analytics.get( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_operations.py new file mode 100644 index 000000000000..8f4d49753c0a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_operations.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterIotSecuritySolutionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solution_list_by_subscription(self, resource_group): + response = self.client.iot_security_solution.list_by_subscription( + api_version="2019-08-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solution_list_by_resource_group(self, resource_group): + response = self.client.iot_security_solution.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2019-08-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solution_get(self, resource_group): + response = self.client.iot_security_solution.get( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solution_create_or_update(self, resource_group): + response = self.client.iot_security_solution.create_or_update( + resource_group_name=resource_group.name, + solution_name="str", + iot_security_solution_data={ + "additionalWorkspaces": [{"dataTypes": ["str"], "type": "Sentinel", "workspace": "str"}], + "autoDiscoveredResources": ["str"], + "disabledDataSources": ["str"], + "displayName": "str", + "export": ["str"], + "id": "str", + "iotHubs": ["str"], + "location": "str", + "name": "str", + "recommendationsConfiguration": [{"recommendationType": "str", "status": "Enabled", "name": "str"}], + "status": "Enabled", + "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", + "unmaskedIpLoggingStatus": "Disabled", + "userDefinedResources": {"query": "str", "querySubscriptions": ["str"]}, + "workspace": "str", + }, + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solution_update(self, resource_group): + response = self.client.iot_security_solution.update( + resource_group_name=resource_group.name, + solution_name="str", + update_iot_security_solution_data={ + "recommendationsConfiguration": [{"recommendationType": "str", "status": "Enabled", "name": "str"}], + "tags": {"str": "str"}, + "userDefinedResources": {"query": "str", "querySubscriptions": ["str"]}, + }, + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solution_delete(self, resource_group): + response = self.client.iot_security_solution.delete( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_operations_async.py new file mode 100644 index 000000000000..0060761b0931 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solution_operations_async.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterIotSecuritySolutionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solution_list_by_subscription(self, resource_group): + response = self.client.iot_security_solution.list_by_subscription( + api_version="2019-08-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_iot_security_solution_list_by_resource_group(self, resource_group): + response = self.client.iot_security_solution.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2019-08-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_iot_security_solution_get(self, resource_group): + response = await self.client.iot_security_solution.get( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solution_create_or_update(self, resource_group): + response = await self.client.iot_security_solution.create_or_update( + resource_group_name=resource_group.name, + solution_name="str", + iot_security_solution_data={ + "additionalWorkspaces": [{"dataTypes": ["str"], "type": "Sentinel", "workspace": "str"}], + "autoDiscoveredResources": ["str"], + "disabledDataSources": ["str"], + "displayName": "str", + "export": ["str"], + "id": "str", + "iotHubs": ["str"], + "location": "str", + "name": "str", + "recommendationsConfiguration": [{"recommendationType": "str", "status": "Enabled", "name": "str"}], + "status": "Enabled", + "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", + "unmaskedIpLoggingStatus": "Disabled", + "userDefinedResources": {"query": "str", "querySubscriptions": ["str"]}, + "workspace": "str", + }, + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solution_update(self, resource_group): + response = await self.client.iot_security_solution.update( + resource_group_name=resource_group.name, + solution_name="str", + update_iot_security_solution_data={ + "recommendationsConfiguration": [{"recommendationType": "str", "status": "Enabled", "name": "str"}], + "tags": {"str": "str"}, + "userDefinedResources": {"query": "str", "querySubscriptions": ["str"]}, + }, + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solution_delete(self, resource_group): + response = await self.client.iot_security_solution.delete( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_aggregated_alert_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_aggregated_alert_operations.py new file mode 100644 index 000000000000..2ee66c9ea8b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_aggregated_alert_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterIotSecuritySolutionsAnalyticsAggregatedAlertOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solutions_analytics_aggregated_alert_list(self, resource_group): + response = self.client.iot_security_solutions_analytics_aggregated_alert.list( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solutions_analytics_aggregated_alert_get(self, resource_group): + response = self.client.iot_security_solutions_analytics_aggregated_alert.get( + resource_group_name=resource_group.name, + solution_name="str", + aggregated_alert_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solutions_analytics_aggregated_alert_dismiss(self, resource_group): + response = self.client.iot_security_solutions_analytics_aggregated_alert.dismiss( + resource_group_name=resource_group.name, + solution_name="str", + aggregated_alert_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_aggregated_alert_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_aggregated_alert_operations_async.py new file mode 100644 index 000000000000..aa9694252483 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_aggregated_alert_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterIotSecuritySolutionsAnalyticsAggregatedAlertOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solutions_analytics_aggregated_alert_list(self, resource_group): + response = self.client.iot_security_solutions_analytics_aggregated_alert.list( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-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_iot_security_solutions_analytics_aggregated_alert_get(self, resource_group): + response = await self.client.iot_security_solutions_analytics_aggregated_alert.get( + resource_group_name=resource_group.name, + solution_name="str", + aggregated_alert_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solutions_analytics_aggregated_alert_dismiss(self, resource_group): + response = await self.client.iot_security_solutions_analytics_aggregated_alert.dismiss( + resource_group_name=resource_group.name, + solution_name="str", + aggregated_alert_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_recommendation_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_recommendation_operations.py new file mode 100644 index 000000000000..369631744a86 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_recommendation_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterIotSecuritySolutionsAnalyticsRecommendationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solutions_analytics_recommendation_get(self, resource_group): + response = self.client.iot_security_solutions_analytics_recommendation.get( + resource_group_name=resource_group.name, + solution_name="str", + aggregated_recommendation_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_security_solutions_analytics_recommendation_list(self, resource_group): + response = self.client.iot_security_solutions_analytics_recommendation.list( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_recommendation_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_recommendation_operations_async.py new file mode 100644 index 000000000000..bbe598b529c2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_iot_security_solutions_analytics_recommendation_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterIotSecuritySolutionsAnalyticsRecommendationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solutions_analytics_recommendation_get(self, resource_group): + response = await self.client.iot_security_solutions_analytics_recommendation.get( + resource_group_name=resource_group.name, + solution_name="str", + aggregated_recommendation_name="str", + api_version="2019-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_security_solutions_analytics_recommendation_list(self, resource_group): + response = self.client.iot_security_solutions_analytics_recommendation.list( + resource_group_name=resource_group.name, + solution_name="str", + api_version="2019-08-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_jit_network_access_policies_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_jit_network_access_policies_operations.py new file mode 100644 index 000000000000..db242be2b7fc --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_jit_network_access_policies_operations.py @@ -0,0 +1,173 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterJitNetworkAccessPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_network_access_policies_list(self, resource_group): + response = self.client.jit_network_access_policies.list( + api_version="2020-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_jit_network_access_policies_list_by_region(self, resource_group): + response = self.client.jit_network_access_policies.list_by_region( + asc_location="str", + api_version="2020-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_jit_network_access_policies_list_by_resource_group(self, resource_group): + response = self.client.jit_network_access_policies.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2020-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_jit_network_access_policies_list_by_resource_group_and_region(self, resource_group): + response = self.client.jit_network_access_policies.list_by_resource_group_and_region( + resource_group_name=resource_group.name, + asc_location="str", + api_version="2020-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_jit_network_access_policies_get(self, resource_group): + response = self.client.jit_network_access_policies.get( + resource_group_name=resource_group.name, + asc_location="str", + jit_network_access_policy_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_network_access_policies_create_or_update(self, resource_group): + response = self.client.jit_network_access_policies.create_or_update( + resource_group_name=resource_group.name, + asc_location="str", + jit_network_access_policy_name="str", + body={ + "virtualMachines": [ + { + "id": "str", + "ports": [ + { + "maxRequestAccessDuration": "str", + "number": 0, + "protocol": "str", + "allowedSourceAddressPrefix": "str", + "allowedSourceAddressPrefixes": ["str"], + } + ], + "publicIpAddress": "str", + } + ], + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "provisioningState": "str", + "requests": [ + { + "requestor": "str", + "startTimeUtc": "2020-02-20 00:00:00", + "virtualMachines": [ + { + "id": "str", + "ports": [ + { + "endTimeUtc": "2020-02-20 00:00:00", + "number": 0, + "status": "str", + "statusReason": "str", + "allowedSourceAddressPrefix": "str", + "allowedSourceAddressPrefixes": ["str"], + "mappedPort": 0, + } + ], + } + ], + "justification": "str", + } + ], + "type": "str", + }, + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_network_access_policies_delete(self, resource_group): + response = self.client.jit_network_access_policies.delete( + resource_group_name=resource_group.name, + asc_location="str", + jit_network_access_policy_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_network_access_policies_initiate(self, resource_group): + response = self.client.jit_network_access_policies.initiate( + resource_group_name=resource_group.name, + asc_location="str", + jit_network_access_policy_name="str", + body={ + "virtualMachines": [ + { + "id": "str", + "ports": [ + {"endTimeUtc": "2020-02-20 00:00:00", "number": 0, "allowedSourceAddressPrefix": "str"} + ], + } + ], + "justification": "str", + }, + jit_network_access_policy_initiate_type="initiate", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_jit_network_access_policies_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_jit_network_access_policies_operations_async.py new file mode 100644 index 000000000000..bd287170af18 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_jit_network_access_policies_operations_async.py @@ -0,0 +1,174 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterJitNetworkAccessPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_network_access_policies_list(self, resource_group): + response = self.client.jit_network_access_policies.list( + api_version="2020-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_jit_network_access_policies_list_by_region(self, resource_group): + response = self.client.jit_network_access_policies.list_by_region( + asc_location="str", + api_version="2020-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_jit_network_access_policies_list_by_resource_group(self, resource_group): + response = self.client.jit_network_access_policies.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2020-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_jit_network_access_policies_list_by_resource_group_and_region(self, resource_group): + response = self.client.jit_network_access_policies.list_by_resource_group_and_region( + resource_group_name=resource_group.name, + asc_location="str", + api_version="2020-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_jit_network_access_policies_get(self, resource_group): + response = await self.client.jit_network_access_policies.get( + resource_group_name=resource_group.name, + asc_location="str", + jit_network_access_policy_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_network_access_policies_create_or_update(self, resource_group): + response = await self.client.jit_network_access_policies.create_or_update( + resource_group_name=resource_group.name, + asc_location="str", + jit_network_access_policy_name="str", + body={ + "virtualMachines": [ + { + "id": "str", + "ports": [ + { + "maxRequestAccessDuration": "str", + "number": 0, + "protocol": "str", + "allowedSourceAddressPrefix": "str", + "allowedSourceAddressPrefixes": ["str"], + } + ], + "publicIpAddress": "str", + } + ], + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "provisioningState": "str", + "requests": [ + { + "requestor": "str", + "startTimeUtc": "2020-02-20 00:00:00", + "virtualMachines": [ + { + "id": "str", + "ports": [ + { + "endTimeUtc": "2020-02-20 00:00:00", + "number": 0, + "status": "str", + "statusReason": "str", + "allowedSourceAddressPrefix": "str", + "allowedSourceAddressPrefixes": ["str"], + "mappedPort": 0, + } + ], + } + ], + "justification": "str", + } + ], + "type": "str", + }, + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_network_access_policies_delete(self, resource_group): + response = await self.client.jit_network_access_policies.delete( + resource_group_name=resource_group.name, + asc_location="str", + jit_network_access_policy_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_network_access_policies_initiate(self, resource_group): + response = await self.client.jit_network_access_policies.initiate( + resource_group_name=resource_group.name, + asc_location="str", + jit_network_access_policy_name="str", + body={ + "virtualMachines": [ + { + "id": "str", + "ports": [ + {"endTimeUtc": "2020-02-20 00:00:00", "number": 0, "allowedSourceAddressPrefix": "str"} + ], + } + ], + "justification": "str", + }, + jit_network_access_policy_initiate_type="initiate", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_locations_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_locations_operations.py new file mode 100644 index 000000000000..68d8e081d799 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_locations_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterLocationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_locations_list(self, resource_group): + response = self.client.locations.list( + api_version="2015-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_locations_get(self, resource_group): + response = self.client.locations.get( + asc_location="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_locations_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_locations_operations_async.py new file mode 100644 index 000000000000..b5e2c8f8aff3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_locations_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterLocationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_locations_list(self, resource_group): + response = self.client.locations.list( + api_version="2015-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_locations_get(self, resource_group): + response = await self.client.locations.get( + asc_location="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_mde_onboardings_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_mde_onboardings_operations.py new file mode 100644 index 000000000000..f6f843c8d325 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_mde_onboardings_operations.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterMdeOnboardingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_mde_onboardings_list(self, resource_group): + response = self.client.mde_onboardings.list( + api_version="2021-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_mde_onboardings_get(self, resource_group): + response = self.client.mde_onboardings.get( + api_version="2021-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_mde_onboardings_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_mde_onboardings_operations_async.py new file mode 100644 index 000000000000..bd80ec3a5a77 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_mde_onboardings_operations_async.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterMdeOnboardingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_mde_onboardings_list(self, resource_group): + response = await self.client.mde_onboardings.list( + api_version="2021-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_mde_onboardings_get(self, resource_group): + response = await self.client.mde_onboardings.get( + api_version="2021-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_operations.py new file mode 100644 index 000000000000..9492fcb8849c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2025-05-04-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_operations_async.py new file mode 100644 index 000000000000..2cca94f8864e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2025-05-04-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_pricings_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_pricings_operations.py new file mode 100644 index 000000000000..45ae54466bbe --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_pricings_operations.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterPricingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_pricings_get(self, resource_group): + response = self.client.pricings.get( + scope_id="str", + pricing_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_pricings_update(self, resource_group): + response = self.client.pricings.update( + scope_id="str", + pricing_name="str", + pricing={ + "deprecated": bool, + "enablementTime": "2020-02-20 00:00:00", + "enforce": "str", + "extensions": [ + { + "isEnabled": "str", + "name": "str", + "additionalExtensionProperties": {"str": {}}, + "operationStatus": {"code": "str", "message": "str"}, + } + ], + "freeTrialRemainingTime": "1 day, 0:00:00", + "id": "str", + "inherited": "str", + "inheritedFrom": "str", + "name": "str", + "pricingTier": "str", + "replacedBy": ["str"], + "resourcesCoverageStatus": "str", + "subPlan": "str", + "type": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_pricings_delete(self, resource_group): + response = self.client.pricings.delete( + scope_id="str", + pricing_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_pricings_list(self, resource_group): + response = self.client.pricings.list( + scope_id="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_pricings_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_pricings_operations_async.py new file mode 100644 index 000000000000..a709b115b9a3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_pricings_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterPricingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_pricings_get(self, resource_group): + response = await self.client.pricings.get( + scope_id="str", + pricing_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_pricings_update(self, resource_group): + response = await self.client.pricings.update( + scope_id="str", + pricing_name="str", + pricing={ + "deprecated": bool, + "enablementTime": "2020-02-20 00:00:00", + "enforce": "str", + "extensions": [ + { + "isEnabled": "str", + "name": "str", + "additionalExtensionProperties": {"str": {}}, + "operationStatus": {"code": "str", "message": "str"}, + } + ], + "freeTrialRemainingTime": "1 day, 0:00:00", + "id": "str", + "inherited": "str", + "inheritedFrom": "str", + "name": "str", + "pricingTier": "str", + "replacedBy": ["str"], + "resourcesCoverageStatus": "str", + "subPlan": "str", + "type": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_pricings_delete(self, resource_group): + response = await self.client.pricings.delete( + scope_id="str", + pricing_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_pricings_list(self, resource_group): + response = await self.client.pricings.list( + scope_id="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_endpoint_connections_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..c236d2e4e7e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_endpoint_connections_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + private_endpoint_connection_name="str", + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_create_or_update(self, resource_group): + response = self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + private_endpoint_connection_name="str", + private_link_parameters={"privateLinkName": "str"}, + private_endpoint_connection={ + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "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", + }, + api_version="2025-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + private_endpoint_connection_name="str", + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_endpoint_connections_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..4e4c827bd22d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_endpoint_connections_operations_async.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + private_endpoint_connection_name="str", + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_create_or_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + private_endpoint_connection_name="str", + private_link_parameters={"privateLinkName": "str"}, + private_endpoint_connection={ + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "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", + }, + api_version="2025-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + private_endpoint_connection_name="str", + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_link_resources_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_link_resources_operations.py new file mode 100644 index 000000000000..8f9568a963d4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_link_resources_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_get(self, resource_group): + response = self.client.private_link_resources.get( + resource_group_name=resource_group.name, + group_id="str", + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_link_resources_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_link_resources_operations_async.py new file mode 100644 index 000000000000..9f4ceb96aba0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_link_resources_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_get(self, resource_group): + response = await self.client.private_link_resources.get( + resource_group_name=resource_group.name, + group_id="str", + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_links_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_links_operations.py new file mode 100644 index 000000000000..8391279e1980 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_links_operations.py @@ -0,0 +1,158 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterPrivateLinksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_links_list_by_subscription(self, resource_group): + response = self.client.private_links.list_by_subscription( + api_version="2025-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_links_list(self, resource_group): + response = self.client.private_links.list( + resource_group_name=resource_group.name, + api_version="2025-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_links_get(self, resource_group): + response = self.client.private_links.get( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_links_head(self, resource_group): + response = self.client.private_links.head( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_links_begin_create(self, resource_group): + response = self.client.private_links.begin_create( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + private_link={ + "location": "str", + "id": "str", + "name": "str", + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "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", + } + ], + "privateLinkResources": [ + { + "groupId": "str", + "id": "str", + "name": "str", + "requiredMembers": ["str"], + "requiredZoneNames": ["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", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_links_update(self, resource_group): + response = self.client.private_links.update( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + private_link={"tags": {"str": "str"}}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_links_begin_delete(self, resource_group): + response = self.client.private_links.begin_delete( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_links_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_links_operations_async.py new file mode 100644 index 000000000000..c8f8949276c3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_private_links_operations_async.py @@ -0,0 +1,163 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterPrivateLinksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_links_list_by_subscription(self, resource_group): + response = self.client.private_links.list_by_subscription( + api_version="2025-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_links_list(self, resource_group): + response = self.client.private_links.list( + resource_group_name=resource_group.name, + api_version="2025-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_links_get(self, resource_group): + response = await self.client.private_links.get( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_links_head(self, resource_group): + response = await self.client.private_links.head( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_links_begin_create(self, resource_group): + response = await ( + await self.client.private_links.begin_create( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + private_link={ + "location": "str", + "id": "str", + "name": "str", + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "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", + } + ], + "privateLinkResources": [ + { + "groupId": "str", + "id": "str", + "name": "str", + "requiredMembers": ["str"], + "requiredZoneNames": ["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", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_links_update(self, resource_group): + response = await self.client.private_links.update( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + private_link={"tags": {"str": "str"}}, + api_version="2025-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_links_begin_delete(self, resource_group): + response = await ( + await self.client.private_links.begin_delete( + resource_group_name=resource_group.name, + private_link_parameters={"privateLinkName": "str"}, + api_version="2025-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_assessments_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_assessments_operations.py new file mode 100644 index 000000000000..fd58f730b7e3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_assessments_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterRegulatoryComplianceAssessmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regulatory_compliance_assessments_list(self, resource_group): + response = self.client.regulatory_compliance_assessments.list( + regulatory_compliance_standard_name="str", + regulatory_compliance_control_name="str", + api_version="2019-01-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regulatory_compliance_assessments_get(self, resource_group): + response = self.client.regulatory_compliance_assessments.get( + regulatory_compliance_standard_name="str", + regulatory_compliance_control_name="str", + regulatory_compliance_assessment_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_assessments_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_assessments_operations_async.py new file mode 100644 index 000000000000..d67cdb1bce04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_assessments_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterRegulatoryComplianceAssessmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regulatory_compliance_assessments_list(self, resource_group): + response = self.client.regulatory_compliance_assessments.list( + regulatory_compliance_standard_name="str", + regulatory_compliance_control_name="str", + api_version="2019-01-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regulatory_compliance_assessments_get(self, resource_group): + response = await self.client.regulatory_compliance_assessments.get( + regulatory_compliance_standard_name="str", + regulatory_compliance_control_name="str", + regulatory_compliance_assessment_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_controls_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_controls_operations.py new file mode 100644 index 000000000000..0a9f2fe483e9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_controls_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterRegulatoryComplianceControlsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regulatory_compliance_controls_list(self, resource_group): + response = self.client.regulatory_compliance_controls.list( + regulatory_compliance_standard_name="str", + api_version="2019-01-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regulatory_compliance_controls_get(self, resource_group): + response = self.client.regulatory_compliance_controls.get( + regulatory_compliance_standard_name="str", + regulatory_compliance_control_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_controls_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_controls_operations_async.py new file mode 100644 index 000000000000..3bbf9200a518 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_controls_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterRegulatoryComplianceControlsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regulatory_compliance_controls_list(self, resource_group): + response = self.client.regulatory_compliance_controls.list( + regulatory_compliance_standard_name="str", + api_version="2019-01-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regulatory_compliance_controls_get(self, resource_group): + response = await self.client.regulatory_compliance_controls.get( + regulatory_compliance_standard_name="str", + regulatory_compliance_control_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_standards_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_standards_operations.py new file mode 100644 index 000000000000..19f7c8019117 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_standards_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterRegulatoryComplianceStandardsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regulatory_compliance_standards_list(self, resource_group): + response = self.client.regulatory_compliance_standards.list( + api_version="2019-01-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regulatory_compliance_standards_get(self, resource_group): + response = self.client.regulatory_compliance_standards.get( + regulatory_compliance_standard_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_standards_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_standards_operations_async.py new file mode 100644 index 000000000000..a17ed7f94e5f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_regulatory_compliance_standards_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterRegulatoryComplianceStandardsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regulatory_compliance_standards_list(self, resource_group): + response = self.client.regulatory_compliance_standards.list( + api_version="2019-01-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regulatory_compliance_standards_get(self, resource_group): + response = await self.client.regulatory_compliance_standards.get( + regulatory_compliance_standard_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_control_definitions_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_control_definitions_operations.py new file mode 100644 index 000000000000..e5bf1f3ae7fc --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_control_definitions_operations.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecureScoreControlDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secure_score_control_definitions_list(self, resource_group): + response = self.client.secure_score_control_definitions.list( + api_version="2020-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_secure_score_control_definitions_list_by_subscription(self, resource_group): + response = self.client.secure_score_control_definitions.list_by_subscription( + api_version="2020-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_control_definitions_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_control_definitions_operations_async.py new file mode 100644 index 000000000000..5ae5c82abb8f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_control_definitions_operations_async.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecureScoreControlDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_secure_score_control_definitions_list(self, resource_group): + response = self.client.secure_score_control_definitions.list( + api_version="2020-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_secure_score_control_definitions_list_by_subscription(self, resource_group): + response = self.client.secure_score_control_definitions.list_by_subscription( + api_version="2020-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_controls_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_controls_operations.py new file mode 100644 index 000000000000..197f7ed91e1e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_controls_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecureScoreControlsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secure_score_controls_list_by_secure_score(self, resource_group): + response = self.client.secure_score_controls.list_by_secure_score( + secure_score_name="str", + api_version="2020-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_secure_score_controls_list(self, resource_group): + response = self.client.secure_score_controls.list( + api_version="2020-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_controls_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_controls_operations_async.py new file mode 100644 index 000000000000..48a727ff944b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_score_controls_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecureScoreControlsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_secure_score_controls_list_by_secure_score(self, resource_group): + response = self.client.secure_score_controls.list_by_secure_score( + secure_score_name="str", + api_version="2020-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_secure_score_controls_list(self, resource_group): + response = self.client.secure_score_controls.list( + api_version="2020-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_scores_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_scores_operations.py new file mode 100644 index 000000000000..227efef74efb --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_scores_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecureScoresOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secure_scores_list(self, resource_group): + response = self.client.secure_scores.list( + api_version="2020-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_secure_scores_get(self, resource_group): + response = self.client.secure_scores.get( + secure_score_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_scores_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_scores_operations_async.py new file mode 100644 index 000000000000..2876ddc8fe9e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_secure_scores_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecureScoresOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_secure_scores_list(self, resource_group): + response = self.client.secure_scores.list( + api_version="2020-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_secure_scores_get(self, resource_group): + response = await self.client.secure_scores.get( + secure_score_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_application_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_application_operations.py new file mode 100644 index 000000000000..d275db93d07e --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_application_operations.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecurityConnectorApplicationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connector_application_get(self, resource_group): + response = self.client.security_connector_application.get( + resource_group_name=resource_group.name, + security_connector_name="str", + application_id="str", + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connector_application_create_or_update(self, resource_group): + response = self.client.security_connector_application.create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + application_id="str", + application={ + "conditionSets": [{}], + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "sourceResourceType": "str", + "type": "str", + }, + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connector_application_delete(self, resource_group): + response = self.client.security_connector_application.delete( + resource_group_name=resource_group.name, + security_connector_name="str", + application_id="str", + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_application_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_application_operations_async.py new file mode 100644 index 000000000000..b147f0be2c4d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_application_operations_async.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecurityConnectorApplicationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connector_application_get(self, resource_group): + response = await self.client.security_connector_application.get( + resource_group_name=resource_group.name, + security_connector_name="str", + application_id="str", + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connector_application_create_or_update(self, resource_group): + response = await self.client.security_connector_application.create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + application_id="str", + application={ + "conditionSets": [{}], + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "sourceResourceType": "str", + "type": "str", + }, + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connector_application_delete(self, resource_group): + response = await self.client.security_connector_application.delete( + resource_group_name=resource_group.name, + security_connector_name="str", + application_id="str", + api_version="2022-07-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_applications_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_applications_operations.py new file mode 100644 index 000000000000..8724a63892cd --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_applications_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecurityConnectorApplicationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connector_applications_list(self, resource_group): + response = self.client.security_connector_applications.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2022-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_applications_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_applications_operations_async.py new file mode 100644 index 000000000000..765f51a9c502 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connector_applications_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecurityConnectorApplicationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connector_applications_list(self, resource_group): + response = self.client.security_connector_applications.list( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2022-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connectors_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connectors_operations.py new file mode 100644 index 000000000000..afd9647ec2e2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connectors_operations.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecurityConnectorsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connectors_list(self, resource_group): + response = self.client.security_connectors.list( + api_version="2024-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connectors_list_by_resource_group(self, resource_group): + response = self.client.security_connectors.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connectors_get(self, resource_group): + response = self.client.security_connectors.get( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2024-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connectors_create_or_update(self, resource_group): + response = self.client.security_connectors.create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + security_connector={ + "environmentData": "environment_data", + "environmentName": "str", + "etag": "str", + "hierarchyIdentifier": "str", + "hierarchyIdentifierTrialEndDate": "2020-02-20 00:00:00", + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "offerings": ["cloud_offering"], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connectors_update(self, resource_group): + response = self.client.security_connectors.update( + resource_group_name=resource_group.name, + security_connector_name="str", + security_connector={ + "environmentData": "environment_data", + "environmentName": "str", + "etag": "str", + "hierarchyIdentifier": "str", + "hierarchyIdentifierTrialEndDate": "2020-02-20 00:00:00", + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "offerings": ["cloud_offering"], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connectors_delete(self, resource_group): + response = self.client.security_connectors.delete( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2024-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connectors_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connectors_operations_async.py new file mode 100644 index 000000000000..80423dfbe6eb --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_connectors_operations_async.py @@ -0,0 +1,133 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecurityConnectorsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connectors_list(self, resource_group): + response = self.client.security_connectors.list( + api_version="2024-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connectors_list_by_resource_group(self, resource_group): + response = self.client.security_connectors.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connectors_get(self, resource_group): + response = await self.client.security_connectors.get( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2024-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connectors_create_or_update(self, resource_group): + response = await self.client.security_connectors.create_or_update( + resource_group_name=resource_group.name, + security_connector_name="str", + security_connector={ + "environmentData": "environment_data", + "environmentName": "str", + "etag": "str", + "hierarchyIdentifier": "str", + "hierarchyIdentifierTrialEndDate": "2020-02-20 00:00:00", + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "offerings": ["cloud_offering"], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connectors_update(self, resource_group): + response = await self.client.security_connectors.update( + resource_group_name=resource_group.name, + security_connector_name="str", + security_connector={ + "environmentData": "environment_data", + "environmentName": "str", + "etag": "str", + "hierarchyIdentifier": "str", + "hierarchyIdentifierTrialEndDate": "2020-02-20 00:00:00", + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "offerings": ["cloud_offering"], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connectors_delete(self, resource_group): + response = await self.client.security_connectors.delete( + resource_group_name=resource_group.name, + security_connector_name="str", + api_version="2024-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_contacts_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_contacts_operations.py new file mode 100644 index 000000000000..857fe9b39dee --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_contacts_operations.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecurityContactsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_contacts_list(self, resource_group): + response = self.client.security_contacts.list( + api_version="2023-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_contacts_get(self, resource_group): + response = self.client.security_contacts.get( + security_contact_name="str", + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_contacts_create(self, resource_group): + response = self.client.security_contacts.create( + security_contact_name="str", + security_contact={ + "emails": "str", + "id": "str", + "isEnabled": bool, + "name": "str", + "notificationsByRole": {"roles": ["str"], "state": "str"}, + "notificationsSources": ["notifications_source"], + "phone": "str", + "type": "str", + }, + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_contacts_delete(self, resource_group): + response = self.client.security_contacts.delete( + security_contact_name="str", + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_contacts_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_contacts_operations_async.py new file mode 100644 index 000000000000..af31c1c3e55b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_contacts_operations_async.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecurityContactsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_contacts_list(self, resource_group): + response = self.client.security_contacts.list( + api_version="2023-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_contacts_get(self, resource_group): + response = await self.client.security_contacts.get( + security_contact_name="str", + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_contacts_create(self, resource_group): + response = await self.client.security_contacts.create( + security_contact_name="str", + security_contact={ + "emails": "str", + "id": "str", + "isEnabled": bool, + "name": "str", + "notificationsByRole": {"roles": ["str"], "state": "str"}, + "notificationsSources": ["notifications_source"], + "phone": "str", + "type": "str", + }, + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_contacts_delete(self, resource_group): + response = await self.client.security_contacts.delete( + security_contact_name="str", + api_version="2023-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_operators_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_operators_operations.py new file mode 100644 index 000000000000..69af51db7b0c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_operators_operations.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecurityOperatorsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_operators_list(self, resource_group): + response = self.client.security_operators.list( + pricing_name="str", + api_version="2023-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_operators_get(self, resource_group): + response = self.client.security_operators.get( + pricing_name="str", + security_operator_name="str", + api_version="2023-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_operators_create_or_update(self, resource_group): + response = self.client.security_operators.create_or_update( + pricing_name="str", + security_operator_name="str", + api_version="2023-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_operators_delete(self, resource_group): + response = self.client.security_operators.delete( + pricing_name="str", + security_operator_name="str", + api_version="2023-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_operators_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_operators_operations_async.py new file mode 100644 index 000000000000..090619021bce --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_operators_operations_async.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecurityOperatorsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_operators_list(self, resource_group): + response = await self.client.security_operators.list( + pricing_name="str", + api_version="2023-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_operators_get(self, resource_group): + response = await self.client.security_operators.get( + pricing_name="str", + security_operator_name="str", + api_version="2023-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_operators_create_or_update(self, resource_group): + response = await self.client.security_operators.create_or_update( + pricing_name="str", + security_operator_name="str", + api_version="2023-01-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_operators_delete(self, resource_group): + response = await self.client.security_operators.delete( + pricing_name="str", + security_operator_name="str", + api_version="2023-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_operations.py new file mode 100644 index 000000000000..852551874f7f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecuritySolutionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_solutions_list(self, resource_group): + response = self.client.security_solutions.list( + api_version="2020-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_security_solutions_get(self, resource_group): + response = self.client.security_solutions.get( + resource_group_name=resource_group.name, + asc_location="str", + security_solution_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_operations_async.py new file mode 100644 index 000000000000..3c754d742275 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecuritySolutionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_solutions_list(self, resource_group): + response = self.client.security_solutions.list( + api_version="2020-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_security_solutions_get(self, resource_group): + response = await self.client.security_solutions.get( + resource_group_name=resource_group.name, + asc_location="str", + security_solution_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_reference_data_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_reference_data_operations.py new file mode 100644 index 000000000000..e1a52cd94290 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_reference_data_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecuritySolutionsReferenceDataOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_solutions_reference_data_list(self, resource_group): + response = self.client.security_solutions_reference_data.list( + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_solutions_reference_data_list_by_home_region(self, resource_group): + response = self.client.security_solutions_reference_data.list_by_home_region( + asc_location="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_reference_data_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_reference_data_operations_async.py new file mode 100644 index 000000000000..bcba02da6fc7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_solutions_reference_data_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecuritySolutionsReferenceDataOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_solutions_reference_data_list(self, resource_group): + response = await self.client.security_solutions_reference_data.list( + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_solutions_reference_data_list_by_home_region(self, resource_group): + response = await self.client.security_solutions_reference_data.list_by_home_region( + asc_location="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_standards_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_standards_operations.py new file mode 100644 index 000000000000..91fd9fc0856f --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_standards_operations.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSecurityStandardsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_standards_list(self, resource_group): + response = self.client.security_standards.list( + scope="str", + api_version="2024-08-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_standards_get(self, resource_group): + response = self.client.security_standards.get( + scope="str", + standard_id="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_standards_create_or_update(self, resource_group): + response = self.client.security_standards.create_or_update( + scope="str", + standard_id="str", + standard={ + "assessments": [{"assessmentKey": "str"}], + "cloudProviders": ["str"], + "description": "str", + "displayName": "str", + "id": "str", + "metadata": { + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "lastUpdatedBy": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + }, + "name": "str", + "policySetDefinitionId": "str", + "standardType": "str", + "type": "str", + }, + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_standards_delete(self, resource_group): + response = self.client.security_standards.delete( + scope="str", + standard_id="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_standards_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_standards_operations_async.py new file mode 100644 index 000000000000..01c9e013a28a --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_security_standards_operations_async.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSecurityStandardsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_standards_list(self, resource_group): + response = self.client.security_standards.list( + scope="str", + api_version="2024-08-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_security_standards_get(self, resource_group): + response = await self.client.security_standards.get( + scope="str", + standard_id="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_standards_create_or_update(self, resource_group): + response = await self.client.security_standards.create_or_update( + scope="str", + standard_id="str", + standard={ + "assessments": [{"assessmentKey": "str"}], + "cloudProviders": ["str"], + "description": "str", + "displayName": "str", + "id": "str", + "metadata": { + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "lastUpdatedBy": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + }, + "name": "str", + "policySetDefinitionId": "str", + "standardType": "str", + "type": "str", + }, + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_standards_delete(self, resource_group): + response = await self.client.security_standards.delete( + scope="str", + standard_id="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sensitivity_settings_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sensitivity_settings_operations.py new file mode 100644 index 000000000000..6b735a5bb115 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sensitivity_settings_operations.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSensitivitySettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sensitivity_settings_create_or_update(self, resource_group): + response = self.client.sensitivity_settings.create_or_update( + sensitivity_settings={ + "sensitiveInfoTypesIds": ["str"], + "sensitivityThresholdLabelId": "str", + "sensitivityThresholdLabelOrder": 0.0, + }, + api_version="2023-02-15-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sensitivity_settings_get(self, resource_group): + response = self.client.sensitivity_settings.get( + api_version="2023-02-15-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sensitivity_settings_list(self, resource_group): + response = self.client.sensitivity_settings.list( + api_version="2023-02-15-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sensitivity_settings_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sensitivity_settings_operations_async.py new file mode 100644 index 000000000000..7b6b995373b2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sensitivity_settings_operations_async.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSensitivitySettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sensitivity_settings_create_or_update(self, resource_group): + response = await self.client.sensitivity_settings.create_or_update( + sensitivity_settings={ + "sensitiveInfoTypesIds": ["str"], + "sensitivityThresholdLabelId": "str", + "sensitivityThresholdLabelOrder": 0.0, + }, + api_version="2023-02-15-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sensitivity_settings_get(self, resource_group): + response = await self.client.sensitivity_settings.get( + api_version="2023-02-15-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sensitivity_settings_list(self, resource_group): + response = await self.client.sensitivity_settings.list( + api_version="2023-02-15-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessment_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessment_operations.py new file mode 100644 index 000000000000..75940af44468 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessment_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterServerVulnerabilityAssessmentOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_vulnerability_assessment_list_by_extended_resource(self, resource_group): + response = self.client.server_vulnerability_assessment.list_by_extended_resource( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_vulnerability_assessment_get(self, resource_group): + response = self.client.server_vulnerability_assessment.get( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + server_vulnerability_assessment="default", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_vulnerability_assessment_create_or_update(self, resource_group): + response = self.client.server_vulnerability_assessment.create_or_update( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + server_vulnerability_assessment="default", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_vulnerability_assessment_begin_delete(self, resource_group): + response = self.client.server_vulnerability_assessment.begin_delete( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + server_vulnerability_assessment="default", + api_version="2020-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessment_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessment_operations_async.py new file mode 100644 index 000000000000..ced4da5957ff --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessment_operations_async.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterServerVulnerabilityAssessmentOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_vulnerability_assessment_list_by_extended_resource(self, resource_group): + response = await self.client.server_vulnerability_assessment.list_by_extended_resource( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_vulnerability_assessment_get(self, resource_group): + response = await self.client.server_vulnerability_assessment.get( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + server_vulnerability_assessment="default", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_vulnerability_assessment_create_or_update(self, resource_group): + response = await self.client.server_vulnerability_assessment.create_or_update( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + server_vulnerability_assessment="default", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_vulnerability_assessment_begin_delete(self, resource_group): + response = await ( + await self.client.server_vulnerability_assessment.begin_delete( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + server_vulnerability_assessment="default", + api_version="2020-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessments_settings_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessments_settings_operations.py new file mode 100644 index 000000000000..851e1417d3d9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessments_settings_operations.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterServerVulnerabilityAssessmentsSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_vulnerability_assessments_settings_list_by_subscription(self, resource_group): + response = self.client.server_vulnerability_assessments_settings.list_by_subscription( + api_version="2023-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_vulnerability_assessments_settings_get(self, resource_group): + response = self.client.server_vulnerability_assessments_settings.get( + setting_kind="str", + api_version="2023-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_vulnerability_assessments_settings_create_or_update(self, resource_group): + response = self.client.server_vulnerability_assessments_settings.create_or_update( + setting_kind="str", + server_vulnerability_assessments_setting={ + "kind": "AzureServersSetting", + "id": "str", + "name": "str", + "selectedProvider": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_vulnerability_assessments_settings_delete(self, resource_group): + response = self.client.server_vulnerability_assessments_settings.delete( + setting_kind="str", + api_version="2023-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessments_settings_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessments_settings_operations_async.py new file mode 100644 index 000000000000..29a491f8a403 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_server_vulnerability_assessments_settings_operations_async.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterServerVulnerabilityAssessmentsSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_vulnerability_assessments_settings_list_by_subscription(self, resource_group): + response = self.client.server_vulnerability_assessments_settings.list_by_subscription( + api_version="2023-05-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_server_vulnerability_assessments_settings_get(self, resource_group): + response = await self.client.server_vulnerability_assessments_settings.get( + setting_kind="str", + api_version="2023-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_vulnerability_assessments_settings_create_or_update(self, resource_group): + response = await self.client.server_vulnerability_assessments_settings.create_or_update( + setting_kind="str", + server_vulnerability_assessments_setting={ + "kind": "AzureServersSetting", + "id": "str", + "name": "str", + "selectedProvider": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_vulnerability_assessments_settings_delete(self, resource_group): + response = await self.client.server_vulnerability_assessments_settings.delete( + setting_kind="str", + api_version="2023-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_settings_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_settings_operations.py new file mode 100644 index 000000000000..2770f977f023 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_settings_operations.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_settings_list(self, resource_group): + response = self.client.settings.list( + api_version="2022-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_settings_get(self, resource_group): + response = self.client.settings.get( + setting_name="str", + api_version="2022-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_settings_update(self, resource_group): + response = self.client.settings.update( + setting_name="str", + setting={"kind": "AlertSyncSettings", "enabled": bool, "id": "str", "name": "str", "type": "str"}, + api_version="2022-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_settings_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_settings_operations_async.py new file mode 100644 index 000000000000..72f7eba5d140 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_settings_operations_async.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_settings_list(self, resource_group): + response = self.client.settings.list( + api_version="2022-05-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_settings_get(self, resource_group): + response = await self.client.settings.get( + setting_name="str", + api_version="2022-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_settings_update(self, resource_group): + response = await self.client.settings.update( + setting_name="str", + setting={"kind": "AlertSyncSettings", "enabled": bool, "id": "str", "name": "str", "type": "str"}, + api_version="2022-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_software_inventories_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_software_inventories_operations.py new file mode 100644 index 000000000000..a17633630685 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_software_inventories_operations.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSoftwareInventoriesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_software_inventories_list_by_extended_resource(self, resource_group): + response = self.client.software_inventories.list_by_extended_resource( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + api_version="2021-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_software_inventories_list_by_subscription(self, resource_group): + response = self.client.software_inventories.list_by_subscription( + api_version="2021-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_software_inventories_get(self, resource_group): + response = self.client.software_inventories.get( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + software_name="str", + api_version="2021-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_software_inventories_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_software_inventories_operations_async.py new file mode 100644 index 000000000000..f1e90e9a6565 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_software_inventories_operations_async.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSoftwareInventoriesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_software_inventories_list_by_extended_resource(self, resource_group): + response = self.client.software_inventories.list_by_extended_resource( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + api_version="2021-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_software_inventories_list_by_subscription(self, resource_group): + response = self.client.software_inventories.list_by_subscription( + api_version="2021-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_software_inventories_get(self, resource_group): + response = await self.client.software_inventories.get( + resource_group_name=resource_group.name, + resource_namespace="str", + resource_type="str", + resource_name="str", + software_name="str", + api_version="2021-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_baseline_rules_operations.py new file mode 100644 index 000000000000..6b14dd56679d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_baseline_rules_operations.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSqlVulnerabilityAssessmentBaselineRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_baseline_rules_create_or_update(self, resource_group): + response = self.client.sql_vulnerability_assessment_baseline_rules.create_or_update( + rule_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_baseline_rules_get(self, resource_group): + response = self.client.sql_vulnerability_assessment_baseline_rules.get( + rule_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_baseline_rules_delete(self, resource_group): + response = self.client.sql_vulnerability_assessment_baseline_rules.delete( + rule_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_baseline_rules_list(self, resource_group): + response = self.client.sql_vulnerability_assessment_baseline_rules.list( + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_baseline_rules_add(self, resource_group): + response = self.client.sql_vulnerability_assessment_baseline_rules.add( + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_baseline_rules_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_baseline_rules_operations_async.py new file mode 100644 index 000000000000..3ae7827f1874 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_baseline_rules_operations_async.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSqlVulnerabilityAssessmentBaselineRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_baseline_rules_create_or_update(self, resource_group): + response = await self.client.sql_vulnerability_assessment_baseline_rules.create_or_update( + rule_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_baseline_rules_get(self, resource_group): + response = await self.client.sql_vulnerability_assessment_baseline_rules.get( + rule_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_baseline_rules_delete(self, resource_group): + response = await self.client.sql_vulnerability_assessment_baseline_rules.delete( + rule_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_baseline_rules_list(self, resource_group): + response = await self.client.sql_vulnerability_assessment_baseline_rules.list( + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_baseline_rules_add(self, resource_group): + response = await self.client.sql_vulnerability_assessment_baseline_rules.add( + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scan_results_operations.py new file mode 100644 index 000000000000..521ad787fe31 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scan_results_operations.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSqlVulnerabilityAssessmentScanResultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_scan_results_get(self, resource_group): + response = self.client.sql_vulnerability_assessment_scan_results.get( + scan_id="str", + scan_result_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_scan_results_list(self, resource_group): + response = self.client.sql_vulnerability_assessment_scan_results.list( + scan_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scan_results_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scan_results_operations_async.py new file mode 100644 index 000000000000..da0ab7da05d2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scan_results_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSqlVulnerabilityAssessmentScanResultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_scan_results_get(self, resource_group): + response = await self.client.sql_vulnerability_assessment_scan_results.get( + scan_id="str", + scan_result_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_scan_results_list(self, resource_group): + response = await self.client.sql_vulnerability_assessment_scan_results.list( + scan_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scans_operations.py new file mode 100644 index 000000000000..1354aa186b2d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scans_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSqlVulnerabilityAssessmentScansOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_scans_get(self, resource_group): + response = self.client.sql_vulnerability_assessment_scans.get( + scan_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_scans_list(self, resource_group): + response = self.client.sql_vulnerability_assessment_scans.list( + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scans_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scans_operations_async.py new file mode 100644 index 000000000000..d2502faf0335 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sql_vulnerability_assessment_scans_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSqlVulnerabilityAssessmentScansOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_scans_get(self, resource_group): + response = await self.client.sql_vulnerability_assessment_scans.get( + scan_id="str", + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_scans_list(self, resource_group): + response = await self.client.sql_vulnerability_assessment_scans.list( + workspace_id="str", + resource_id="str", + api_version="2023-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_standard_assignments_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_standard_assignments_operations.py new file mode 100644 index 000000000000..297844806d81 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_standard_assignments_operations.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterStandardAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_standard_assignments_get(self, resource_group): + response = self.client.standard_assignments.get( + resource_id="str", + standard_assignment_name="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_standard_assignments_create(self, resource_group): + response = self.client.standard_assignments.create( + resource_id="str", + standard_assignment_name="str", + standard_assignment={ + "assignedStandard": {"id": "str"}, + "attestationData": { + "assignedAssessment": {"assessmentKey": "str"}, + "complianceDate": "2020-02-20 00:00:00", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUrl": "str"}], + }, + "description": "str", + "displayName": "str", + "effect": "str", + "excludedScopes": ["str"], + "exemptionData": {"assignedAssessment": {"assessmentKey": "str"}, "exemptionCategory": "str"}, + "expiresOn": "2020-02-20 00:00:00", + "id": "str", + "metadata": { + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "lastUpdatedBy": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + }, + "name": "str", + "type": "str", + }, + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_standard_assignments_delete(self, resource_group): + response = self.client.standard_assignments.delete( + resource_id="str", + standard_assignment_name="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_standard_assignments_list(self, resource_group): + response = self.client.standard_assignments.list( + scope="str", + api_version="2024-08-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_standard_assignments_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_standard_assignments_operations_async.py new file mode 100644 index 000000000000..43d8c823421b --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_standard_assignments_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterStandardAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_standard_assignments_get(self, resource_group): + response = await self.client.standard_assignments.get( + resource_id="str", + standard_assignment_name="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_standard_assignments_create(self, resource_group): + response = await self.client.standard_assignments.create( + resource_id="str", + standard_assignment_name="str", + standard_assignment={ + "assignedStandard": {"id": "str"}, + "attestationData": { + "assignedAssessment": {"assessmentKey": "str"}, + "complianceDate": "2020-02-20 00:00:00", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUrl": "str"}], + }, + "description": "str", + "displayName": "str", + "effect": "str", + "excludedScopes": ["str"], + "exemptionData": {"assignedAssessment": {"assessmentKey": "str"}, "exemptionCategory": "str"}, + "expiresOn": "2020-02-20 00:00:00", + "id": "str", + "metadata": { + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "lastUpdatedBy": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + }, + "name": "str", + "type": "str", + }, + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_standard_assignments_delete(self, resource_group): + response = await self.client.standard_assignments.delete( + resource_id="str", + standard_assignment_name="str", + api_version="2024-08-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_standard_assignments_list(self, resource_group): + response = self.client.standard_assignments.list( + scope="str", + api_version="2024-08-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sub_assessments_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sub_assessments_operations.py new file mode 100644 index 000000000000..a5160a1ed140 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sub_assessments_operations.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterSubAssessmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sub_assessments_list_all(self, resource_group): + response = self.client.sub_assessments.list_all( + scope="str", + api_version="2019-01-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sub_assessments_list(self, resource_group): + response = self.client.sub_assessments.list( + scope="str", + assessment_name="str", + api_version="2019-01-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sub_assessments_get(self, resource_group): + response = self.client.sub_assessments.get( + scope="str", + assessment_name="str", + sub_assessment_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sub_assessments_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sub_assessments_operations_async.py new file mode 100644 index 000000000000..9bb3675cf524 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_sub_assessments_operations_async.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterSubAssessmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sub_assessments_list_all(self, resource_group): + response = self.client.sub_assessments.list_all( + scope="str", + api_version="2019-01-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sub_assessments_list(self, resource_group): + response = self.client.sub_assessments.list( + scope="str", + assessment_name="str", + api_version="2019-01-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sub_assessments_get(self, resource_group): + response = await self.client.sub_assessments.get( + scope="str", + assessment_name="str", + sub_assessment_name="str", + api_version="2019-01-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_tasks_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_tasks_operations.py new file mode 100644 index 000000000000..72bb156cf3ea --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_tasks_operations.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterTasksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tasks_list(self, resource_group): + response = self.client.tasks.list( + api_version="2015-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tasks_list_by_home_region(self, resource_group): + response = self.client.tasks.list_by_home_region( + asc_location="str", + api_version="2015-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tasks_get_subscription_level_task(self, resource_group): + response = self.client.tasks.get_subscription_level_task( + asc_location="str", + task_name="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tasks_update_subscription_level_task_state(self, resource_group): + response = self.client.tasks.update_subscription_level_task_state( + asc_location="str", + task_name="str", + task_update_action_type="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tasks_list_by_resource_group(self, resource_group): + response = self.client.tasks.list_by_resource_group( + resource_group_name=resource_group.name, + asc_location="str", + api_version="2015-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tasks_get_resource_group_level_task(self, resource_group): + response = self.client.tasks.get_resource_group_level_task( + resource_group_name=resource_group.name, + asc_location="str", + task_name="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tasks_update_resource_group_level_task_state(self, resource_group): + response = self.client.tasks.update_resource_group_level_task_state( + resource_group_name=resource_group.name, + asc_location="str", + task_name="str", + task_update_action_type="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_tasks_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_tasks_operations_async.py new file mode 100644 index 000000000000..c0692a193d99 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_tasks_operations_async.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterTasksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tasks_list(self, resource_group): + response = self.client.tasks.list( + api_version="2015-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tasks_list_by_home_region(self, resource_group): + response = self.client.tasks.list_by_home_region( + asc_location="str", + api_version="2015-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tasks_get_subscription_level_task(self, resource_group): + response = await self.client.tasks.get_subscription_level_task( + asc_location="str", + task_name="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tasks_update_subscription_level_task_state(self, resource_group): + response = await self.client.tasks.update_subscription_level_task_state( + asc_location="str", + task_name="str", + task_update_action_type="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tasks_list_by_resource_group(self, resource_group): + response = self.client.tasks.list_by_resource_group( + resource_group_name=resource_group.name, + asc_location="str", + api_version="2015-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tasks_get_resource_group_level_task(self, resource_group): + response = await self.client.tasks.get_resource_group_level_task( + resource_group_name=resource_group.name, + asc_location="str", + task_name="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tasks_update_resource_group_level_task_state(self, resource_group): + response = await self.client.tasks.update_resource_group_level_task_state( + resource_group_name=resource_group.name, + asc_location="str", + task_name="str", + task_update_action_type="str", + api_version="2015-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_topology_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_topology_operations.py new file mode 100644 index 000000000000..378e4b0614e3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_topology_operations.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterTopologyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_topology_list(self, resource_group): + response = self.client.topology.list( + api_version="2020-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_topology_list_by_home_region(self, resource_group): + response = self.client.topology.list_by_home_region( + asc_location="str", + api_version="2020-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_topology_get(self, resource_group): + response = self.client.topology.get( + resource_group_name=resource_group.name, + asc_location="str", + topology_resource_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_topology_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_topology_operations_async.py new file mode 100644 index 000000000000..e29861bbfe27 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_topology_operations_async.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterTopologyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_topology_list(self, resource_group): + response = self.client.topology.list( + api_version="2020-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_topology_list_by_home_region(self, resource_group): + response = self.client.topology.list_by_home_region( + asc_location="str", + api_version="2020-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_topology_get(self, resource_group): + response = await self.client.topology.get( + resource_group_name=resource_group.name, + asc_location="str", + topology_resource_name="str", + api_version="2020-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_workspace_settings_operations.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_workspace_settings_operations.py new file mode 100644 index 000000000000..606254b9ebb4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_workspace_settings_operations.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +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 TestSecurityCenterWorkspaceSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_settings_list(self, resource_group): + response = self.client.workspace_settings.list( + api_version="2017-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_settings_get(self, resource_group): + response = self.client.workspace_settings.get( + workspace_setting_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_settings_create(self, resource_group): + response = self.client.workspace_settings.create( + workspace_setting_name="str", + workspace_setting={"id": "str", "name": "str", "scope": "str", "type": "str", "workspaceId": "str"}, + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_settings_update(self, resource_group): + response = self.client.workspace_settings.update( + workspace_setting_name="str", + workspace_setting={"id": "str", "name": "str", "scope": "str", "type": "str", "workspaceId": "str"}, + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_settings_delete(self, resource_group): + response = self.client.workspace_settings.delete( + workspace_setting_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/generated_tests/test_security_center_workspace_settings_operations_async.py b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_workspace_settings_operations_async.py new file mode 100644 index 000000000000..04033f54ffdd --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_tests/test_security_center_workspace_settings_operations_async.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +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 TestSecurityCenterWorkspaceSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_settings_list(self, resource_group): + response = self.client.workspace_settings.list( + api_version="2017-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_settings_get(self, resource_group): + response = await self.client.workspace_settings.get( + workspace_setting_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_settings_create(self, resource_group): + response = await self.client.workspace_settings.create( + workspace_setting_name="str", + workspace_setting={"id": "str", "name": "str", "scope": "str", "type": "str", "workspaceId": "str"}, + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_settings_update(self, resource_group): + response = await self.client.workspace_settings.update( + workspace_setting_name="str", + workspace_setting={"id": "str", "name": "str", "scope": "str", "type": "str", "workspaceId": "str"}, + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_settings_delete(self, resource_group): + response = await self.client.workspace_settings.delete( + workspace_setting_name="str", + api_version="2017-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/security/azure-mgmt-security/pyproject.toml b/sdk/security/azure-mgmt-security/pyproject.toml index 540da07d41af..a3006bd168dd 100644 --- a/sdk/security/azure-mgmt-security/pyproject.toml +++ b/sdk/security/azure-mgmt-security/pyproject.toml @@ -4,3 +4,12 @@ mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-security" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Security Center Management" +package_doc_id = "" +is_stable = false +is_arm = true +title = "SecurityCenter" diff --git a/sdk/security/azure-mgmt-security/sdk_packaging.toml b/sdk/security/azure-mgmt-security/sdk_packaging.toml deleted file mode 100644 index 63e8f7734327..000000000000 --- a/sdk/security/azure-mgmt-security/sdk_packaging.toml +++ /dev/null @@ -1,8 +0,0 @@ -[packaging] -package_name = "azure-mgmt-security" -package_nspkg = "azure-mgmt-nspkg" -package_pprint_name = "Security Center Management" -package_doc_id = "" -is_stable = true -is_arm = true -title = "SecurityCenter" diff --git a/sdk/security/azure-mgmt-security/setup.py b/sdk/security/azure-mgmt-security/setup.py index 15b3b6e1bc8b..c5ee608bdd56 100644 --- a/sdk/security/azure-mgmt-security/setup.py +++ b/sdk/security/azure-mgmt-security/setup.py @@ -49,15 +49,15 @@ 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", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "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", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -75,8 +75,9 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", + "azure-mgmt-core>=1.6.0", ], - python_requires=">=3.8", + python_requires=">=3.9", ) diff --git a/sdk/security/azure-mgmt-security/tests/conftest.py b/sdk/security/azure-mgmt-security/tests/conftest.py new file mode 100644 index 000000000000..597418983477 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + securitycenter_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + securitycenter_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + securitycenter_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + securitycenter_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=securitycenter_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=securitycenter_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=securitycenter_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=securitycenter_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_operations_async_test.py new file mode 100644 index 000000000000..0e81abea3c95 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAlertsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_list(self, resource_group): + response = self.client.alerts.list() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_list_by_resource_group(self, resource_group): + response = self.client.alerts.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_operations_test.py new file mode 100644 index 000000000000..5c4fccc7a887 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAlertsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_list(self, resource_group): + response = self.client.alerts.list() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_list_by_resource_group(self, resource_group): + response = self.client.alerts.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_suppression_rules_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_suppression_rules_operations_async_test.py new file mode 100644 index 000000000000..d317ded77b93 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_suppression_rules_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAlertsSuppressionRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_suppression_rules_list(self, resource_group): + response = self.client.alerts_suppression_rules.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_suppression_rules_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_suppression_rules_operations_test.py new file mode 100644 index 000000000000..72bea8db881a --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_alerts_suppression_rules_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAlertsSuppressionRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_suppression_rules_list(self, resource_group): + response = self.client.alerts_suppression_rules.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_allowed_connections_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_allowed_connections_operations_async_test.py new file mode 100644 index 000000000000..1729acbf70c1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_allowed_connections_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAllowedConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_allowed_connections_list(self, resource_group): + response = self.client.allowed_connections.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_allowed_connections_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_allowed_connections_operations_test.py new file mode 100644 index 000000000000..27089e9fcd98 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_allowed_connections_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAllowedConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_allowed_connections_list(self, resource_group): + response = self.client.allowed_connections.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_auto_provisioning_settings_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_auto_provisioning_settings_operations_async_test.py new file mode 100644 index 000000000000..b6578487a30d --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_auto_provisioning_settings_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAutoProvisioningSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_auto_provisioning_settings_list(self, resource_group): + response = self.client.auto_provisioning_settings.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_auto_provisioning_settings_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_auto_provisioning_settings_operations_test.py new file mode 100644 index 000000000000..90d7590305bd --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_auto_provisioning_settings_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAutoProvisioningSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_auto_provisioning_settings_list(self, resource_group): + response = self.client.auto_provisioning_settings.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_automations_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_automations_operations_async_test.py new file mode 100644 index 000000000000..fcb425f0d9f0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_automations_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAutomationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automations_list(self, resource_group): + response = self.client.automations.list() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automations_list_by_resource_group(self, resource_group): + response = self.client.automations.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_automations_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_automations_operations_test.py new file mode 100644 index 000000000000..8543c758715a --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_automations_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterAutomationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automations_list(self, resource_group): + response = self.client.automations.list() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automations_list_by_resource_group(self, resource_group): + response = self.client.automations.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_discovered_security_solutions_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_discovered_security_solutions_operations_async_test.py new file mode 100644 index 000000000000..c753990e7701 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_discovered_security_solutions_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterDiscoveredSecuritySolutionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_discovered_security_solutions_list(self, resource_group): + response = self.client.discovered_security_solutions.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_discovered_security_solutions_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_discovered_security_solutions_operations_test.py new file mode 100644 index 000000000000..cf93b3032a41 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_discovered_security_solutions_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterDiscoveredSecuritySolutionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_discovered_security_solutions_list(self, resource_group): + response = self.client.discovered_security_solutions.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_external_security_solutions_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_external_security_solutions_operations_async_test.py new file mode 100644 index 000000000000..2475c26d0d56 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_external_security_solutions_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterExternalSecuritySolutionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_external_security_solutions_list(self, resource_group): + response = self.client.external_security_solutions.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_external_security_solutions_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_external_security_solutions_operations_test.py new file mode 100644 index 000000000000..216efd5a87e4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_external_security_solutions_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterExternalSecuritySolutionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_external_security_solutions_list(self, resource_group): + response = self.client.external_security_solutions.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_jit_network_access_policies_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_jit_network_access_policies_operations_async_test.py new file mode 100644 index 000000000000..fa7eb1dce4d6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_jit_network_access_policies_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterJitNetworkAccessPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_network_access_policies_list(self, resource_group): + response = self.client.jit_network_access_policies.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_jit_network_access_policies_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_jit_network_access_policies_operations_test.py new file mode 100644 index 000000000000..5cbfde82ac7e --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_jit_network_access_policies_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterJitNetworkAccessPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_network_access_policies_list(self, resource_group): + response = self.client.jit_network_access_policies.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_locations_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_locations_operations_async_test.py new file mode 100644 index 000000000000..95c46027fbff --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_locations_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterLocationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_locations_list(self, resource_group): + response = self.client.locations.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_locations_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_locations_operations_test.py new file mode 100644 index 000000000000..f33eed144013 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_locations_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterLocationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_locations_list(self, resource_group): + response = self.client.locations.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_mde_onboardings_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_mde_onboardings_operations_async_test.py new file mode 100644 index 000000000000..650d76f516e0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_mde_onboardings_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterMdeOnboardingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_mde_onboardings_list(self, resource_group): + response = await self.client.mde_onboardings.list() + + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_mde_onboardings_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_mde_onboardings_operations_test.py new file mode 100644 index 000000000000..6535d44d36f8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_mde_onboardings_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterMdeOnboardingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_mde_onboardings_list(self, resource_group): + response = self.client.mde_onboardings.list() + + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_regulatory_compliance_standards_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_regulatory_compliance_standards_operations_async_test.py new file mode 100644 index 000000000000..3f26d10a65b5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_regulatory_compliance_standards_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterRegulatoryComplianceStandardsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regulatory_compliance_standards_list(self, resource_group): + response = self.client.regulatory_compliance_standards.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_regulatory_compliance_standards_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_regulatory_compliance_standards_operations_test.py new file mode 100644 index 000000000000..12d6fe5bb0d2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_regulatory_compliance_standards_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterRegulatoryComplianceStandardsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regulatory_compliance_standards_list(self, resource_group): + response = self.client.regulatory_compliance_standards.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_secure_score_control_definitions_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_secure_score_control_definitions_operations_async_test.py new file mode 100644 index 000000000000..a6bfd4aebcb3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_secure_score_control_definitions_operations_async_test.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecureScoreControlDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_secure_score_control_definitions_list(self, resource_group): + response = self.client.secure_score_control_definitions.list() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_secure_score_control_definitions_list_by_subscription(self, resource_group): + response = self.client.secure_score_control_definitions.list_by_subscription() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_secure_score_control_definitions_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_secure_score_control_definitions_operations_test.py new file mode 100644 index 000000000000..a9fbda975043 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_secure_score_control_definitions_operations_test.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecureScoreControlDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secure_score_control_definitions_list(self, resource_group): + response = self.client.secure_score_control_definitions.list() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secure_score_control_definitions_list_by_subscription(self, resource_group): + response = self.client.secure_score_control_definitions.list_by_subscription() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_secure_scores_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_secure_scores_operations_async_test.py new file mode 100644 index 000000000000..a38726f6ab0c --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_secure_scores_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecureScoresOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_secure_scores_list(self, resource_group): + response = self.client.secure_scores.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_secure_scores_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_secure_scores_operations_test.py new file mode 100644 index 000000000000..1f5d72a4f520 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_secure_scores_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecureScoresOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secure_scores_list(self, resource_group): + response = self.client.secure_scores.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_security_connectors_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_security_connectors_operations_async_test.py new file mode 100644 index 000000000000..d50e7e1c187b --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_security_connectors_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecurityConnectorsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connectors_list(self, resource_group): + response = self.client.security_connectors.list() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_connectors_list_by_resource_group(self, resource_group): + response = self.client.security_connectors.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_security_connectors_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_security_connectors_operations_test.py new file mode 100644 index 000000000000..0a2b40f47b95 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_security_connectors_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecurityConnectorsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connectors_list(self, resource_group): + response = self.client.security_connectors.list() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_connectors_list_by_resource_group(self, resource_group): + response = self.client.security_connectors.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_security_contacts_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_security_contacts_operations_async_test.py new file mode 100644 index 000000000000..fa83f5792481 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_security_contacts_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecurityContactsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_contacts_list(self, resource_group): + response = self.client.security_contacts.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_security_contacts_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_security_contacts_operations_test.py new file mode 100644 index 000000000000..04e7e9cc486a --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_security_contacts_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecurityContactsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_contacts_list(self, resource_group): + response = self.client.security_contacts.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_security_solutions_reference_data_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_security_solutions_reference_data_operations_async_test.py new file mode 100644 index 000000000000..209a9268ee5d --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_security_solutions_reference_data_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecuritySolutionsReferenceDataOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_solutions_reference_data_list(self, resource_group): + response = await self.client.security_solutions_reference_data.list() + + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_security_solutions_reference_data_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_security_solutions_reference_data_operations_test.py new file mode 100644 index 000000000000..8071e506b8d4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_security_solutions_reference_data_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSecuritySolutionsReferenceDataOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_solutions_reference_data_list(self, resource_group): + response = self.client.security_solutions_reference_data.list() + + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_settings_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_settings_operations_async_test.py new file mode 100644 index 000000000000..1e687726bab5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_settings_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_settings_list(self, resource_group): + response = self.client.settings.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_settings_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_settings_operations_test.py new file mode 100644 index 000000000000..c4ad788c76ca --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_settings_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_settings_list(self, resource_group): + response = self.client.settings.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_tasks_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_tasks_operations_async_test.py new file mode 100644 index 000000000000..ef3f110cc7e7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_tasks_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterTasksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tasks_list(self, resource_group): + response = self.client.tasks.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_tasks_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_tasks_operations_test.py new file mode 100644 index 000000000000..625e2eec783b --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_tasks_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterTasksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tasks_list(self, resource_group): + response = self.client.tasks.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_topology_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_topology_operations_async_test.py new file mode 100644 index 000000000000..dbd776063add --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_topology_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterTopologyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_topology_list(self, resource_group): + response = self.client.topology.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_topology_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_topology_operations_test.py new file mode 100644 index 000000000000..132e80523ccd --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_topology_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterTopologyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_topology_list(self, resource_group): + response = self.client.topology.list() + result = [r for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_workspace_settings_operations_async_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_workspace_settings_operations_async_test.py new file mode 100644 index 000000000000..22e526b916bb --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_workspace_settings_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security.aio import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterWorkspaceSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_settings_list(self, resource_group): + response = self.client.workspace_settings.list() + result = [r async for r in response] + assert response diff --git a/sdk/security/azure-mgmt-security/tests/test_security_center_workspace_settings_operations_test.py b/sdk/security/azure-mgmt-security/tests/test_security_center_workspace_settings_operations_test.py new file mode 100644 index 000000000000..0f714107c800 --- /dev/null +++ b/sdk/security/azure-mgmt-security/tests/test_security_center_workspace_settings_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.security import SecurityCenter + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestSecurityCenterWorkspaceSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SecurityCenter) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_settings_list(self, resource_group): + response = self.client.workspace_settings.list() + result = [r for r in response] + assert response